-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
35 lines (28 loc) · 826 Bytes
/
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
FROM golang:1.22.1-alpine3.19 AS builder
ARG ENV
RUN apk update && apk upgrade --available && \
apk add make && \
adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "10001" \
"auth"
WORKDIR /opt/app/
COPY . .
RUN go mod download && go mod verify
RUN make build-app ENV=${ENV}
RUN mkdir logs/
FROM scratch
ARG CONFIG
WORKDIR /opt/app/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder --chown=auth:auth /opt/app/bin/main .
COPY --from=builder --chown=auth:auth /opt/app/${CONFIG} ./config
COPY --from=builder --chown=auth:auth /opt/app/tls/ ./tls/
COPY --from=builder --chown=auth:auth /opt/app/logs/ ./logs/
USER auth:auth
CMD ["./main", "-config=./config"]