Skip to content

Commit

Permalink
build: fix container image targets
Browse files Browse the repository at this point in the history
Use stacker to build OCI image.
Use podman/docker to build docker image.

Signed-off-by: Ramkumar Chinchani <[email protected]>
  • Loading branch information
rchincha committed Sep 26, 2023
1 parent 510b7a2 commit 962b7cb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 17 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ run-container:
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
zot-build:latest

.PHONY: binary-stacker
binary-stacker: $(STACKER)
.PHONY: oci-image
oci-image: $(STACKER)
${STACKER} --debug build \
-f build/stacker.yaml \
--substitute COMMIT=$(COMMIT) \
Expand All @@ -348,9 +348,9 @@ binary-stacker: $(STACKER)
--substitute RELEASE_TAG=$(RELEASE_TAG) \
--substitute REPO_NAME=zot-$(OS)-$(ARCH)

.PHONY: image
image:
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile -t zot:latest .
.PHONY: docker-image
docker-image:
${CONTAINER_RUNTIME} buildx build --platform $(OS)/$(ARCH) -f build/Dockerfile .

$(BATS):
rm -rf bats-core; \
Expand Down
6 changes: 6 additions & 0 deletions build/Dockerfile-conformance
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
# Stage 1: Install certs, build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.20 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG COMMIT

RUN apt-get update && apt-get install -y git make ca-certificates
RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
Expand All @@ -21,6 +25,8 @@ storage:\n\
# Stage 2: Final image with nothing but certs, binary, and default config file
# ---
FROM gcr.io/distroless/base AS final
ARG TARGETOS
ARG TARGETARCH
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zot-linux-amd64 /usr/bin/zot
COPY --from=builder /go/src/github.com/project-zot/zot/config.yml /etc/zot/config.yml
Expand Down
10 changes: 6 additions & 4 deletions build/Dockerfile-minimal
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# Stage 1: Install certs, build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.20 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG COMMIT
ARG OS
ARG ARCH

RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand All @@ -26,8 +28,8 @@ RUN echo '{\n\
# Stage 2: Final image with nothing but certs, binary, and default config file
# ---
FROM gcr.io/distroless/base AS final
ARG OS
ARG ARCH
ARG TARGETOS
ARG TARGETARCH
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zot-$OS-$ARCH-minimal /usr/bin/zot
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json
Expand Down
10 changes: 6 additions & 4 deletions build/Dockerfile-zb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# Stage 1: Install certs, build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.20 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG COMMIT
ARG OS
ARG ARCH

RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand All @@ -14,7 +16,7 @@ RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean bench
# Stage 2: Final image with nothing but certs, binary, and default config file
# ---
FROM gcr.io/distroless/base AS final
ARG OS
ARG ARCH
ARG TARGETOS
ARG TARGETARCH
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$OS-$ARCH /usr/bin/zb
ENTRYPOINT ["/usr/bin/zb"]
10 changes: 6 additions & 4 deletions build/Dockerfile-zxp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
# Stage 1: Build binary, create default config file
# ---
FROM ghcr.io/project-zot/golang:1.20 AS builder

ARG TARGETOS
ARG TARGETARCH
ARG COMMIT
ARG OS
ARG ARCH

RUN mkdir -p /go/src/github.com/project-zot/zot
WORKDIR /go/src/github.com/project-zot/zot
COPY . .
Expand All @@ -27,8 +29,8 @@ RUN echo '{\n\
# Stage 2: Final image with nothing but binary and default config file
# ---
FROM gcr.io/distroless/base AS final
ARG OS
ARG ARCH
ARG TARGETOS
ARG TARGETARCH
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp-$OS-$ARCH /zxp
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
ENTRYPOINT ["/zxp"]
Expand Down

0 comments on commit 962b7cb

Please sign in to comment.