Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 292 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
# Trial multi-arch workflow based on https://github.com/postgis/docker-postgis/pull/432
# and the ImreSamu/docker-postgis-test prototype.

name: TEST - Docker PostGIS CI
# Serialize publish-capable runs per ref so scheduled/push/manual runs queue instead of racing.
concurrency:
group: test-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '15 13 * * *'

# ============================================================================
# FOR FORKING: Modify these settings in your forked repository
# ============================================================================
env:
DOCKERHUB_REPO: postgis/docker-postgis-test
GITHUB_REPO: postgis/docker-postgis
LATEST_VERSION: 17-3.5
DOCKERHUB_SHORT_DESCRIPTION: "TEST REPO - PostGIS Docker"
DOCKERHUB_README_PREFIX: "# WARNING: This is a TEST repository ONLY\n\n"
RUNNER_PLATFORMS_JSON: '["ubuntu-24.04","ubuntu-24.04-arm"]' # Runner platforms used to expand the build matrix
EXPECTED_IMAGE_PLATFORMS_JSON: '["linux/amd64","linux/arm64"]'
#
# Also add these secrets in your repository settings:
# https://github.com/${GITHUB_REPO}/settings/secrets/actions
# - secrets.DOCKERHUB_USERNAME
# - secrets.DOCKERHUB_ACCESS_TOKEN (read/write/delete access for the test repository)
# ============================================================================

defaults:
run:
shell: bash --noprofile --norc -euo pipefail {0}

jobs:

setup:
# This job sets up configuration constants and loads the CI matrix from matrix.yml.
# - Constants: CANONICAL_REPO and SHOULD_PUBLISH flag (fork-friendly configuration)
# - Matrix: BUILD_TARGETS and BUILD_INCLUDE arrays (automatically generated by ./update.sh)
name: Setup and Load Configuration
runs-on: ubuntu-latest
outputs:
CANONICAL_REPO: ${{ steps.constants.outputs.CANONICAL_REPO }}
SHOULD_PUBLISH: ${{ steps.constants.outputs.SHOULD_PUBLISH }}
BUILD_INCLUDE: ${{ steps.matrix.outputs.BUILD_INCLUDE }}
BUILD_TARGETS: ${{ steps.matrix.outputs.BUILD_TARGETS }}
steps:
- name: Set constants
id: constants
env:
VAR_CANONICAL: ${{ vars.CANONICAL_REPO }}
run: |
CANONICAL_REPO="${VAR_CANONICAL:-$GITHUB_REPO}"
echo "CANONICAL_REPO=$CANONICAL_REPO" >> "$GITHUB_OUTPUT"

# Compute if we should publish
if [[ "${{ github.repository }}" == "$CANONICAL_REPO" ]] && \
[[ "${{ github.ref }}" == "refs/heads/master" ]] && \
[[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "SHOULD_PUBLISH=true" >> "$GITHUB_OUTPUT"
else
echo "SHOULD_PUBLISH=false" >> "$GITHUB_OUTPUT"
fi

- name: Checkout repository
uses: actions/checkout@v6

- name: Load and validate matrix
id: matrix
run: bash ci/matrix.sh

make-docker-images:
needs: setup
strategy:
matrix:
include: ${{ fromJSON(needs.setup.outputs.BUILD_INCLUDE) }}

name: "Build:${{ matrix.postgres }}-${{ matrix.postgis }}-${{ matrix.variant }} (${{ contains(matrix.runner-platform, 'arm') && 'arm64' || 'x86-64' }}) Docker image"
runs-on: ${{ matrix.runner-platform }}
continue-on-error: ${{ matrix.postgis == 'master' }}
env:
VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }}
VARIANT: ${{ matrix.variant }}
# the "postgis/postgis" name is the expected test name; ( via ./test/postgis-config.sh )
# changing it will break the official-images test script
# this is only for CI test and not for Docker hub publishing
CI_IMAGE_TAG: postgis/postgis:ci-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.postgres }}-${{ matrix.postgis }}-${{ matrix.variant }}-${{ contains(matrix.runner-platform, 'arm') && 'arm' || 'x64' }}

steps:
- name: Checkout source
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Compute build directory
run: |
if [[ "$VARIANT" == "alpine" ]]; then
echo "BUILD_DIR=$VERSION/alpine" >> "$GITHUB_ENV"
else
echo "BUILD_DIR=$VERSION" >> "$GITHUB_ENV"
fi

- name: Build Docker image for ${{ env.VERSION }} ${{ env.VARIANT }}
id: build
uses: docker/build-push-action@v6
with:
context: ${{ env.BUILD_DIR }}
file: ${{ env.BUILD_DIR }}/Dockerfile
tags: ${{ env.CI_IMAGE_TAG }}
load: true
push: false # don't push until after testing

