From 1722b09c344e070f5c563e70863a367dac070d7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=BCller?= Date: Tue, 26 Nov 2024 16:50:50 +0100 Subject: [PATCH] templates/maintenance.yml: use the existing container for maintenance Adds the `image-builder-maintenance` binary to the existing container `quay.io/cloudservices/image-builder`, to avoid duplicating all the necessary build jobs. --- Makefile | 13 ++++--------- build_deploy.sh | 5 ----- distribution/Dockerfile-ubi | 1 + distribution/Dockerfile-ubi-maintenance | 12 ------------ templates/maintenance.yml | 3 ++- 5 files changed, 7 insertions(+), 27 deletions(-) delete mode 100644 distribution/Dockerfile-ubi-maintenance diff --git a/Makefile b/Makefile index c133a2fc6..8f1a20283 100644 --- a/Makefile +++ b/Makefile @@ -49,21 +49,16 @@ check-api-spec: .PHONY: ubi-container ubi-container: - if [ -f .git ]; then echo "You seem to be in a git worktree - build will fail here"; exit 1; fi - podman build --pull=always -t osbuild/image-builder -f distribution/Dockerfile-ubi . - -.PHONY: ubi-maintenance-container -ubi-maintenance-container: if [ -f .git ]; then echo "You seem to be in a git worktree - build will fail here"; exit 1; fi # backwards compatibility with old podman used in github - podman build --pull=always -t osbuild/image-builder-maintenance -f distribution/Dockerfile-ubi-maintenance . || \ - podman build -t osbuild/image-builder-maintenance -f distribution/Dockerfile-ubi-maintenance . + podman build --pull=always -t osbuild/image-builder -f distribution/Dockerfile-ubi . || \ + podman build -t osbuild/image-builder -f distribution/Dockerfile-ubi . .PHONY: ubi-maintenance-container-test -ubi-maintenance-container-test: ubi-maintenance-container +ubi-maintenance-container-test: ubi-container # just check if the container would start # functional tests are in the target "db-tests" - podman run --rm --tty osbuild/image-builder-maintenance 2>&1 | grep "Dry run, no state will be changed" + podman run --rm --tty --entrypoint /app/image-builder-maintenance osbuild/image-builder 2>&1 | grep "Dry run, no state will be changed" .PHONY: generate-openscap-blueprints generate-openscap-blueprints: diff --git a/build_deploy.sh b/build_deploy.sh index 7804e4c4f..bcbb10398 100755 --- a/build_deploy.sh +++ b/build_deploy.sh @@ -28,8 +28,3 @@ mkdir -p "$DOCKER_CONF" docker --config="$DOCKER_CONF" login -u="$QUAY_USER" -p="$QUAY_TOKEN" quay.io docker --config="$DOCKER_CONF" build -f distribution/Dockerfile-ubi -t "${IMAGE_NAME}:${IMAGE_TAG}" . docker --config="$DOCKER_CONF" push "${IMAGE_NAME}:${IMAGE_TAG}" - -# Maintenance image -IMAGE_NAME="quay.io/app-sre/image-builder-maintenance" -docker --config="$DOCKER_CONF" build -f distribution/Dockerfile-ubi-maintenance -t "${IMAGE_NAME}:${IMAGE_TAG}" . -docker --config="$DOCKER_CONF" push "${IMAGE_NAME}:${IMAGE_TAG}" diff --git a/distribution/Dockerfile-ubi b/distribution/Dockerfile-ubi index 52ebdf713..e3c07446b 100644 --- a/distribution/Dockerfile-ubi +++ b/distribution/Dockerfile-ubi @@ -18,6 +18,7 @@ RUN mkdir /app RUN mkdir -p "/opt/migrate/" COPY --from=builder /opt/app-root/src/go/bin/image-builder /app/ COPY --from=builder /opt/app-root/src/go/bin/image-builder-migrate-db-tern /app/ +COPY --from=builder /opt/app-root/src/go/bin/image-builder-maintenance /app/ COPY ./distributions /app/distributions COPY ./internal/db/migrations-tern /app/migrations COPY ./distribution/openshift-startup.sh /opt/openshift-startup.sh diff --git a/distribution/Dockerfile-ubi-maintenance b/distribution/Dockerfile-ubi-maintenance deleted file mode 100644 index 01afad2cf..000000000 --- a/distribution/Dockerfile-ubi-maintenance +++ /dev/null @@ -1,12 +0,0 @@ -FROM registry.access.redhat.com/ubi9/go-toolset:latest AS builder -# ubi9/go-toolset defaults to uid 1001. Let's copy the files with this UID as well. -# Otherwise, VCS stamping will fail because git >= 2.35.2 refuses to work in -# a repository owned by a different user. -COPY --chown=1001 . . -ENV GOFLAGS=-mod=vendor -RUN go install ./cmd/image-builder-maintenance/ - -FROM registry.access.redhat.com/ubi9/ubi-minimal:latest -RUN mkdir -p "/app" -COPY --from=builder /opt/app-root/src/go/bin/image-builder-maintenance /app/ -ENTRYPOINT ["/app/image-builder-maintenance"] diff --git a/templates/maintenance.yml b/templates/maintenance.yml index b9cba3fbd..4f83affb5 100644 --- a/templates/maintenance.yml +++ b/templates/maintenance.yml @@ -33,6 +33,7 @@ objects: containers: - image: "${IMAGE_NAME}:${IMAGE_TAG}" name: image-builder-maintenance + command: ["/app/image-builder-maintenance"] resources: requests: cpu: "${CPU_REQUEST}" @@ -90,7 +91,7 @@ objects: parameters: - description: maintenance image name name: IMAGE_NAME - value: quay.io/app-sre/image-builder-maintenance + value: quay.io/cloudservices/image-builder required: true - description: composer image tag name: IMAGE_TAG