-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build and push Docker image based on Chainguard base image #13137
Changes from 10 commits
7d0feee
a89834b
369c5be
a1ea9f8
b7527f1
de52938
c30bbfd
569a5b9
de225d7
1bb262f
8509876
e403623
f1fe3f9
0db7be1
88fcc8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,19 +31,38 @@ DOCKER_IMAGES := \ | |
build/docker/apm-server-ubi-$(APM_SERVER_VERSION).txt \ | ||
build/docker/apm-server-ubi-$(APM_SERVER_VERSION)-SNAPSHOT.txt | ||
|
||
# If GENERATE_WOLFI_IMAGES is set then generate wolfi docker images. | ||
ifdef GENERATE_WOLFI_IMAGES | ||
DOCKER_IMAGES := $(DOCKER_IMAGES) \ | ||
build/docker/apm-server-wolfi-$(APM_SERVER_VERSION).txt \ | ||
build/docker/apm-server-wolfi-$(APM_SERVER_VERSION)-SNAPSHOT.txt | ||
endif | ||
|
||
build/docker/%.txt: DOCKER_IMAGE_TAG := docker.elastic.co/apm/apm-server:% | ||
build/docker/%.txt: VERSION := $(APM_SERVER_VERSION) | ||
build/docker/%-SNAPSHOT.txt: VERSION := $(APM_SERVER_VERSION)-SNAPSHOT | ||
build/docker/apm-server-ubi-%.txt: DOCKER_BUILD_ARGS+=--build-arg BASE_IMAGE=docker.elastic.co/ubi9/ubi-minimal | ||
build/docker/apm-server-wolfi-%.txt: DOCKER_BUILD_ARGS+=--build-arg BASE_IMAGE=docker.elastic.co/wolfi/chainguard-base:20230214 --build-arg BASE_GOLANG_IMAGE=docker.elastic.co/wolfi/go | ||
v1v marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
INTERNAL_DOCKER_IMAGE := docker.elastic.co/observability-ci/apm-server-internal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should help create docker images and publish them to our internal docker registry - this is handy for validating changes before anything related to the DRA and in GitHub actions. We are safe since these docker images won't be public available for the time being: $ docker pull docker.elastic.co/observability-ci/apm-server-internal:8.15.0-SNAPSHOT-wolfi
Error response from daemon: pull access denied for docker.elastic.co/observability-ci/apm-server-internal, repository does not exist or may require 'docker login': denied: requested access to the resource is denied |
||
|
||
.PHONY: $(DOCKER_IMAGES) | ||
$(DOCKER_IMAGES): | ||
@mkdir -p $(@D) | ||
docker build --iidfile="$(@)" --build-arg GOLANG_VERSION=$(GOLANG_VERSION) --build-arg VERSION=$(VERSION) $(DOCKER_BUILD_ARGS) -f packaging/docker/Dockerfile . | ||
|
||
# Docker image tarballs. We distribute UBI8 Docker images only for AMD64. | ||
docker build --iidfile="$(@)" \ | ||
--build-arg GOLANG_VERSION=$(GOLANG_VERSION) \ | ||
--build-arg VERSION=$(VERSION) \ | ||
$(DOCKER_BUILD_ARGS) \ | ||
--tag $(INTERNAL_DOCKER_IMAGE):$(VERSION)$(if $(findstring arm64,$(GOARCH)),-arm64)$(if $(findstring wolfi,$(@)),-wolfi) \ | ||
-f packaging/docker/Dockerfile . | ||
|
||
# Docker image tarballs. We distribute UBI Docker images only for AMD64. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docs: no |
||
DOCKER_IMAGE_SUFFIX := docker-image$(if $(findstring arm64,$(GOARCH)),-arm64).tar.gz | ||
DOCKER_IMAGE_PREFIXES := apm-server $(if $(findstring amd64,$(GOARCH)), apm-server-ubi) | ||
# If GENERATE_WOLFI_IMAGES is set then generate wolfi docker images. | ||
ifdef GENERATE_WOLFI_IMAGES | ||
DOCKER_IMAGE_PREFIXES := $(DOCKER_IMAGE_PREFIXES) apm-server-wolfi | ||
endif | ||
DOCKER_IMAGE_RELEASE_TARBALLS := $(patsubst %, $(DISTDIR)/%-$(APM_SERVER_VERSION)-$(DOCKER_IMAGE_SUFFIX), $(DOCKER_IMAGE_PREFIXES)) | ||
DOCKER_IMAGE_SNAPSHOT_TARBALLS := $(patsubst %, $(DISTDIR)/%-$(APM_SERVER_VERSION)-SNAPSHOT-$(DOCKER_IMAGE_SUFFIX), $(DOCKER_IMAGE_PREFIXES)) | ||
|
||
|
@@ -186,7 +205,10 @@ build/dependencies-$(APM_SERVER_VERSION)-SNAPSHOT.csv: build/dependencies-$(APM_ | |
cp $< $@ | ||
|
||
package-docker: $(DOCKER_IMAGE_RELEASE_TARBALLS) | ||
@echo ">> $(DOCKER_IMAGE_RELEASE_TARBALLS)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to help with printing what it did |
||
|
||
package-docker-snapshot: $(DOCKER_IMAGE_SNAPSHOT_TARBALLS) | ||
@echo ">> $(DOCKER_IMAGE_SNAPSHOT_TARBALLS)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just to help with printing what it did |
||
|
||
package: \ | ||
package-docker \ | ||
|
@@ -200,3 +222,6 @@ package-snapshot: \ | |
$(DOCKER_IMAGE_SNAPSHOT_TARBALLS) \ | ||
$(DISTDIR)/apm-server-ironbank-$(APM_SERVER_VERSION)-SNAPSHOT-docker-build-context.tar.gz \ | ||
build/dependencies-$(APM_SERVER_VERSION)-SNAPSHOT.csv | ||
|
||
publish-docker-images: | ||
docker push --all-tags $(INTERNAL_DOCKER_IMAGE) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,32 @@ | ||
ARG BASE_IMAGE=ubuntu:22.04 | ||
ARG BASE_GOLANG_IMAGE=golang | ||
ARG GOLANG_VERSION | ||
|
||
################################################################################ | ||
# Build stage 0 | ||
# Build the apm-server binary. The golang image version is kept | ||
# up to date with go.mod by Makefile. | ||
FROM golang:${GOLANG_VERSION} as builder | ||
################################################################################ | ||
FROM ${BASE_GOLANG_IMAGE}:${GOLANG_VERSION} as builder | ||
WORKDIR /src | ||
COPY go.mod go.sum /src/ | ||
COPY go.mod go.sum .go-version /src/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes a warning when building the docker image |
||
COPY internal/glog/go.mod /src/internal/glog/go.mod | ||
RUN --mount=type=cache,target=/go/pkg/mod go mod download | ||
COPY Makefile *.mk /src | ||
COPY cmd /src/cmd | ||
COPY internal /src/internal | ||
COPY x-pack /src/x-pack | ||
COPY .git /src/.git | ||
COPY script /src/script | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes a warning when building the docker image |
||
|
||
ENV GOROOT /usr/local/go | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrequired for building the wolfi version and in fact it's not needed for the traditional docker image |
||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
make apm-server | ||
|
||
################################################################################ | ||
# Build stage 1 | ||
# Copy prepared files from the previous stage and complete the image. | ||
################################################################################ | ||
FROM ${BASE_IMAGE} | ||
ARG TARGETARCH | ||
ARG BUILD_DATE | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove some warnings in the github logs, regarding missing variable when running gh in the GitHub runner