File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Built following https://medium.com/@chemidy/create-the-smallest-and-secured-golang-docker-image-based-on-scratch-4752223b7324
2
+
3
+ # STEP 1 build executable binary
4
+ FROM golang:alpine as builder
5
+ # Install SSL ca certificates
6
+ RUN apk update && apk add git && apk add ca-certificates
7
+ # Create appuser
8
+ RUN adduser -D -g '' appuser
9
+ COPY . $GOPATH/src/mypackage/myapp/
10
+ WORKDIR $GOPATH/src/mypackage/myapp/
11
+ # get dependancies
12
+ RUN go get -d -v
13
+ # build the binary
14
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o /go/bin/alertmanager-discord
15
+
16
+
17
+ # STEP 2 build a small image
18
+ # start from scratch
19
+ FROM scratch
20
+ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
21
+ COPY --from=builder /etc/passwd /etc/passwd
22
+ # Copy our static executable
23
+ COPY --from=builder /go/bin/alertmanager-discord /go/bin/alertmanager-discord
24
+ USER appuser
25
+ ENTRYPOINT ["/go/bin/alertmanager-discord" ]
26
+
You can’t perform that action at this time.
0 commit comments