From 298b966eab84f22e0ba132709f4a846b09d4c9f8 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Mon, 24 Jan 2022 05:19:01 +0000 Subject: [PATCH] build: parameterize arch builds Build zot artifacts for multiple os and arch. [linux, amd64] - common case [linux, arm64] - raspberry pi [darwin, amd64] - Intel-based macs [darwin, arm64] - Arm-based macs Signed-off-by: Ramkumar Chinchani --- .github/workflows/ci-cd.yml | 97 +++++++++++++++---------------------- Dockerfile | 6 ++- Dockerfile-arch | 34 ------------- Dockerfile-arch-minimal | 34 ------------- Dockerfile-arch-zb | 17 ------- Dockerfile-arch-zxp | 33 ------------- Dockerfile-conformance | 2 +- Dockerfile-minimal | 6 ++- Dockerfile-zb | 6 ++- Dockerfile-zxp | 7 ++- Makefile | 60 ++++++++--------------- 11 files changed, 77 insertions(+), 225 deletions(-) delete mode 100644 Dockerfile-arch delete mode 100644 Dockerfile-arch-minimal delete mode 100644 Dockerfile-arch-zb delete mode 100644 Dockerfile-arch-zxp diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index c78c4252..9758c79c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -13,6 +13,10 @@ jobs: build-test: name: Build and test ZOT runs-on: ubuntu-latest + strategy: + matrix: + os: [linux, darwin] + arch: [amd64, arm64] services: s3mock: image: ghcr.io/project-zot/localstack/localstack:0.13.2 @@ -46,15 +50,23 @@ jobs: - name: Run build and test timeout-minutes: 60 run: | - cd $GITHUB_WORKSPACE && make && make ARCH=arm64 binary-arch-minimal && make ARCH=arm64 binary-arch + echo "Building for $OS:$ARCH" + cd $GITHUB_WORKSPACE + if [ "${OS}" == "linux" && "${ARCH}" == "amd64" ]; then + make OS=$OS ARCH=$ARCH + else + make OS=$OS ARCH=$ARCH binary binary-minimal binary-debug cli bench exporter-minimal + fi env: S3MOCK_ENDPOINT: localhost:4566 AWS_ACCESS_KEY_ID: fake AWS_SECRET_ACCESS_KEY: fake + OS: ${{ matrix.os }} + ARCH: ${{ matrix.arch }} - name: Upload code coverage - uses: codecov/codecov-action@v1 - + uses: codecov/codecov-action@v1 + - if: github.event_name == 'release' && github.event.action == 'published' name: Publish artifacts on releases uses: svenstaro/upload-release-action@v2 @@ -69,6 +81,10 @@ jobs: if: github.event_name == 'release' && github.event.action== 'published' name: Push Docker image to GitHub Packages runs-on: ubuntu-latest + strategy: + matrix: + os: [linux, darwin] + arch: [amd64, arm64] steps: - name: Check out the repo uses: actions/checkout@v2 @@ -78,86 +94,51 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build container image + - name: Build zot container image uses: docker/build-push-action@v2 with: build-args: | COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} + OS=${{ matrix.os }} + ARCH=${{ matrix.arch }} push: true + file: Dockerfile tags: | - ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}:latest - - name: Build minimal container image + ghcr.io/${{ github.repository }}-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }} + ghcr.io/${{ github.repository }}-${{ matrix.os }}-${{ matrix.arch }}:latest + - name: Build zot-minimal container image uses: docker/build-push-action@v2 with: build-args: | COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} + OS=${{ matrix.os }} + ARCH=${{ matrix.arch }} push: true file: Dockerfile-minimal tags: | - ghcr.io/${{ github.repository }}-minimal:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-minimal:latest + ghcr.io/${{ github.repository }}-minimal-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }} + ghcr.io/${{ github.repository }}-minimal-${{ matrix.os }}-${{ matrix.arch }}:latest - name: Build zot-exporter container image uses: docker/build-push-action@v2 with: build-args: | COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} + OS=${{ matrix.os }} + ARCH=${{ matrix.arch }} push: true file: Dockerfile-zxp tags: | - ghcr.io/${{ github.repository }}-zxp:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-zxp:latest - - name: Build zot-exporter container image (arm64) - uses: docker/build-push-action@v2 - with: - build-args: | - COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} - ARCH=arm64 - push: true - file: Dockerfile-arch-zxp - tags: | - ghcr.io/${{ github.repository }}-arm64-zxp:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-arm64-zxp:latest - - name: Build container image (arm64) - uses: docker/build-push-action@v2 - with: - build-args: | - COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} - ARCH=arm64 - push: true - file: Dockerfile-arch - tags: | - ghcr.io/${{ github.repository }}-arm64:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-arm64:latest - - name: Build minimal container image (arm64) - uses: docker/build-push-action@v2 - with: - build-args: | - COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} - ARCH=arm64 - push: true - file: Dockerfile-arch-minimal - tags: | - ghcr.io/${{ github.repository }}-arm64-minimal:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-arm64-minimal:latest - - name: Build container image + ghcr.io/${{ github.repository }}-zxp-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }} + ghcr.io/${{ github.repository }}-zxp-${{ matrix.os }}-${{ matrix.arch }}:latest + - name: Build zb container image uses: docker/build-push-action@v2 with: build-args: | COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} + OS=${{ matrix.os }} + ARCH=${{ matrix.arch }} push: true file: Dockerfile-zb tags: | - ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}:latest - - name: Build container image (arm64) - uses: docker/build-push-action@v2 - with: - build-args: | - COMMIT=${{ github.event.release.tag_name }}-${{ github.sha }} - ARCH=arm64 - push: true - file: Dockerfile-arch-zb - tags: | - ghcr.io/${{ github.repository }}-arm64:${{ github.event.release.tag_name }} - ghcr.io/${{ github.repository }}-arm64:latest + ghcr.io/${{ github.repository }}-zb-${{ matrix.os }}-${{ matrix.arch }}:${{ github.event.release.tag_name }} + ghcr.io/${{ github.repository }}-zb-${{ matrix.os }}-${{ matrix.arch }}:latest diff --git a/Dockerfile b/Dockerfile index 9481098f..06f9ce7c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,12 @@ # --- FROM ghcr.io/project-zot/golang:1.17 AS builder 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 . . -RUN make COMMIT=$COMMIT clean binary +RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean binary RUN echo '{\n\ "storage": {\n\ "rootDirectory": "/var/lib/registry"\n\ @@ -25,7 +27,7 @@ RUN echo '{\n\ # --- FROM scratch AS final 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 /usr/bin/zot +COPY --from=builder /go/src/github.com/project-zot/zot/bin/zot-$OS-$ARCH /usr/bin/zot COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json ENTRYPOINT ["/usr/bin/zot"] EXPOSE 5000 diff --git a/Dockerfile-arch b/Dockerfile-arch deleted file mode 100644 index f1080621..00000000 --- a/Dockerfile-arch +++ /dev/null @@ -1,34 +0,0 @@ -# --- -# Stage 1: Install certs, build binary, create default config file -# --- -FROM ghcr.io/project-zot/golang:1.17 AS builder -ARG COMMIT -ARG ARCH -RUN mkdir -p /go/src/github.com/project-zot/zot -WORKDIR /go/src/github.com/project-zot/zot -COPY . . -RUN make COMMIT=$COMMIT ARCH=$ARCH clean binary -RUN echo '{\n\ - "storage": {\n\ - "rootDirectory": "/var/lib/registry"\n\ - },\n\ - "http": {\n\ - "address": "0.0.0.0",\n\ - "port": "5000"\n\ - },\n\ - "log": {\n\ - "level": "debug"\n\ - }\n\ -}\n' > config.json && cat config.json - -# --- -# Stage 2: Final image with nothing but certs, binary, and default config file -# --- -FROM scratch AS final -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 /usr/bin/zot -COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json -ENTRYPOINT ["/usr/bin/zot"] -EXPOSE 5000 -VOLUME ["/var/lib/registry"] -CMD ["serve", "/etc/zot/config.json"] diff --git a/Dockerfile-arch-minimal b/Dockerfile-arch-minimal deleted file mode 100644 index aac492d5..00000000 --- a/Dockerfile-arch-minimal +++ /dev/null @@ -1,34 +0,0 @@ -# --- -# Stage 1: Install certs, build binary, create default config file -# --- -FROM ghcr.io/project-zot/golang:1.17 AS builder -ARG COMMIT -ARG ARCH -RUN mkdir -p /go/src/github.com/project-zot/zot -WORKDIR /go/src/github.com/project-zot/zot -COPY . . -RUN make COMMIT=$COMMIT ARCH=$ARCH clean binary-minimal -RUN echo '{\n\ - "storage": {\n\ - "rootDirectory": "/var/lib/registry"\n\ - },\n\ - "http": {\n\ - "address": "0.0.0.0",\n\ - "port": "5000"\n\ - },\n\ - "log": {\n\ - "level": "debug"\n\ - }\n\ -}\n' > config.json && cat config.json - -# --- -# Stage 2: Final image with nothing but certs, binary, and default config file -# --- -FROM scratch AS final -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-minimal /usr/bin/zot -COPY --from=builder /go/src/github.com/project-zot/zot/config.json /etc/zot/config.json -ENTRYPOINT ["/usr/bin/zot"] -EXPOSE 5000 -VOLUME ["/var/lib/registry"] -CMD ["serve", "/etc/zot/config.json"] diff --git a/Dockerfile-arch-zb b/Dockerfile-arch-zb deleted file mode 100644 index 17189961..00000000 --- a/Dockerfile-arch-zb +++ /dev/null @@ -1,17 +0,0 @@ -# --- -# Stage 1: Install certs, build binary, create default config file -# --- -FROM ghcr.io/project-zot/golang:1.17 AS builder -ARG COMMIT -ARG ARCH -RUN mkdir -p /go/src/github.com/project-zot/zot -WORKDIR /go/src/github.com/project-zot/zot -COPY . . -RUN make COMMIT=$COMMIT ARCH=$ARCH clean bench - -# --- -# Stage 2: Final image with nothing but certs, binary, and default config file -# --- -FROM scratch AS final -COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb /usr/bin/zb -ENTRYPOINT ["/usr/bin/zb"] diff --git a/Dockerfile-arch-zxp b/Dockerfile-arch-zxp deleted file mode 100644 index 6f5f76bc..00000000 --- a/Dockerfile-arch-zxp +++ /dev/null @@ -1,33 +0,0 @@ -# --- -# Stage 1: Build binary, create default config file -# --- -FROM ghcr.io/project-zot/golang:1.17 AS builder -ARG COMMIT -ARG ARCH -RUN mkdir -p /go/src/github.com/project-zot/zot -WORKDIR /go/src/github.com/project-zot/zot -COPY . . -RUN make COMMIT=$COMMIT ARCH=$ARCH clean exporter-minimal -RUN echo '{\n\ - "Server": {\n\ - "protocol": "http",\n\ - "host": "127.0.0.1",\n\ - "port": "5000"\n\ - },\n\ - "Exporter": {\n\ - "port": "5001",\n\ - "log": {\n\ - "level": "debug"\n\ - }\n\ - }\n\ -}\n' > config.json && cat config.json - -# --- -# Stage 2: Final image with nothing but binary and default config file -# --- -FROM scratch AS final -COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp /zxp -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"] diff --git a/Dockerfile-conformance b/Dockerfile-conformance index 86665af3..9c8e42cb 100644 --- a/Dockerfile-conformance +++ b/Dockerfile-conformance @@ -22,7 +22,7 @@ storage:\n\ # --- FROM scratch AS final 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 /usr/bin/zot +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 ENTRYPOINT ["/usr/bin/zot"] EXPOSE 5000 diff --git a/Dockerfile-minimal b/Dockerfile-minimal index 6df4b4d4..566b190a 100644 --- a/Dockerfile-minimal +++ b/Dockerfile-minimal @@ -3,10 +3,12 @@ # --- FROM ghcr.io/project-zot/golang:1.17 AS builder 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 . . -RUN make COMMIT=$COMMIT clean binary-minimal +RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean binary-minimal RUN echo '{\n\ "storage": {\n\ "rootDirectory": "/var/lib/registry"\n\ @@ -25,7 +27,7 @@ RUN echo '{\n\ # --- FROM scratch AS final 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-minimal /usr/bin/zot +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 ENTRYPOINT ["/usr/bin/zot"] EXPOSE 5000 diff --git a/Dockerfile-zb b/Dockerfile-zb index 24178cfc..b055db14 100644 --- a/Dockerfile-zb +++ b/Dockerfile-zb @@ -3,14 +3,16 @@ # --- FROM ghcr.io/project-zot/golang:1.17 AS builder 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 . . -RUN make COMMIT=$COMMIT clean bench +RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean bench # --- # Stage 2: Final image with nothing but certs, binary, and default config file # --- FROM scratch AS final -COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb /usr/bin/zb +COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$OS-$ARCH /usr/bin/zb ENTRYPOINT ["/usr/bin/zb"] diff --git a/Dockerfile-zxp b/Dockerfile-zxp index c4b88d84..ff84499b 100644 --- a/Dockerfile-zxp +++ b/Dockerfile-zxp @@ -2,10 +2,13 @@ # Stage 1: Build binary, create default config file # --- FROM ghcr.io/project-zot/golang:1.17 AS builder +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 . . -RUN make clean exporter-minimal +RUN make COMMIT=$COMMIT OS=$OS ARCH=$ARCH clean exporter-minimal RUN echo '{\n\ "Server": {\n\ "protocol": "http",\n\ @@ -24,7 +27,7 @@ RUN echo '{\n\ # Stage 2: Final image with nothing but binary and default config file # --- FROM scratch AS final -COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp /zxp +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"] EXPOSE 5001 diff --git a/Makefile b/Makefile index 4dc61c99..e24ab298 100644 --- a/Makefile +++ b/Makefile @@ -15,51 +15,31 @@ ARCH ?= amd64 BENCH_OUTPUT ?= stdout .PHONY: all -all: swagger binary binary-minimal binary-debug binary-arch binary-arch-minimal cli cli-arch bench bench-arch exporter-minimal verify-config test covhtml test-clean check - -.PHONY: binary-minimal -binary-minimal: swagger - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot - -.PHONY: binary -binary: swagger - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot +all: swagger binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml test-clean check .PHONY: binary-debug binary-debug: swagger - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-debug -tags extended,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug -tags extended,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot -.PHONY: binary-arch-minimal -binary-arch-minimal: swagger - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(ARCH)-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot +.PHONY: binary-minimal +binary-minimal: swagger + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-minimal -tags minimal,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=minimal -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot -.PHONY: binary-arch -binary-arch: swagger - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot +.PHONY: binary +binary: swagger + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zot .PHONY: cli -cli: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zli -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zli - -.PHONY: cli-arch -cli-arch: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zli-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zli +cli: + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zli-$(OS)-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zli .PHONY: bench -bench: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb - -.PHONY: bench-arch -bench-arch: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb +bench: + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(OS)-$(ARCH) -tags extended,containers_image_openpgp -v -trimpath -ldflags "-X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=extended -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION} -s -w" ./cmd/zb .PHONY: exporter-minimal exporter-minimal: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp - -.PHONY: exporter-arch-minimal -exporter-arch-minimal: - env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp-$(ARCH) -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp + env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp-$(OS)-$(ARCH) -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp .PHONY: test test: check-skopeo $(NOTATION) @@ -74,14 +54,14 @@ test: check-skopeo $(NOTATION) .PHONY: run-bench run-bench: binary bench - bin/zot serve examples/config-minimal.json & + bin/zot-$(OS)-$(ARCH) serve examples/config-minimal.json & sleep 5 - bin/zb -c 10 -n 100 -o $(BENCH_OUTPUT) http://localhost:8080 - killall zot + bin/zb-$(OS)-$(ARCH) -c 10 -n 100 -o $(BENCH_OUTPUT) http://localhost:8080 + killall -r zot-* .PHONY: push-pull push-pull: binary check-skopeo - bin/zot serve examples/config-minimal.json & + bin/zot-$(OS)-$(ARCH) serve examples/config-minimal.json & sleep 5 # skopeo push/pull skopeo --debug copy --format=oci --dest-tls-verify=false docker://ghcr.io/project-zot/golang:1.17 docker://localhost:8080/golang:1.17 @@ -96,10 +76,10 @@ push-pull: binary check-skopeo oras pull localhost:8080/hello-artifact:v2 -d -v -a grep -q "hello world" artifact.txt # should print "hello world" if [ $? -ne 0 ]; then \ - killall zot; \ + killall -r zot-*; \ exit 1; \ fi - killall zot + killall -r zot-* .PHONY: test-clean test-clean: @@ -180,7 +160,7 @@ clean: .PHONY: run run: binary test - ./bin/zot serve examples/config-test.json + ./bin/zot-$(OS)-$(ARCH) serve examples/config-test.json .PHONY: verify-config verify-config: binary