diff --git a/Containerfile b/Containerfile index d8e8e80..f96cf3e 100644 --- a/Containerfile +++ b/Containerfile @@ -1,6 +1,8 @@ # Base image for build ARG base_image_version=1.20.7 -FROM golang:${base_image_version} as builder +FROM --platform=$BUILDPLATFORM golang:${base_image_version} as builder +ARG TARGETARCH +ARG TARGETOS # Switch workdir WORKDIR /opt/apm-perf @@ -9,12 +11,15 @@ WORKDIR /opt/apm-perf COPY . . # Build +ENV GOOS=$TARGETOS +ENV GOARCH=$TARGETARCH +ENV CGO_ENABLED=0 RUN \ go mod download \ && make build -# Base image for build -FROM debian:bookworm +# Base image for final image +FROM cgr.dev/chainguard/static # Arguments ARG commit_sha @@ -37,18 +42,6 @@ LABEL \ # Switch workdir WORKDIR /opt/apm-perf -# Add minimal stuff -RUN \ - apt-get update > /dev/null \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends \ - "apt-utils=*" \ - "ca-certificates=*" \ - "curl=*" \ - "gnupg=*" \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - # Copy files for apmsoak COPY --from=builder /opt/apm-perf/dist/apmsoak /usr/bin/apmsoak COPY ./internal/loadgen/events ./events diff --git a/Makefile b/Makefile index 8690c6f..35897a8 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ package: PROJECT_URL=$$(go list -m all | head -1) package: mkdir -p $(STATES_DIR) echo "$(IMAGE_REF)" > "$(STATES_DIR)/image_ref" - docker buildx build \ + docker build \ --build-arg base_image_version=$(BASE_IMAGE_VERSION) \ --build-arg commit_sha=$(COMMIT_SHA) \ --build-arg current_time=$(CURRENT_TIME_ISO) \