- name: Check out official-images repo
uses: actions/checkout@v6
with:
repository: docker-library/official-images
path: official-images
sparse-checkout: |
test

- name: Test image with official-images
run: bash ci/test-image.sh "$CI_IMAGE_TAG"

- name: Login to dockerhub
id: login-dockerhub
uses: docker/login-action@v3
if: ${{ needs.setup.outputs.SHOULD_PUBLISH == 'true' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Push image by digest
id: push
uses: docker/build-push-action@v6
if: ${{ needs.setup.outputs.SHOULD_PUBLISH == 'true' && steps.login-dockerhub.outcome == 'success' }}
with:
context: ${{ env.BUILD_DIR }}
file: ${{ env.BUILD_DIR }}/Dockerfile
outputs: type=image,"name=${{ env.DOCKERHUB_REPO }}",push-by-digest=true,name-canonical=true,push=true

- name: Export digest
if: ${{ steps.push.outcome == 'success' }}
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.push.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"

- name: Upload digests
if: ${{ steps.push.outcome == 'success' }}
uses: actions/upload-artifact@v5
with:
name: digests-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.VERSION }}-${{ env.VARIANT }}-${{ matrix.runner-platform }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 10

merge-manifests:
name: "Merge:${{ matrix.postgres }}-${{ matrix.postgis }}-${{ matrix.variant }} manifests and push to DockerHub"
needs: [setup, make-docker-images]
runs-on: ubuntu-24.04-arm # Run on arm runner for manifest merge
if: ${{ needs.setup.outputs.SHOULD_PUBLISH == 'true' }}
# Ensure each tag variant is published by only one workflow run at a time to keep manifests consistent.
concurrency:
group: merge-${{ matrix.postgres }}-${{ matrix.postgis }}-${{ matrix.variant }}
cancel-in-progress: false
continue-on-error: ${{ matrix.postgis == 'master' }}
env:
VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }}
VARIANT: ${{ matrix.variant }}
strategy:
matrix:
include: ${{ fromJSON(needs.setup.outputs.BUILD_TARGETS) }}

steps:
- name: Checkout source
uses: actions/checkout@v6

- name: Login to dockerhub
id: login-dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Download digests
uses: actions/download-artifact@v6
with:
path: ${{ runner.temp }}/digests
pattern: digests-${{ github.run_id }}-${{ github.run_attempt }}-${{ env.VERSION }}-${{ env.VARIANT }}-*
merge-multiple: true

- name: Verify digests for all platforms
working-directory: ${{ runner.temp }}/digests
run: |
expected="$(jq 'length' <<< "$RUNNER_PLATFORMS_JSON")"
found="$(find . -maxdepth 1 -type f | wc -l | tr -d '[:space:]')"
if [[ "$found" -ne "$expected" ]]; then
echo "ERROR: Expected ${expected} digest(s) (one per runner platform), found ${found}."
echo "RUNNER_PLATFORMS_JSON=${RUNNER_PLATFORMS_JSON}"
ls -la
exit 1
fi
echo "[OK] Found ${found}/${expected} digests"

- name: Create, push, and verify manifest list
env:
MATRIX_TAGS: ${{ matrix.tags }}
run: |
build_month="$(date -u +%Y%m)"
read -r -a tags_arr <<< "$MATRIX_TAGS"
extra_tags=""
if [[ "${#tags_arr[@]}" -ge 2 ]]; then
extra_tags+=" ${tags_arr[1]}-${build_month}"
fi
bash ci/push-manifest.sh "${{ env.DOCKERHUB_REPO }}" "${MATRIX_TAGS}${extra_tags}" "${{ runner.temp }}/digests" "$EXPECTED_IMAGE_PLATFORMS_JSON"

test-published-images:
name: "Published:${{ matrix.postgres }}-${{ matrix.postgis }}-${{ matrix.variant }} (${{ contains(matrix.runner-platform, 'arm') && 'arm64' || 'x86-64' }}) official-images test"
needs: [setup, merge-manifests]
runs-on: ${{ matrix.runner-platform }}
if: ${{ needs.setup.outputs.SHOULD_PUBLISH == 'true' }}
continue-on-error: ${{ matrix.postgis == 'master' }}
strategy:
matrix:
include: ${{ fromJSON(needs.setup.outputs.BUILD_INCLUDE) }}
env:
VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }}
VARIANT: ${{ matrix.variant }}

steps:
- name: Checkout source
uses: actions/checkout@v6

- name: Check out official-images repo
uses: actions/checkout@v6
with:
repository: docker-library/official-images
path: official-images
sparse-checkout: |
test

- name: Login to dockerhub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}

