mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-09 00:29:57 +08:00
44 lines
908 B
Text
44 lines
908 B
Text
|
FROM golang:alpine as builder
|
||
|
|
||
|
RUN apk update && apk add --no-cache git ca-certificates tzdata && update-ca-certificates
|
||
|
|
||
|
ENV USER=appuser
|
||
|
|
||
|
ENV UID=10001
|
||
|
|
||
|
RUN adduser \
|
||
|
--disabled-password \
|
||
|
--gecos "" \
|
||
|
--home "/nonexistent" \
|
||
|
--shell "/sbin/nologin" \
|
||
|
--no-create-home \
|
||
|
--uid "${UID}" \
|
||
|
"${USER}"
|
||
|
|
||
|
WORKDIR /app
|
||
|
|
||
|
# use modules
|
||
|
COPY go.mod .
|
||
|
|
||
|
ENV GO111MODULE=on
|
||
|
RUN go mod download && go mod verify
|
||
|
|
||
|
COPY . .
|
||
|
|
||
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
|
||
|
-ldflags='-w -s -extldflags "-static"' -a \
|
||
|
-o /go/bin/teldrive .
|
||
|
|
||
|
|
||
|
FROM scratch
|
||
|
|
||
|
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
||
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||
|
COPY --from=builder /etc/passwd /etc/passwd
|
||
|
COPY --from=builder /etc/group /etc/group
|
||
|
|
||
|
COPY --from=builder /go/bin/teldrive /go/bin/teldrive
|
||
|
|
||
|
USER appuser:appuser
|
||
|
|
||
|
ENTRYPOINT ["/go/bin/teldrive"]
|