From c9f1f3450da4490f02cb189925c7485c735b2e3b Mon Sep 17 00:00:00 2001 From: Simon Rieger Date: Wed, 10 Jan 2024 14:18:00 +0100 Subject: [PATCH] fix dockerfile for me --- Dockerfile | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4c81ef..d846e28 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,30 @@ -FROM alpine:3.19.0 as builder +# syntax=docker/dockerfile:1 + +# Build the application from source +FROM golang:1.21.4 AS build-stage + +WORKDIR /app + +COPY go.mod go.sum ./ +RUN go mod download + +COPY *.go ./ + +RUN CGO_ENABLED=0 GOOS=linux go build -o /prometheus-jitsi-meet-exporter -WORKDIR /go/src/github.com/systemli/prometheus-jitsi-meet-exporter +# Run the tests in the container +FROM build-stage AS run-test-stage +RUN go test -v ./... -ENV USER=appuser -ENV UID=10001 +# Deploy the application binary into a lean image +FROM gcr.io/distroless/base-debian11 AS build-release-stage -RUN adduser \ - --disabled-password \ - --gecos "" \ - --home "/nonexistent" \ - --shell "/sbin/nologin" \ - --no-create-home \ - --uid "${UID}" \ - "${USER}" +WORKDIR / - -FROM scratch - -COPY --from=builder /etc/passwd /etc/passwd -COPY --from=builder /etc/group /etc/group -COPY prometheus-jitsi-meet-exporter /prometheus-jitsi-meet-exporter - -USER appuser:appuser +COPY --from=build-stage /prometheus-jitsi-meet-exporter /prometheus-jitsi-meet-exporter EXPOSE 9888 +USER nonroot:nonroot + ENTRYPOINT ["/prometheus-jitsi-meet-exporter"]