2024-01-12 10:02:48 +00:00
|
|
|
FROM golang:1.21.6 as builder
|
2021-02-19 23:58:01 +00:00
|
|
|
|
2022-07-20 09:58:19 +00:00
|
|
|
ARG LD_FLAGS='-s -w -linkmode external -extldflags "-static"'
|
2021-06-27 10:11:39 +00:00
|
|
|
ARG TARGETPLATFORM
|
|
|
|
|
2021-02-19 23:58:01 +00:00
|
|
|
WORKDIR /app
|
|
|
|
|
2021-06-27 10:11:39 +00:00
|
|
|
RUN export GOOS=$(echo ${TARGETPLATFORM} | cut -d / -f1) && \
|
|
|
|
export GOARCH=$(echo ${TARGETPLATFORM} | cut -d / -f2)
|
|
|
|
|
2023-09-22 11:29:01 +00:00
|
|
|
COPY go.* ./
|
|
|
|
RUN go env && go mod download
|
2021-06-27 10:11:39 +00:00
|
|
|
|
2023-09-22 11:29:01 +00:00
|
|
|
COPY . .
|
2021-02-19 23:58:01 +00:00
|
|
|
|
2023-03-03 10:07:25 +00:00
|
|
|
RUN CGO_ENABLED=1 go build -ldflags="${LD_FLAGS}" -tags="sqlite_unlock_notify" -o /app/build/policyreporter -v
|
2021-02-19 23:58:01 +00:00
|
|
|
|
2021-06-27 10:11:39 +00:00
|
|
|
FROM scratch
|
2021-10-18 09:07:38 +00:00
|
|
|
LABEL MAINTAINER="Frank Jogeleit <frank.jogeleit@gweb.de>"
|
2021-02-19 23:58:01 +00:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
USER 1234
|
|
|
|
|
|
|
|
COPY --from=builder /app/LICENSE.md .
|
2022-07-03 21:49:16 +00:00
|
|
|
COPY --from=builder /app/templates /app/templates
|
2021-02-19 23:58:01 +00:00
|
|
|
COPY --from=builder /app/build/policyreporter /app/policyreporter
|
2021-08-06 09:47:35 +00:00
|
|
|
# copy the debian's trusted root CA's to the final image
|
|
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
2021-02-19 23:58:01 +00:00
|
|
|
|
2023-03-03 10:07:25 +00:00
|
|
|
EXPOSE 8080
|
2021-02-19 23:58:01 +00:00
|
|
|
|
2021-08-06 09:47:35 +00:00
|
|
|
ENTRYPOINT ["/app/policyreporter", "run"]
|