33 lines
644 B
Docker
33 lines
644 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
|
|
|
|
RUN mkdir /webdav/root && chown -R 101:101 /webdav
|
|
|
|
USER 101
|
|
|
|
COPY --from=build-env /src/app .
|
|
|
|
ENTRYPOINT [ "./app" ]
|