-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
27 lines (26 loc) · 835 Bytes
/
Dockerfile
File metadata and controls
27 lines (26 loc) · 835 Bytes
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
# golang alpine 1.13.5-alpine
FROM golang:1.16.5-alpine AS builder
# Create sngular user.
RUN adduser -D -g '' sngular
# Create workspace
WORKDIR /opt/app/
COPY go.mod go.sum ./
# fetch dependancies
RUN go mod download
RUN go mod verify
# copy the source code as the last step
COPY . .
# build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o /go/bin/gitops-echobot .
# build a small image
FROM alpine:3.14.0
LABEL language="golang"
LABEL org.opencontainers.image.source https://github.com/sngular/gitops-echobot
# import the user and group files from the builder.
COPY --from=builder /etc/passwd /etc/passwd
# copy the static executable
COPY --from=builder /go/bin/gitops-echobot /usr/local/bin/gitops-echobot
# use an unprivileged user.
USER sngular
# run app
ENTRYPOINT ["gitops-echobot"]