mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
build: add -buildmode=pie to builds
This makes zot a dynamic binary, so the container base image has to be changed accordingly Signed-off-by: Ramkumar Chinchani <rchincha@cisco.com>
This commit is contained in:
parent
b2a4388522
commit
554e99a967
6 changed files with 11 additions and 11 deletions
|
@ -25,7 +25,7 @@ RUN echo '{\n\
|
|||
# ---
|
||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||
# ---
|
||||
FROM scratch AS final
|
||||
FROM gcr.io/distroless/base AS final
|
||||
ARG OS
|
||||
ARG ARCH
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
|
|
@ -20,7 +20,7 @@ storage:\n\
|
|||
# ---
|
||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||
# ---
|
||||
FROM scratch AS final
|
||||
FROM gcr.io/distroless/base 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-linux-amd64 /usr/bin/zot
|
||||
COPY --from=builder /go/src/github.com/project-zot/zot/config.yml /etc/zot/config.yml
|
||||
|
|
|
@ -25,7 +25,7 @@ RUN echo '{\n\
|
|||
# ---
|
||||
# Stage 2: Final image with nothing but certs, binary, and default config file
|
||||
# ---
|
||||
FROM scratch AS final
|
||||
FROM gcr.io/distroless/base AS final
|
||||
ARG OS
|
||||
ARG ARCH
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
|
|
|
@ -13,7 +13,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 scratch AS final
|
||||
FROM gcr.io/distroless/base AS final
|
||||
ARG OS
|
||||
ARG ARCH
|
||||
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zb-$OS-$ARCH /usr/bin/zb
|
||||
|
|
|
@ -26,7 +26,7 @@ RUN echo '{\n\
|
|||
# ---
|
||||
# Stage 2: Final image with nothing but binary and default config file
|
||||
# ---
|
||||
FROM scratch AS final
|
||||
FROM gcr.io/distroless/base AS final
|
||||
ARG OS
|
||||
ARG ARCH
|
||||
COPY --from=builder /go/src/github.com/project-zot/zot/bin/zxp-$OS-$ARCH /zxp
|
||||
|
|
12
Makefile
12
Makefile
|
@ -24,27 +24,27 @@ modcheck:
|
|||
|
||||
.PHONY: binary-debug
|
||||
binary-debug: modcheck swagger
|
||||
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
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug -buildmode=pie -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-minimal
|
||||
binary-minimal: modcheck 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
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-minimal -buildmode=pie -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: modcheck 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
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH) -buildmode=pie -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: modcheck
|
||||
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
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zli-$(OS)-$(ARCH) -buildmode=pie -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: modcheck
|
||||
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
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zb-$(OS)-$(ARCH) -buildmode=pie -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: modcheck
|
||||
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zxp-$(OS)-$(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) -buildmode=pie -tags minimal,containers_image_openpgp -v -trimpath ./cmd/zxp
|
||||
|
||||
.PHONY: test
|
||||
test: check-skopeo $(NOTATION)
|
||||
|
|
Loading…
Reference in a new issue