From a3ca353f730462aa021b0382ec8ebf09a234727d Mon Sep 17 00:00:00 2001 From: "Jonathan Gonzalez V." Date: Thu, 21 Aug 2025 09:55:50 +0200 Subject: [PATCH] chore: add Barman base image (#59) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We build a new image every week with the necessary base packages for the sidecar. This aims to reduce the time required for each CI process to run. Signed-off-by: Jonathan Gonzalez V. Signed-off-by: Niccolò Fei Co-authored-by: Niccolò Fei --- .github/workflows/barman-base-image.yml | 38 +++++++++++++++++++++++++ Taskfile.yml | 27 ++++++++++++++++++ containers/Dockerfile.barmanbase | 7 +++++ 3 files changed, 72 insertions(+) create mode 100644 .github/workflows/barman-base-image.yml create mode 100644 containers/Dockerfile.barmanbase diff --git a/.github/workflows/barman-base-image.yml b/.github/workflows/barman-base-image.yml new file mode 100644 index 0000000..ad16bc6 --- /dev/null +++ b/.github/workflows/barman-base-image.yml @@ -0,0 +1,38 @@ +name: Barman Base Image +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * 0" + push: + branches: + - main + paths: + - 'containers/sidecar-requirements.txt' + +permissions: read-all + +jobs: + build: + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install QEMU static binaries + uses: docker/setup-qemu-action@v3 + - name: Install Task + uses: arduino/setup-task@v2 + - name: Install Dagger + env: + # renovate: datasource=github-tags depName=dagger/dagger versioning=semver + DAGGER_VERSION: 0.18.5 + run: | + curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh + - name: Publish a barman-base + env: + REGISTRY_USER: ${{ github.actor }} + REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + run: | + task publish-barman-base diff --git a/Taskfile.yml b/Taskfile.yml index 12ff611..a775bc6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -377,6 +377,33 @@ tasks: build --dir . --file containers/Dockerfile.sidecar --platform linux/amd64 --platform linux/arm64 publish --ref {{.SIDECAR_IMAGE_NAME}} --tags {{.IMAGE_VERSION}} + publish-barman-base: + desc: Build and publish a barman-cloud base container image + vars: + BARMAN_BASE_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}-base{{if not (hasPrefix "refs/heads/main" .GITHUB_REF)}}-testing{{end}} + BARMAN_VERSION: + sh: grep "^barman" containers/sidecar-requirements.in | sed -E 's/.*==([^ ]+)/\1/' + BUILD_DATE: + sh: date +"%Y%m%d%H%M" + requires: + # We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here + # to prevent running this task locally by accident. + vars: + - CI + - GITHUB_REPOSITORY + - GITHUB_REF + - GITHUB_REF_NAME + - REGISTRY_USER + - REGISTRY_PASSWORD + env: + # renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main + DAGGER_DOCKER_SHA: bba3a4ee46fd663a5577337e2221db56c646a0b7 + cmds: + - > + dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA} + --registry ghcr.io --username $REGISTRY_USER --password env:REGISTRY_PASSWORD + build --dir . --file containers/Dockerfile.barmanbase --platform linux/amd64 --platform linux/arm64 + publish --ref {{.BARMAN_BASE_IMAGE_NAME}} --tags "{{.BARMAN_VERSION}}-{{.BUILD_DATE}}" controller-gen: desc: Run controller-gen diff --git a/containers/Dockerfile.barmanbase b/containers/Dockerfile.barmanbase new file mode 100644 index 0000000..cc01748 --- /dev/null +++ b/containers/Dockerfile.barmanbase @@ -0,0 +1,7 @@ +FROM python:3.13-slim-bookworm +COPY containers/sidecar-requirements.txt . +RUN apt-get update && \ + apt-get install -y postgresql-common build-essential && \ + /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && \ + apt-get install -y libpq-dev && \ + pip install -r sidecar-requirements.txt