about summary refs log tree commit diff
path: root/tools/govanity/Dockerfile
blob: db471c8a3a32f06bbb57fd6d929a5f1e97d5e372 (plain) (blame)
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
FROM golang:1.16 AS builder

WORKDIR /src

ENV USER=app
RUN adduser \
    --disabled-password \
    --gecos "" \
    --home "/src" \
    --shell "/sbin/nologin" \
    --uid "10001" \
    "${USER}"

ADD go.mod /src
ADD go.sum /src
RUN go mod download

ADD . /src

RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -a -installsuffix cgo -ldflags '-extldflags "-static"' -o app .

FROM scratch
COPY --from=builder /src/app /govanity
COPY --from=builder /src/vanity.yaml /vanity.yaml
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group

USER app:app

ENTRYPOINT ["/govanity"]