summaryrefslogtreecommitdiff
path: root/resources/Dockerfile
blob: 4a460c38f07c0ca25e6258c3a515d272380656ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
FROM golang:latest AS compile
WORKDIR /build

COPY . .
RUN go mod download && go mod verify

# Enable static linking for scratch
RUN CGO_ENABLED=0 GOOS=linux go build -o /application -ldflags="-s -w" main.go

FROM alpine:latest AS compressor
RUN apk add --no-cache upx
COPY --from=compile /application /application
RUN upx --best /application

FROM scratch AS package

# Copy CA certificates
COPY --from=alpine:latest /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=compressor /application /application

ENTRYPOINT ["/application"]