From ab957b2f64b8252e18a657e2e5abe0cff087b38a Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Tue, 21 Jan 2025 09:59:32 +0800 Subject: [PATCH] Build images with PG 15 installed (#917) This commit updates the build workflow to build and push an extra base Docker image with PG 15 installed. The tag is not meant to be permanent and is just meant to help us update our postgres templates to support PG 15 within the same commit. The tag will be removed once our `discourse/base:release` ships with PG 15 by default. --- .github/workflows/build.yml | 14 +++++++++++++- image/auto_build.rb | 14 ++++++++++++++ image/base/Dockerfile | 3 ++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5532758..5404f30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -73,6 +73,12 @@ jobs: run: | ruby auto_build.rb base_release_main_${{ matrix.arch }} + # Temporarily build images with PG 15 so that we can ship the changes to the postgres templates in the same PR. + - name: build release images for `main` branch with PG 15 + working-directory: image + run: | + ruby auto_build.rb base_release_main_${{ matrix.arch }}_pg_15 + - name: build release images for `stable` branch working-directory: image run: | @@ -81,6 +87,7 @@ jobs: - name: tag release images run: | docker tag discourse/base:build_release_main_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} + docker tag discourse/base:build_release_main_${{ matrix.arch }}_pg_15 discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}-pg-15 docker tag discourse/base:build_release_stable_${{ matrix.arch }} discourse/base:2.0.${{ env.TIMESTAMP }}-stable-${{ matrix.arch }} - name: build test_build image for `main` branch @@ -129,6 +136,7 @@ jobs: docker login --username discoursebuild --password $DOCKERHUB_PASSWORD docker push discourse/base:2.0.${{ env.TIMESTAMP }}-slim-${{ matrix.arch }} docker push discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} + docker push discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }}-pg-15 docker push discourse/base:2.0.${{ env.TIMESTAMP }}-stable-${{ matrix.arch }} docker push discourse/discourse_dev:${{ env.TIMESTAMP }}-${{ matrix.arch }} @@ -137,7 +145,6 @@ jobs: run: | docker tag discourse/base:2.0.${{ env.TIMESTAMP }}-main-${{ matrix.arch }} discourse/base:aarch64 docker push discourse/base:aarch64 - push_multi_arch_manifests: runs-on: ubuntu-latest needs: [base, timestamp] @@ -164,6 +171,11 @@ jobs: -a discourse/base:2.0.${{ env.TIMESTAMP }}-main-amd64 \ -a discourse/base:2.0.${{ env.TIMESTAMP }}-main-arm64 + # Full Discourse `main` branch timestamped with PG 15 + docker manifest create discourse/base:2.0.${{ env.TIMESTAMP }}-15 \ + -a discourse/base:2.0.${{ env.TIMESTAMP }}-main-amd64-pg-15 \ + -a discourse/base:2.0.${{ env.TIMESTAMP }}-main-arm64-pg-15 + # Full Discourse `stable` branch timestamped docker manifest create discourse/base:2.0.${{ env.TIMESTAMP }}-stable \ -a discourse/base:2.0.${{ env.TIMESTAMP }}-stable-amd64 \ diff --git a/image/auto_build.rb b/image/auto_build.rb index 6ae4227..a684b0c 100644 --- a/image/auto_build.rb +++ b/image/auto_build.rb @@ -43,6 +43,13 @@ images = { extra_args: "--build-arg=\"DISCOURSE_BRANCH=main\" --target discourse_release", use_cache: true, }, + base_release_main_amd64_pg_15: { + name: "base", + tag: "discourse/base:build_release_main_amd64_pg_15", + extra_args: + "--build-arg=\"DISCOURSE_BRANCH=main\" --target discourse_release --build-arg PG_MAJOR=15", + use_cache: true, + }, base_release_main_arm64: { name: "base", tag: "discourse/base:build_release_main_arm64", @@ -50,6 +57,13 @@ images = { "--platform linux/arm64 --build-arg=\"DISCOURSE_BRANCH=main\" --target discourse_release", use_cache: true, }, + base_release_main_arm64_pg_15: { + name: "base", + tag: "discourse/base:build_release_main_arm64_pg_15", + extra_args: + "--build-arg=\"DISCOURSE_BRANCH=main\" --target discourse_release --build-arg PG_MAJOR=15", + use_cache: true, + }, base_release_stable_amd64: { name: "base", tag: "discourse/base:build_release_stable_amd64", diff --git a/image/base/Dockerfile b/image/base/Dockerfile index 213c322..0a2fc27 100644 --- a/image/base/Dockerfile +++ b/image/base/Dockerfile @@ -28,7 +28,8 @@ RUN gpg --import /tmp/nginx_public_keys.key &&\ FROM discourse/ruby:3.3.6-${DEBIAN_RELEASE}-slim AS discourse_dependencies ARG DEBIAN_RELEASE -ENV PG_MAJOR=13 \ +ARG PG_MAJOR=13 +ENV PG_MAJOR=${PG_MAJOR} \ RUBY_ALLOCATOR=/usr/lib/libjemalloc.so \ LEFTHOOK=0 \ DEBIAN_RELEASE=${DEBIAN_RELEASE} -- 2.25.1