mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
build: fix container image targets (#1856)
Use stacker to build OCI image. Use podman/docker to build docker image. Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
parent
ca1c3288cf
commit
c6407354b5
7 changed files with 57 additions and 33 deletions
12
.github/workflows/nightly.yaml
vendored
12
.github/workflows/nightly.yaml
vendored
|
@ -152,3 +152,15 @@ jobs:
|
||||||
cat /tmp/gc-bench-s3.log
|
cat /tmp/gc-bench-s3.log
|
||||||
exit 1
|
exit 1
|
||||||
- uses: ./.github/actions/teardown-localstack
|
- uses: ./.github/actions/teardown-localstack
|
||||||
|
|
||||||
|
docker-image:
|
||||||
|
name: Build docker image (for users still using Docker environments)
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: ./.github/actions/clean-runner
|
||||||
|
- name: Check out source code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Build image
|
||||||
|
run: |
|
||||||
|
make docker-image
|
||||||
|
|
|
@ -62,13 +62,13 @@ make exporter-minimal
|
||||||
## Using container builds (stacker)
|
## Using container builds (stacker)
|
||||||
|
|
||||||
```
|
```
|
||||||
make binary-stacker
|
make oci-image
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using container builds (docker)
|
## Using container builds (docker)
|
||||||
|
|
||||||
```
|
```
|
||||||
make binary-container
|
make docker-image
|
||||||
```
|
```
|
||||||
|
|
||||||
# Project Structure
|
# Project Structure
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -354,8 +354,8 @@ run-container:
|
||||||
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
|
${CONTAINER_RUNTIME} run --rm --security-opt label=disable -v $$(pwd):/go/src/github.com/project-zot/zot \
|
||||||
zot-build:latest
|
zot-build:latest
|
||||||
|
|
||||||
.PHONY: binary-stacker
|
.PHONY: oci-image
|
||||||
binary-stacker: $(STACKER)
|
oci-image: $(STACKER)
|
||||||
${STACKER} --debug build \
|
${STACKER} --debug build \
|
||||||
-f build/stacker.yaml \
|
-f build/stacker.yaml \
|
||||||
--substitute COMMIT=$(COMMIT) \
|
--substitute COMMIT=$(COMMIT) \
|
||||||
|
@ -364,9 +364,9 @@ binary-stacker: $(STACKER)
|
||||||
--substitute RELEASE_TAG=$(RELEASE_TAG) \
|
--substitute RELEASE_TAG=$(RELEASE_TAG) \
|
||||||
--substitute REPO_NAME=zot-$(OS)-$(ARCH)
|
--substitute REPO_NAME=zot-$(OS)-$(ARCH)
|
||||||
|
|
||||||
.PHONY: image
|
.PHONY: docker-image
|
||||||
image:
|
docker-image:
|
||||||
${CONTAINER_RUNTIME} build ${BUILD_ARGS} -f build/Dockerfile -t zot:latest .
|
${CONTAINER_RUNTIME} buildx build --platform $(OS)/$(ARCH) -f build/Dockerfile .
|
||||||
|
|
||||||
$(BATS):
|
$(BATS):
|
||||||
rm -rf bats-core; \
|
rm -rf bats-core; \
|
||||||
|
@ -438,7 +438,7 @@ fuzz-all:
|
||||||
bash test/scripts/fuzzAll.sh ${fuzztime}; \
|
bash test/scripts/fuzzAll.sh ${fuzztime}; \
|
||||||
rm -rf pkg/storage/testdata; \
|
rm -rf pkg/storage/testdata; \
|
||||||
|
|
||||||
$(STACKER):
|
$(STACKER): check-linux
|
||||||
mkdir -p $(TOOLSDIR)/bin; \
|
mkdir -p $(TOOLSDIR)/bin; \
|
||||||
curl -fsSL https://github.com/project-stacker/stacker/releases/latest/download/stacker -o $@; \
|
curl -fsSL https://github.com/project-stacker/stacker/releases/latest/download/stacker -o $@; \
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
# ---
|
# ---
|
||||||
# Stage 1: Install certs, build binary, create default config file
|
# Stage 1: Install certs, build binary, create default config file
|
||||||
# ---
|
# ---
|
||||||
FROM ghcr.io/project-zot/golang:1.20 AS builder
|
FROM --platform=$BUILDPLATFORM ghcr.io/project-zot/golang:1.20 AS builder
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y git make ca-certificates
|
RUN apt-get update && apt-get install -y git make ca-certificates
|
||||||
RUN mkdir -p /go/src/github.com/project-zot/zot
|
RUN mkdir -p /go/src/github.com/project-zot/zot
|
||||||
WORKDIR /go/src/github.com/project-zot/zot
|
WORKDIR /go/src/github.com/project-zot/zot
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make COMMIT=$COMMIT clean binary
|
RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean binary
|
||||||
RUN echo '# Default config file for zot server\n\
|
RUN echo '# Default config file for zot server\n\
|
||||||
http:\n\
|
http:\n\
|
||||||
address: 0.0.0.0\n\
|
address: 0.0.0.0\n\
|
||||||
|
@ -21,9 +25,11 @@ storage:\n\
|
||||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||||
# ---
|
# ---
|
||||||
FROM gcr.io/distroless/base AS final
|
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 /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/bin/zot-$TARGETOS-$TARGETARCH /usr/bin/zot
|
||||||
COPY --from=builder /go/src/github.com/project-zot/zot/config.yaml /etc/zot/config.yaml
|
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json
|
||||||
ENTRYPOINT ["/usr/bin/zot"]
|
ENTRYPOINT ["/usr/bin/zot"]
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
VOLUME ["/var/lib/registry"]
|
VOLUME ["/var/lib/registry"]
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
# ---
|
# ---
|
||||||
# Stage 1: Install certs, build binary, create default config file
|
# Stage 1: Install certs, build binary, create default config file
|
||||||
# ---
|
# ---
|
||||||
FROM ghcr.io/project-zot/golang:1.20 AS builder
|
FROM --platform=$BUILDPLATFORM ghcr.io/project-zot/golang:1.20 AS builder
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
ARG OS
|
|
||||||
ARG ARCH
|
|
||||||
RUN mkdir -p /go/src/github.com/project-zot/zot
|
RUN mkdir -p /go/src/github.com/project-zot/zot
|
||||||
WORKDIR /go/src/github.com/project-zot/zot
|
WORKDIR /go/src/github.com/project-zot/zot
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean binary-minimal
|
RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean binary-minimal
|
||||||
RUN echo '{\n\
|
RUN echo '{\n\
|
||||||
"storage": {\n\
|
"storage": {\n\
|
||||||
"rootDirectory": "/var/lib/registry"\n\
|
"rootDirectory": "/var/lib/registry"\n\
|
||||||
|
@ -26,10 +28,10 @@ RUN echo '{\n\
|
||||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||||
# ---
|
# ---
|
||||||
FROM gcr.io/distroless/base AS final
|
FROM gcr.io/distroless/base AS final
|
||||||
ARG OS
|
ARG TARGETOS
|
||||||
ARG ARCH
|
ARG TARGETARCH
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
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/bin/zot-$TARGETOS-$TARGETARCH-minimal /usr/bin/zot
|
||||||
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json
|
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json
|
||||||
ENTRYPOINT ["/usr/bin/zot"]
|
ENTRYPOINT ["/usr/bin/zot"]
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
|
@ -1,20 +1,22 @@
|
||||||
# ---
|
# ---
|
||||||
# Stage 1: Install certs, build binary, create default config file
|
# Stage 1: Install certs, build binary, create default config file
|
||||||
# ---
|
# ---
|
||||||
FROM ghcr.io/project-zot/golang:1.20 AS builder
|
FROM --platform=$BUILDPLATFORM ghcr.io/project-zot/golang:1.20 AS builder
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
ARG OS
|
|
||||||
ARG ARCH
|
|
||||||
RUN mkdir -p /go/src/github.com/project-zot/zot
|
RUN mkdir -p /go/src/github.com/project-zot/zot
|
||||||
WORKDIR /go/src/github.com/project-zot/zot
|
WORKDIR /go/src/github.com/project-zot/zot
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean bench
|
RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean bench
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||||
# ---
|
# ---
|
||||||
FROM gcr.io/distroless/base AS final
|
FROM gcr.io/distroless/base AS final
|
||||||
ARG OS
|
ARG TARGETOS
|
||||||
ARG ARCH
|
ARG TARGETARCH
|
||||||
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$OS-$ARCH /usr/bin/zb
|
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$TARGETOS-$TARGETARCH /usr/bin/zb
|
||||||
ENTRYPOINT ["/usr/bin/zb"]
|
ENTRYPOINT ["/usr/bin/zb"]
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
# ---
|
# ---
|
||||||
# Stage 1: Build binary, create default config file
|
# Stage 1: Build binary, create default config file
|
||||||
# ---
|
# ---
|
||||||
FROM ghcr.io/project-zot/golang:1.20 AS builder
|
FROM --platform=$BUILDPLATFORM ghcr.io/project-zot/golang:1.20 AS builder
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
ARG COMMIT
|
ARG COMMIT
|
||||||
ARG OS
|
|
||||||
ARG ARCH
|
|
||||||
RUN mkdir -p /go/src/github.com/project-zot/zot
|
RUN mkdir -p /go/src/github.com/project-zot/zot
|
||||||
WORKDIR /go/src/github.com/project-zot/zot
|
WORKDIR /go/src/github.com/project-zot/zot
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean exporter-minimal
|
RUN make COMMIT=$COMMIT OS=$TARGETOS ARCH=$TARGETARCH clean exporter-minimal
|
||||||
RUN echo '{\n\
|
RUN echo '{\n\
|
||||||
"Server": {\n\
|
"Server": {\n\
|
||||||
"protocol": "http",\n\
|
"protocol": "http",\n\
|
||||||
|
@ -27,9 +29,9 @@ RUN echo '{\n\
|
||||||
# Stage 2: Final image with nothing but binary and default config file
|
# Stage 2: Final image with nothing but binary and default config file
|
||||||
# ---
|
# ---
|
||||||
FROM gcr.io/distroless/base AS final
|
FROM gcr.io/distroless/base AS final
|
||||||
ARG OS
|
ARG TARGETOS
|
||||||
ARG ARCH
|
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/bin/zxp-$TARGETOS-$TARGETARCH /zxp
|
||||||
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
|
COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zxp/config.json
|
||||||
ENTRYPOINT ["/zxp"]
|
ENTRYPOINT ["/zxp"]
|
||||||
EXPOSE 5001
|
EXPOSE 5001
|
||||||
|
|
Loading…
Reference in a new issue