2021-10-15 10:05:00 -05:00
|
|
|
# ---
|
2022-01-17 09:36:13 -05:00
|
|
|
# Stage 1: Build binary, create default config file
|
2021-10-15 10:05:00 -05:00
|
|
|
# ---
|
2023-10-04 11:12:56 -05:00
|
|
|
FROM --platform=$BUILDPLATFORM ghcr.io/project-zot/golang:1.20 AS builder
|
|
|
|
|
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
2022-01-24 00:19:01 -05:00
|
|
|
ARG COMMIT
|
2023-10-04 11:12:56 -05:00
|
|
|
|
2021-12-03 22:50:58 -05:00
|
|
|
RUN mkdir -p /go/src/github.com/project-zot/zot
|
|
|
|
WORKDIR /go/src/github.com/project-zot/zot
|
2021-10-15 10:05:00 -05:00
|
|
|
COPY . .
|
2023-10-04 11:12:56 -05:00
|
|
|
RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean exporter-minimal
|
2021-10-15 10:05:00 -05:00
|
|
|
RUN echo '{\n\
|
|
|
|
"Server": {\n\
|
|
|
|
"protocol": "http",\n\
|
|
|
|
"host": "127.0.0.1",\n\
|
2022-01-17 09:36:13 -05:00
|
|
|
"port": "5000"\n\
|
2021-10-15 10:05:00 -05:00
|
|
|
},\n\
|
|
|
|
"Exporter": {\n\
|
2022-01-17 09:36:13 -05:00
|
|
|
"port": "5001",\n\
|
2021-10-15 10:05:00 -05:00
|
|
|
"log": {\n\
|
|
|
|
"level": "debug"\n\
|
|
|
|
}\n\
|
|
|
|
}\n\
|
|
|
|
}\n' > config.json && cat config.json
|
|
|
|
|
|
|
|
# ---
|
2022-01-17 09:36:13 -05:00
|
|
|
# Stage 2: Final image with nothing but binary and default config file
|
2021-10-15 10:05:00 -05:00
|
|
|
# ---
|
2022-02-16 17:03:03 -05:00
|
|
|
FROM gcr.io/distroless/base AS final
|
2023-10-04 11:12:56 -05:00
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
|
|
|
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp-$TARGETOS-$TARGETARCH /zxp
|
2022-01-17 09:36:13 -05:00
|
|
|
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
|
|
|
|
ENTRYPOINT ["/zxp"]
|
|
|
|
EXPOSE 5001
|
|
|
|
CMD ["config", "/etc/zxp/config.json"]
|