-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (28 loc) · 1.06 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# ---
FROM --platform=$BUILDPLATFORM registry-1.docker.io/library/alpine:latest as certs
RUN apk update && apk add --no-cache ca-certificates
# ---
FROM --platform=$BUILDPLATFORM registry-1.docker.io/library/golang:1.21.4 as builder
WORKDIR /build/
COPY go.mod go.sum ./
RUN go mod download
ARG TARGETOS TARGETARCH VERSION
COPY . /build/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags "-s -w -X main.version=${VERSION}" -o /out/dpsproxy-server ./cmd/dpsproxy-server/main.go
# ---
FROM registry-1.docker.io/library/busybox:1.36.1
ARG TARGETOS TARGETARCH
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-$TARGETARCH /tini
RUN chmod +x /tini
RUN mkdir /app
RUN addgroup -S app && adduser -S -G app app
WORKDIR /app
COPY --from=builder /out/dpsproxy-server .
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
RUN chown -R app:app .
USER app
EXPOSE 3000
ENTRYPOINT ["/tini", "--", "/app/dpsproxy-server"]