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