30 lines
591 B
Docker
30 lines
591 B
Docker
|
# build stage
|
||
|
FROM golang:1.16-stretch AS build-env
|
||
|
|
||
|
WORKDIR /src
|
||
|
|
||
|
COPY go.mod /src/go.mod
|
||
|
RUN go mod download
|
||
|
|
||
|
COPY . /src
|
||
|
|
||
|
ENV GO113MODULE=on
|
||
|
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o app .
|
||
|
|
||
|
# cert stage
|
||
|
FROM alpine:latest as certs
|
||
|
RUN apk --update add ca-certificates
|
||
|
|
||
|
# final stage
|
||
|
FROM scratch
|
||
|
LABEL maintainer="Lennard Brinkhaus <lennard.brinkhaus@dragse.de>"
|
||
|
|
||
|
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||
|
|
||
|
WORKDIR /app
|
||
|
|
||
|
USER 101
|
||
|
|
||
|
COPY --from=build-env /src/app .
|
||
|
|
||
|
ENTRYPOINT [ "./app" ]
|