yt-stats/Dockerfile

20 lines
670 B
Docker
Raw Normal View History

2024-05-23 08:41:34 +00:00
FROM alpine:3.16 as root-certs
RUN apk add -U --no-cache ca-certificates
RUN addgroup -g 1001 app
RUN adduser app -u 1001 -D -G app /home/app
FROM golang:1.22 as builder
WORKDIR /yt-stats
COPY --from=root-certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=vendor -o ./yt-stats ./app/./...
FROM scratch as final
COPY --from=root-certs /etc/passwd /etc/passwd
COPY --from=root-certs /etc/group /etc/group
COPY --chown=1001:1001 --from=root-certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --chown=1001:1001 --from=builder /yt-stats/yt-stats /yt-stats
USER app
ENTRYPOINT ["/yt-stats"]