-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
22 lines (16 loc) · 789 Bytes
/
Copy pathDockerfile
File metadata and controls
22 lines (16 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
FROM golang:alpine3.12 as builder
RUN apk update && apk add --no-cache git ca-certificates tzdata gcc musl-dev && update-ca-certificates
ENV USER=appuser
ENV UID=10001
RUN adduser --disabled-password --gecos "" --home "/nonexistent" --shell "/sbin/nologin" --no-create-home --uid "${UID}" "${USER}"
WORKDIR $GOPATH/src/app/
COPY . .
RUN GOOS=linux GOARCH=amd64 go build -mod=vendor -ldflags='-w -s -extldflags "-static"' -a -o /go/bin/corpobot .
FROM scratch
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /go/bin/corpobot /go/bin/corpobot
USER appuser:appuser
ENTRYPOINT ["/go/bin/corpobot"]