- name: Pull published manifest tag
env:
MATRIX_TAGS: ${{ matrix.tags }}
run: |
read -r primary_tag _ <<< "$MATRIX_TAGS"
published_image="${DOCKERHUB_REPO}:${primary_tag}"
local_tag="postgis/postgis:ci-published-${{ github.run_id }}-${{ github.run_attempt }}-${VERSION}-${VARIANT}-${{ contains(matrix.runner-platform, 'arm') && 'arm' || 'x64' }}"
docker pull "$published_image"
docker tag "$published_image" "$local_tag"
echo "CI_IMAGE_TAG=$local_tag" >> "$GITHUB_ENV"

- name: Test published image with official-images
env:
TEST_LOG_FILE: test-published-${{ env.VERSION }}-${{ env.VARIANT }}.log
run: bash ci/test-image.sh "$CI_IMAGE_TAG"

dockerHubDescription:
needs: [test-published-images]
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v6

- name: Prepare README with prefix (create ./_DOCKER-HUB-README.md )
run: bash ci/prepare-dockerhub-readme.sh && ls -la ./_DOCKER-HUB-README.md

- name: Debug ./_DOCKER-HUB-README.md
run: cat ./_DOCKER-HUB-README.md
- name: Update Docker Hub Description
uses: peter-evans/dockerhub-description@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
repository: ${{ env.DOCKERHUB_REPO }}
short-description: "${{ env.DOCKERHUB_SHORT_DESCRIPTION }}"
readme-filepath: ./_DOCKER-HUB-README.md
9 changes: 9 additions & 0 deletions 14-3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ LABEL maintainer="PostGIS Project - https://postgis.net" \
ENV POSTGIS_MAJOR=3
ENV POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1

# Archived suite: deb.debian.org and apt.postgresql.org no longer serve it.
RUN set -eux; \
mv /etc/apt/sources.list.d/pgdg.list /tmp/pgdg.list.disabled; \
sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
sed 's|http://apt.postgresql.org/pub/repos/apt/|https://apt-archive.postgresql.org/pub/repos/apt/|' /tmp/pgdg.list.disabled > /etc/apt/sources.list.d/pgdg.list; \
rm -f /tmp/pgdg.list.disabled; \
rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
Expand Down
9 changes: 9 additions & 0 deletions 15-3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ LABEL maintainer="PostGIS Project - https://postgis.net" \
ENV POSTGIS_MAJOR=3
ENV POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1

# Archived suite: deb.debian.org and apt.postgresql.org no longer serve it.
RUN set -eux; \
mv /etc/apt/sources.list.d/pgdg.list /tmp/pgdg.list.disabled; \
sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
sed 's|http://apt.postgresql.org/pub/repos/apt/|https://apt-archive.postgresql.org/pub/repos/apt/|' /tmp/pgdg.list.disabled > /etc/apt/sources.list.d/pgdg.list; \
rm -f /tmp/pgdg.list.disabled; \
rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
Expand Down
9 changes: 9 additions & 0 deletions 16-3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ LABEL maintainer="PostGIS Project - https://postgis.net" \
ENV POSTGIS_MAJOR=3
ENV POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1

# Archived suite: deb.debian.org and apt.postgresql.org no longer serve it.
RUN set -eux; \
mv /etc/apt/sources.list.d/pgdg.list /tmp/pgdg.list.disabled; \
sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
sed 's|http://apt.postgresql.org/pub/repos/apt/|https://apt-archive.postgresql.org/pub/repos/apt/|' /tmp/pgdg.list.disabled > /etc/apt/sources.list.d/pgdg.list; \
rm -f /tmp/pgdg.list.disabled; \
rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
Expand Down
9 changes: 9 additions & 0 deletions 17-3.5/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ LABEL maintainer="PostGIS Project - https://postgis.net" \
ENV POSTGIS_MAJOR=3
ENV POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1

# Archived suite: deb.debian.org and apt.postgresql.org no longer serve it.
RUN set -eux; \
mv /etc/apt/sources.list.d/pgdg.list /tmp/pgdg.list.disabled; \
sed -i 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' /etc/apt/sources.list; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
sed 's|http://apt.postgresql.org/pub/repos/apt/|https://apt-archive.postgresql.org/pub/repos/apt/|' /tmp/pgdg.list.disabled > /etc/apt/sources.list.d/pgdg.list; \
rm -f /tmp/pgdg.list.disabled; \
rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LABEL maintainer="PostGIS Project - https://postgis.net" \
ENV POSTGIS_MAJOR=%%POSTGIS_MAJOR%%
ENV POSTGIS_VERSION=%%POSTGIS_VERSION%%

%%PGDG_APT_FIX%%
RUN apt-get update \
&& apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
&& apt-get install -y --no-install-recommends \
Expand Down
Loading
Loading