diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..f464ba66d --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,177 @@ +# .circleci/config.yml + +# Circle CI arm64 builder +version: 2.1 + +orbs: + # https://circleci.com/developer/orbs/orb/circleci/docker + docker: circleci/docker@2.8.1 + # https://circleci.com/developer/orbs/orb/circleci/python + python: circleci/python@3.0.0 + # https://circleci.com/developer/orbs/orb/circleci/shellcheck + shellcheck: circleci/shellcheck@3.2.0 + +jobs: + build-arm64: + # We limit this to prevent overloading external servers (e.g., OSGeo, PROJ). + # Note: Include parallel GitHub CI jobs when calculating the total load, as they run simultaneously! + parallelism: 8 + machine: + image: ubuntu-2404:current + resource_class: arm.large + environment: + BUILDX_PLATFORMS: linux/arm64v8 + DOCKER_BUILDKIT: '1' + PLATFORM: linux/arm64v8 + parameters: + target-version-variant: + type: string + steps: + - checkout + + - run: + name: Display pipeline.* values + command: | + echo 'pipeline.git.branch: <>' + echo 'pipeline.git.revision: <>' + echo 'pipeline.id: <>' + echo 'pipeline.project.git_url: <>' + echo 'pipeline.trigger_source: <>' + echo 'pipeline.schedule.name:<< pipeline.schedule.name >>' + echo 'pipeline.schedule.id:<< pipeline.schedule.id >>' + + - docker/check: + registry: docker.io + docker-username: DOCKERHUB_USERNAME + docker-password: DOCKERHUB_ACCESS_TOKEN + + - run: + name: Docker Ratelimit Check - before + # https://docs.docker.com/docker-hub/download-rate-limit/ + command: | + TOKEN=$(curl --user "$DOCKERHUB_USERNAME:$DOCKERHUB_ACCESS_TOKEN" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) + HEADERS=$(curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest) + echo "Rate Limit Info:" + echo "$HEADERS" | grep ratelimit + + - run: uname -a + - run: docker --version + - run: docker info + - run: pip3 install --upgrade pip + - run: pip3 install --upgrade lastversion check-jsonschema + - run: tools/install_manifest-tool.sh + - run: tools/install_dive.sh + - run: tools/environment_init.sh + - run: make check_version + + - run: + name: Conditional Docker Check - Halt if not on master branch or if it's a PR or Weekly image exists + command: | + # Check if the current branch is 'master' and the weekly image is not extis + # If weekly image exists, skip docker build and push + source tools/environment_init.sh + echo "check: << parameters.target-version-variant >>${IMAGE_VERSION_ID}" + check_image_exists "<< parameters.target-version-variant >>${IMAGE_VERSION_ID}" || true + if [ "$CIRCLE_BRANCH" == "master" ] && check_image_exists "<< parameters.target-version-variant >>${IMAGE_VERSION_ID}"; then + circleci-agent step halt + fi + + - run: make -n test-<< parameters.target-version-variant >> + - run: make test-<< parameters.target-version-variant >> + - run: make scan-<< parameters.target-version-variant >> || true + - run: make dive-<< parameters.target-version-variant >> || true + - run: docker images + + - run: + name: Conditional Docker Check - Halt if not on master branch or if it's a PR + command: | + # Check if the current branch is NOT 'master' or if the build is triggered by a pull request. + # If either of these conditions is met, halt the workflow. + if [ "$CIRCLE_BRANCH" != "master" ] || [ -n "$CIRCLE_PULL_REQUEST" ]; then + circleci-agent step halt + fi + + - run: + name: "Push docker image : make push-<< parameters.target-version-variant >>" + command: | + if [ "$CIRCLE_BRANCH" == "master" ] && [ -z "$CIRCLE_PULL_REQUEST" ]; then + make push-<< parameters.target-version-variant >> + make manifest-<< parameters.target-version-variant >> + echo "...push and manifest done..." + fi + + - run: + name: Docker Ratelimit Check - after + # https://docs.docker.com/docker-hub/download-rate-limit/ + command: | + TOKEN=$(curl --user "$DOCKERHUB_USERNAME:$DOCKERHUB_ACCESS_TOKEN" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) + HEADERS=$(curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest) + echo "Rate Limit Info:" + echo "$HEADERS" | grep ratelimit + + +workflows: + build-deploy: +# AND triggered by the app.circleci.com UI +# daily run : Repeats everyday every month ; 6:00am UTC, 1 (once per hour). + jobs: + - build-arm64: + matrix: + parameters: + target-version-variant: [ +# +# They are created using the ./apply-ci.sh script based on the version.json file, +# where the architecture is defined as "arm64". +# These "--skip--" images serve as inputs for the "*-bundle" images, +# hence they must be generated within the bundle JOB. +# +#circleci-targets-start + "13-3.3-alpine3.21", + "13-3.4-alpine3.21", + "13-3.4-alpine3.22", + "13-3.5-alpine3.21", + "13-3.5-alpine3.22", + "13-3.5-bookworm", + "13-3.5-bullseye", + "14-3.3-alpine3.21", + "14-3.4-alpine3.21", + "14-3.4-alpine3.22", + "14-3.5-alpine3.21", + "14-3.5-alpine3.22", + "14-3.5-bookworm", + "14-3.5-bullseye", + "14-l3.1.9gcp-bookworm", + "15-3.3-alpine3.21", + "15-3.4-alpine3.21", + "15-3.4-alpine3.22", + "15-3.5-alpine3.21", + "15-3.5-alpine3.22", + "15-3.5-bookworm", + "15-3.5-bullseye", + "16-3.3-alpine3.21", + "16-3.4-alpine3.21", + "16-3.4-alpine3.22", + "16-3.5-alpine3.21", + "16-3.5-alpine3.22", +# --skip-- "16-3.5-bookworm", --> generated with the related bundle job! + "16-3.5-bullseye", + "16-3.5-bundle0-bookworm", + "16-master-bookworm", + "16-recent-bookworm", + "17-3.4-alpine3.21", + "17-3.4-alpine3.22", + "17-3.5-alpine3.21", + "17-3.5-alpine3.22", +# --skip-- "17-3.5-bookworm", --> generated with the related bundle job! + "17-3.5-bullseye", + "17-3.5-bundle0-bookworm", + "17-3.6-alpine3.22", + "17-master-bookworm", + "17-recent-bookworm", + "18-3.5-alpine3.22", + "18-3.5-bookworm", + "18-3.6-alpine3.22", + "18-master-bookworm", + "18-recent-bookworm", +#circleci-targets-end + ] diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 000000000..b5eca3fed --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,36 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +# see - https://docs.coderabbit.ai/configure-coderabbit/ + +language: "en-US" + +early_access: true + +# we(docker-postgis) always need a human to approve (and merge), we don't use this, +reviews: + profile: "chill" + request_changes_workflow: false + high_level_summary: false + poem: false + review_status: false + collapse_walkthrough: true + auto_review: + enabled: false + drafts: false + +# chat is allowed +chat: + auto_reply: true + + +# https://docs.coderabbit.ai/guides/commands +# +# The following commands are available (invoked as PR comments): +# @coderabbitai pause : to pause the reviews on a PR. +# @coderabbitai resume : to resume the paused reviews. +# @coderabbitai review : to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. +# @coderabbitai full review : to do a full review from scratch and review all the files again. +# @coderabbitai summary : to regenerate the summary of the PR. +# @coderabbitai resolve : resolve all the CodeRabbit review comments. +# @coderabbitai configuration : to show the current CodeRabbit configuration for the repository. +# @coderabbitai help : to get help. + diff --git a/.dockerignore b/.dockerignore index 2de8e88c3..7337eb52b 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,24 @@ -Dockerfile .git _* +.jq-template.awk +.template-helper-functions.jq +.vscode/ + +.git/ +.github/ +.gitignore +.circleci/ + +docs/ +README.md +version.json + +Dockerfile.*.template +localetest.sh +apply-*.sh + +trivy_cache +tmp/ + +venv-docker-postgis/ +tools/dive \ No newline at end of file diff --git a/.env b/.env new file mode 100644 index 000000000..746da9e9c --- /dev/null +++ b/.env @@ -0,0 +1,22 @@ +# PROD setup +# +# Setup info, used by: +# ./update.sh and other scripts ( ./apply-*.sh ) +# ./Makefile +# ./.github/workflows/main.yml +# ./.circleci/config.yml +# +# IF your are changing the values, please run ./update.sh +# to update some hard coded values in the Dockerfiles or README.md +# + +REGISTRY=docker.io +REPO_NAME=imresamu +IMAGE_NAME=postgis +DOCKERHUB_README_REPOSITORY=imresamu/postgis + +dockerhublink='https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=' +githubrepolink='https://github.com/imresamu/docker-postgis/blob/master' + +ENABLE_IMAGE_ARCH=true +ENABLE_IMAGE_VERSION_ID=true diff --git a/.env.test b/.env.test new file mode 100644 index 000000000..e6f2a3862 --- /dev/null +++ b/.env.test @@ -0,0 +1,23 @@ +# Test Setup ; if TEST=true +# +# Setup info, used by: +# ./update.sh and other scripts ( ./apply-*.sh ) +# ./Makefile +# ./.github/workflows/main.yml +# ./.circleci/config.yml +# +# IF your are changing the values, please run ./update.sh +# to update some hard coded values in the Dockerfiles or README.md +# + +REGISTRY=localhost:5000 +REPO_NAME=testrepo +IMAGE_NAME=testpostgisimage +DOCKERHUB_README_REPOSITORY=testrepo/testpostgisimage + +dockerhublink='https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=' +githubrepolink='https://github.com/postgis/docker-postgis/blob/master' + +ENABLE_IMAGE_ARCH=true +ENABLE_IMAGE_VERSION_ID=true + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..16c09d088 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +# https://github.com/actions/checkout/issues/135#issuecomment-613361104 +* text eol=lf + +/*/**/Dockerfile linguist-generated +/*/**/initdb-postgis.sh linguist-generated +/*/**/update-postgis.sh linguist-generated +/*/**/tags linguist-generated +.github/workflows/main.yml linguist-generated +versions.json linguist-generated +README.md linguist-generated +/Dockerfile*.template linguist-language=Dockerfile diff --git a/.github/workflows/auto-rerun-helper.yml b/.github/workflows/auto-rerun-helper.yml new file mode 100644 index 000000000..0fd005389 --- /dev/null +++ b/.github/workflows/auto-rerun-helper.yml @@ -0,0 +1,43 @@ +name: Auto-rerun Failed Builds (helper) + +on: + workflow_dispatch: + workflow_run: + workflows: + - workflow-build-alpine + - workflow-build-debian + - workflow-build-development + - workflow-build-test + - workflow-build-retrytest + + types: [completed] + +concurrency: + group: "${{ github.event.workflow_run.id }}-helper" + cancel-in-progress: true + +permissions: + actions: write # needed for rerun + contents: read + +jobs: + rerun-failed: + if: > + github.event.workflow_run.conclusion == 'failure' && + github.event.workflow_run.attempt < 3 + runs-on: ubuntu-24.04 + + steps: + - name: Re-run only failed jobs + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo "🔄 Queuing attempt $((${{ github.event.workflow_run.attempt }} + 1)) for workflow '${{ github.event.workflow_run.name }}'" + echo "📊 Failed run ID: ${{ github.event.workflow_run.id }}" + echo "📅 Original run started: ${{ github.event.workflow_run.created_at }}" + echo "🎯 Retrying only failed jobs..." + + gh run rerun ${{ github.event.workflow_run.id }} --failed \ + --repo ${{ github.repository }} + + echo "✅ Retry queued successfully!" diff --git a/.github/workflows/localtest.yml b/.github/workflows/localtest.yml new file mode 100644 index 000000000..add6075c9 --- /dev/null +++ b/.github/workflows/localtest.yml @@ -0,0 +1,21 @@ +name: "Localtest" +# testing the workflow +on: + push: + pull_request: + schedule: + - cron: '15 5 * * 1' + +jobs: + localtest: + name: "testing ./localtest.sh ( update.sh and build test and push to local registry )" + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - run: docker ps -a + - run: pip3 install --upgrade pip + - run: pip3 install --upgrade lastversion check-jsonschema + - run: tools/install_manifest-tool.sh + - run: tools/environment_init.sh + - run: tools/localtest.sh + - run: docker images diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5db918d69..524befde4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,62 +1,214 @@ -name: Docker PostGIS CI +name: Build PostGIS images + +# This is the x86_64/Amd64 build worklow on: push: pull_request: schedule: - - cron: '15 5 * * 1' + - cron: '15 5 * * *' defaults: run: shell: bash jobs: - make-docker-images: strategy: + # We limit this to prevent overloading external servers (e.g., OSGeo, PROJ). + # Note: Include parallel Circle CI jobs when calculating the total load, as they run simultaneously! + max-parallel: 6 matrix: - postgres: [12, 13, 14, 15, 16] - postgis: ['3.4'] - variant: [default, alpine] include: - - postgres: 15 - postgis: master - variant: default - - postgres: 16 - postgis: master - variant: default - - postgres: 11 - postgis: 3.3 - variant: default - - postgres: 11 - postgis: 3.3 - variant: alpine - - name: Build docker image for ${{ matrix.postgres }}-${{ matrix.postgis }} variant ${{ matrix.variant }} - runs-on: ubuntu-20.04 - continue-on-error: ${{ matrix.postgis == 'master' }} +# +# They are created using the ./apply-ci.sh script based on the version.json file, +# +# These "--skip--" images serve as inputs for the "*-bundle" images, +# hence they must be generated within the bundle JOB. +# +#matrix-include-start + - { version: "13-3.3", variant: "alpine3.21" } + - { version: "13-3.4", variant: "alpine3.21" } + - { version: "13-3.4", variant: "alpine3.22" } + - { version: "13-3.5", variant: "alpine3.21" } + - { version: "13-3.5", variant: "alpine3.22" } + - { version: "13-3.5", variant: "bookworm" } + - { version: "13-3.5", variant: "bullseye" } + - { version: "14-3.3", variant: "alpine3.21" } + - { version: "14-3.4", variant: "alpine3.21" } + - { version: "14-3.4", variant: "alpine3.22" } + - { version: "14-3.5", variant: "alpine3.21" } + - { version: "14-3.5", variant: "alpine3.22" } + - { version: "14-3.5", variant: "bookworm" } + - { version: "14-3.5", variant: "bullseye" } + - { version: "14-l3.1.9gcp", variant: "bookworm" } + - { version: "15-3.3", variant: "alpine3.21" } + - { version: "15-3.4", variant: "alpine3.21" } + - { version: "15-3.4", variant: "alpine3.22" } + - { version: "15-3.5", variant: "alpine3.21" } + - { version: "15-3.5", variant: "alpine3.22" } + - { version: "15-3.5", variant: "bookworm" } + - { version: "15-3.5", variant: "bullseye" } + - { version: "16-3.3", variant: "alpine3.21" } + - { version: "16-3.4", variant: "alpine3.21" } + - { version: "16-3.4", variant: "alpine3.22" } + - { version: "16-3.5", variant: "alpine3.21" } + - { version: "16-3.5", variant: "alpine3.22" } +# --skip-- - { version: "16-3.5", variant: "bookworm" } --> generated with the related bundle job! + - { version: "16-3.5", variant: "bullseye" } + - { version: "16-3.5-bundle0", variant: "bookworm" } + - { version: "16-master", variant: "bookworm" } + - { version: "16-recent", variant: "bookworm" } + - { version: "17-3.4", variant: "alpine3.21" } + - { version: "17-3.4", variant: "alpine3.22" } + - { version: "17-3.5", variant: "alpine3.21" } + - { version: "17-3.5", variant: "alpine3.22" } +# --skip-- - { version: "17-3.5", variant: "bookworm" } --> generated with the related bundle job! + - { version: "17-3.5", variant: "bullseye" } + - { version: "17-3.5-bundle0", variant: "bookworm" } + - { version: "17-3.6", variant: "alpine3.22" } + - { version: "17-master", variant: "bookworm" } + - { version: "17-recent", variant: "bookworm" } + - { version: "18-3.5", variant: "alpine3.22" } + - { version: "18-3.5", variant: "bookworm" } + - { version: "18-3.6", variant: "alpine3.22" } + - { version: "18-master", variant: "bookworm" } + - { version: "18-recent", variant: "bookworm" } +#matrix-include-end + + name: "${{ matrix.version }}-${{ matrix.variant }} docker image" + runs-on: ubuntu-24.04 + continue-on-error: ${{ endsWith(matrix.version, '-master') }} + env: + PLATFORM: linux/amd64 + DOCKER_BUILDKIT: '1' + BUILDX_PLATFORMS: linux/amd64 + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - run: pip3 install --upgrade pip + - run: pip3 install --upgrade lastversion check-jsonschema + - run: tools/install_manifest-tool.sh + - run: tools/install_dive.sh + - run: tools/environment_init.sh + - run: make check_version + + - name: Check if DOCKERHUB_USERNAME exists + run: | + if [[ -z "${{ secrets.DOCKERHUB_USERNAME }}" ]]; then + echo "DOCKERHUB_USERNAME is not set" + exit 1 + else + echo "DOCKERHUB_USERNAME is set" + fi + + - name: Check if DOCKERHUB_ACCESS_TOKEN exists + run: | + if [[ -z "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" ]]; then + echo "DOCKERHUB_ACCESS_TOKEN is not set" + exit 1 + else + echo "DOCKERHUB_ACCESS_TOKEN is set" + fi + + - name: Login to dockerhub + uses: docker/login-action@v3 + if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Docker Ratelimit Check + # https://docs.docker.com/docker-hub/download-rate-limit/ + run: | + TOKEN=$(curl --user "${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) + HEADERS=$(curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest) + echo "Rate Limit Info:" + echo "$HEADERS" | grep ratelimit + + - name: Check if image exists + id: check-image + run: | + source tools/environment_init.sh && \ + echo "IMAGE_VERSION_ID=${IMAGE_VERSION_ID}" >> $GITHUB_ENV && \ + if check_image_exists "${{ matrix.version }}-${{ matrix.variant }}${IMAGE_VERSION_ID}"; then + echo "IMAGE_EXISTS=true" >> $GITHUB_ENV + else + echo "IMAGE_EXISTS=false" >> $GITHUB_ENV + fi + + - name: Weekly image exists -> exit + if: env.IMAGE_EXISTS == 'true' + run: | + echo "weekly build exists; no need to re-build. STOP" + exit 0 + + - name: "verify: make -n test-${{ matrix.version }}-${{ matrix.variant }} " + if: env.IMAGE_EXISTS == 'false' + run: make -n test-${{ matrix.version }}-${{ matrix.variant }} + + - name: "make test-${{ matrix.version }}-${{ matrix.variant }} " + if: env.IMAGE_EXISTS == 'false' + run: make test-${{ matrix.version }}-${{ matrix.variant }} + + - name: "make scan-${{ matrix.version }}-${{ matrix.variant }}" + if: env.IMAGE_EXISTS == 'false' + run: make scan-${{ matrix.version }}-${{ matrix.variant }} || true + + - name: "make dive-${{ matrix.version }}-${{ matrix.variant }}" + if: env.IMAGE_EXISTS == 'false' + run: make dive-${{ matrix.version }}-${{ matrix.variant }} || true + + - run: docker images + + - name: Push docker image to dockerhub + if: ${{ (env.IMAGE_EXISTS == 'false') && (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + run: | + make push-${{ matrix.version }}-${{ matrix.variant }} + make manifest-${{ matrix.version }}-${{ matrix.variant }} + + make-readme: + name: update readme + needs: make-docker-images + runs-on: ubuntu-24.04 env: - VERSION: ${{ matrix.postgres }}-${{ matrix.postgis }} - VARIANT: ${{ matrix.variant }} + PLATFORM: linux/amd64 + DOCKER_BUILDKIT: '1' + BUILDX_PLATFORMS: linux/amd64 steps: - name: Checkout source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Build docker image for ${{ env.VERSION }} ${{ env.VARIANT }} - run: make test + - run: pip3 install --upgrade pip + - run: pip3 install --upgrade lastversion check-jsonschema + - run: tools/install_manifest-tool.sh + - run: tools/environment_init.sh + - run: make check_version - name: Login to dockerhub - uses: docker/login-action@v2 + uses: docker/login-action@v3 if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }} with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - - name: Push docker image to dockerhub + - name: Docker Ratelimit Check + # https://docs.docker.com/docker-hub/download-rate-limit/ + run: | + TOKEN=$(curl --user "${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token) + HEADERS=$(curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest) + echo "Rate Limit Info:" + echo "$HEADERS" | grep ratelimit + + - name: push readme to docker hub api if: ${{ (github.ref == 'refs/heads/master') && (github.event_name != 'pull_request') }} env: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} - run: make push - + run: make push-readme diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 000000000..5d1f0c8fe --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,16 @@ +name: "Shellcheck" + +on: + push: + pull_request: + +jobs: + shellcheck: + name: Shellcheck + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + env: + SHELLCHECK_OPTS: --external-sources \ No newline at end of file diff --git a/.github/workflows/test_manifest.yml b/.github/workflows/test_manifest.yml new file mode 100644 index 000000000..8afc57b9b --- /dev/null +++ b/.github/workflows/test_manifest.yml @@ -0,0 +1,484 @@ +name: Multi-Architecture Docker Manifest Test + +on: + workflow_dispatch: + inputs: + push_images: + description: 'Push images to registry' + required: false + default: true + type: boolean + additional_registries: + description: 'Additional registries (comma-separated, e.g., ghcr.io,quay.io)' + required: false + default: '' + type: string + push: + paths: + - '.github/workflows/test_manifest.yml' + - '18-3.5/bookworm/**' + - '18-3.6/alpine3.22/**' + pull_request: + paths: + - '.github/workflows/test_manifest.yml' + - '18-3.5/bookworm/**' + - '18-3.6/alpine3.22/**' + +defaults: + run: + shell: bash + +env: + DOCKER_BUILDKIT: '1' + REGISTRY: 'docker.io' + REPO_NAME: 'imresamu' + IMAGE_NAME: 'postgistest' + +jobs: + build-images: + strategy: + fail-fast: false + matrix: + include: + # 18-3.5/bookworm builds + - image_dir: "18-3.5/bookworm" + target: "linux/amd64" + runner: "ubuntu-22.04" + arch_variant: "amd64" + - image_dir: "18-3.5/bookworm" + target: "linux/arm64" + runner: "ubuntu-22.04-arm" + arch_variant: "arm64" +# - image_dir: "18-3.5/bookworm" +# target: "linux/arm/v6" +# runner: "ubuntu-22.04-arm" +# arch_variant: "armv6" +# - image_dir: "18-3.5/bookworm" +# target: "linux/arm/v7" +# runner: "ubuntu-22.04-arm" +# arch_variant: "armv7" + + # 18-3.6/alpine3.22 builds + - image_dir: "18-3.6/alpine3.22" + target: "linux/amd64" + runner: "ubuntu-22.04" + arch_variant: "amd64" + - image_dir: "18-3.6/alpine3.22" + target: "linux/arm64" + runner: "ubuntu-22.04-arm" + arch_variant: "arm64" +# - image_dir: "18-3.6/alpine3.22" +# target: "linux/arm/v6" +# runner: "ubuntu-22.04-arm" +# arch_variant: "armv6" +# - image_dir: "18-3.6/alpine3.22" +# target: "linux/arm/v7" +# runner: "ubuntu-22.04-arm" +# arch_variant: "armv7" + + # Future architecture support + # - target: "linux/mips64le" + # runner: "ubuntu-22.04" + # arch_variant: "mips64le" + # - target: "linux/ppc64le" + # runner: "ubuntu-22.04" + # arch_variant: "ppc64le" + # - target: "linux/s390x" + # runner: "ubuntu-22.04" + # arch_variant: "s390x" + # - target: "linux/386" + # runner: "ubuntu-22.04" + # arch_variant: "386" + + name: "Build ${{ matrix.image_dir }} for ${{ matrix.arch_variant }}" + runs-on: ${{ matrix.runner }} + continue-on-error: false + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Set up QEMU for cross-platform builds + uses: docker/setup-qemu-action@v3 + with: + platforms: all + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + driver-opts: network=host + + - name: Install build dependencies + run: | + set -x + pip3 install --upgrade pip lastversion check-jsonschema + tools/install_manifest-tool.sh + tools/environment_init.sh + + - name: Check Docker Hub credentials + if: ${{ inputs.push_images }} + run: | + set -x + [[ -n "${{ secrets.DOCKERHUB_USERNAME }}" ]] || { echo "DOCKERHUB_USERNAME missing"; exit 1; } + [[ -n "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" ]] || { echo "DOCKERHUB_ACCESS_TOKEN missing"; exit 1; } + + - name: Login to Docker Hub + uses: docker/login-action@v3 + if: ${{ inputs.push_images && (github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch') }} + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Login to additional registries + if: ${{ inputs.push_images && inputs.additional_registries != '' }} + run: | + set -x + IFS=',' read -ra REGISTRIES <<< "${{ inputs.additional_registries }}" + for registry in "${REGISTRIES[@]}"; do + registry=$(echo "$registry" | xargs) + case "$registry" in + "ghcr.io") + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + ;; + "quay.io") + if [[ -n "${{ secrets.QUAY_USERNAME }}" && -n "${{ secrets.QUAY_TOKEN }}" ]]; then + echo "${{ secrets.QUAY_TOKEN }}" | docker login quay.io -u "${{ secrets.QUAY_USERNAME }}" --password-stdin + else + echo "Quay.io credentials not configured, skipping" + fi + ;; + *) + echo "Registry $registry not supported, skipping" + ;; + esac + done + + - name: Read tags from directory + id: read-tags + run: | + set -x + TAGS_FILE="${{ matrix.image_dir }}/tags" + [[ -f "$TAGS_FILE" ]] || { echo "Tags file not found: $TAGS_FILE"; exit 1; } + cat "$TAGS_FILE" + TAGS=$(cat "$TAGS_FILE" | tr ' ' '\n' | sed '/^$/d' | jq -R . | jq -s . | jq -c .) + echo "tags<> $GITHUB_OUTPUT + echo "$TAGS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Generate Docker build tags + id: generate-tags + run: | + set -x + TAGS_JSON='${{ steps.read-tags.outputs.tags }}' + DOCKER_TAGS="" + ALL_REGISTRIES="${{ env.REGISTRY }}" + + if [[ -n "${{ inputs.additional_registries }}" ]]; then + IFS=',' read -ra ADDITIONAL <<< "${{ inputs.additional_registries }}" + for reg in "${ADDITIONAL[@]}"; do + reg=$(echo "$reg" | xargs) + ALL_REGISTRIES="$ALL_REGISTRIES,$reg" + done + fi + + IFS=',' read -ra REGISTRIES <<< "$ALL_REGISTRIES" + for registry in "${REGISTRIES[@]}"; do + registry=$(echo "$registry" | xargs) + for tag in $(echo "$TAGS_JSON" | jq -r '.[]'); do + case "$registry" in + "ghcr.io") + FULL_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${{ matrix.arch_variant }}:${tag}" + ;; + "quay.io") + FULL_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${{ matrix.arch_variant }}:${tag}" + ;; + *) + FULL_TAG="$registry/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}-${{ matrix.arch_variant }}:${tag}" + ;; + esac + + [[ -z "$DOCKER_TAGS" ]] && DOCKER_TAGS="$FULL_TAG" || DOCKER_TAGS="$DOCKER_TAGS,$FULL_TAG" + done + done + + echo "docker_tags=$DOCKER_TAGS" >> $GITHUB_OUTPUT + echo "Generated tags:" + echo "$DOCKER_TAGS" | tr ',' '\n' + + - name: Build Docker image + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.image_dir }} + file: ${{ matrix.image_dir }}/Dockerfile + platforms: ${{ matrix.target }} + push: false + load: true + tags: ${{ steps.generate-tags.outputs.docker_tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + provenance: false + sbom: false + build-args: | + BUILDKIT_INLINE_CACHE=1 + + + - name: List docker images + run: docker images + + - name: Test built image with official test suite + run: | + set -x + FIRST_TAG=$(echo '${{ steps.read-tags.outputs.tags }}' | jq -r '.[0]') + TEST_IMAGE="${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}-${{ matrix.arch_variant }}:${FIRST_TAG}" + + # Set platform for non-native architectures + case "${{ matrix.target }}" in + "linux/arm/v6"|"linux/arm/v7") + export DOCKER_DEFAULT_PLATFORM="${{ matrix.target }}" + echo "Testing with DOCKER_DEFAULT_PLATFORM=${{ matrix.target }}" + ;; + *) + echo "Testing natively for ${{ matrix.target }}" + ;; + esac + + git clone --depth 1 https://github.com/docker-library/official-images.git + + [[ -f "./official-images/test/run.sh" ]] || { echo "./official-images/test/run.sh not found"; exit 1; } + [[ -f "./test/postgis-config.sh" ]] || { echo "./test/postgis-config.sh not found"; exit 1; } + [[ -f "./official-images/test/config.sh" ]] || { echo "./official-images/test/config.sh not found"; exit 1; } + + ./official-images/test/run.sh -c ./official-images/test/config.sh -c test/postgis-config.sh "$TEST_IMAGE" + + - name: Push Docker image + if: ${{ inputs.push_images && (github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch') }} + run: | + set -x + # Reuse tags from generate-tags step + echo '${{ steps.generate-tags.outputs.docker_tags }}' | tr ',' '\n' | while read -r tag; do + docker push "$tag" + done + + create-manifests: + name: "Create Multi-Arch Manifests" + needs: build-images + runs-on: ubuntu-22.04 + if: ${{ inputs.push_images && (github.ref == 'refs/heads/master' || github.event_name == 'workflow_dispatch') }} + + strategy: + matrix: + image_dir: + - "18-3.5/bookworm" + - "18-3.6/alpine3.22" + + steps: + - name: Checkout source + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Login to additional registries + if: ${{ inputs.additional_registries != '' }} + run: | + set -x + IFS=',' read -ra REGISTRIES <<< "${{ inputs.additional_registries }}" + for registry in "${REGISTRIES[@]}"; do + registry=$(echo "$registry" | xargs) + case "$registry" in + "ghcr.io") + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + ;; + "quay.io") + if [[ -n "${{ secrets.QUAY_USERNAME }}" && -n "${{ secrets.QUAY_TOKEN }}" ]]; then + echo "${{ secrets.QUAY_TOKEN }}" | docker login quay.io -u "${{ secrets.QUAY_USERNAME }}" --password-stdin + else + echo "Quay.io credentials not configured, skipping" + fi + ;; + esac + done + + - name: Read original tags + id: read-original-tags + run: | + set -x + TAGS_FILE="${{ matrix.image_dir }}/tags" + [[ -f "$TAGS_FILE" ]] || { echo "Tags file not found"; exit 1; } + cat "$TAGS_FILE" + TAGS=$(cat "$TAGS_FILE" | tr ' ' '\n' | sed '/^$/d' | jq -R . | jq -s . | jq -c .) + echo "tags<> $GITHUB_OUTPUT + echo "$TAGS" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create and push multi-architecture manifests + run: | + set -x + TAGS_JSON='${{ steps.read-original-tags.outputs.tags }}' + ARCHITECTURES=("amd64" "arm64") + #### not used "armv6" "armv7" ### + + ALL_REGISTRIES="${{ env.REGISTRY }}" + [[ -n "${{ inputs.additional_registries }}" ]] && ALL_REGISTRIES="$ALL_REGISTRIES,${{ inputs.additional_registries }}" + + IFS=',' read -ra REGISTRIES <<< "$ALL_REGISTRIES" + + for registry in "${REGISTRIES[@]}"; do + registry=$(echo "$registry" | xargs) + for tag in $(echo "$TAGS_JSON" | jq -r '.[]'); do + case "$registry" in + "ghcr.io") + MANIFEST_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${tag}" + ;; + "quay.io") + MANIFEST_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${tag}" + ;; + *) + MANIFEST_TAG="$registry/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${tag}" + ;; + esac + + docker manifest rm "$MANIFEST_TAG" 2>/dev/null || true + + MANIFEST_CMD="docker manifest create --amend $MANIFEST_TAG" + for arch in "${ARCHITECTURES[@]}"; do + case "$registry" in + "ghcr.io") + ARCH_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + "quay.io") + ARCH_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + *) + ARCH_TAG="$registry/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + esac + MANIFEST_CMD="$MANIFEST_CMD $ARCH_TAG" + done + eval "$MANIFEST_CMD" + + for arch in "${ARCHITECTURES[@]}"; do + case "$registry" in + "ghcr.io") + ARCH_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + "quay.io") + ARCH_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + *) + ARCH_TAG="$registry/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}-${arch}:${tag}" + ;; + esac + case "$arch" in + "amd64") + docker manifest annotate "$MANIFEST_TAG" "$ARCH_TAG" --os linux --arch amd64 + ;; + "arm64") + docker manifest annotate "$MANIFEST_TAG" "$ARCH_TAG" --os linux --arch arm64 + ;; + "armv6") + docker manifest annotate "$MANIFEST_TAG" "$ARCH_TAG" --os linux --arch arm --variant v6 + ;; + "armv7") + docker manifest annotate "$MANIFEST_TAG" "$ARCH_TAG" --os linux --arch arm --variant v7 + ;; + esac + done + + docker manifest push "$MANIFEST_TAG" + docker manifest inspect "$MANIFEST_TAG" | jq '.manifests[] | {platform: .platform, digest: .digest}' + done + done + + - name: Test multi-architecture manifests + run: | + set -x + FIRST_TAG=$(echo '${{ steps.read-original-tags.outputs.tags }}' | jq -r '.[0]') + + ALL_REGISTRIES="${{ env.REGISTRY }}" + [[ -n "${{ inputs.additional_registries }}" ]] && ALL_REGISTRIES="$ALL_REGISTRIES,${{ inputs.additional_registries }}" + + IFS=',' read -ra REGISTRIES <<< "$ALL_REGISTRIES" + + for registry in "${REGISTRIES[@]}"; do + registry=$(echo "$registry" | xargs) + + case "$registry" in + "ghcr.io") + MANIFEST_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${FIRST_TAG}" + ;; + "quay.io") + MANIFEST_TAG="$registry/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${FIRST_TAG}" + ;; + *) + MANIFEST_TAG="$registry/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${FIRST_TAG}" + ;; + esac + + MANIFEST_INFO=$(docker manifest inspect "$MANIFEST_TAG") + EXPECTED_ARCHS=4 + ACTUAL_ARCHS=$(echo "$MANIFEST_INFO" | jq '.manifests | length') + + if [[ "$ACTUAL_ARCHS" -eq "$EXPECTED_ARCHS" ]]; then + echo "$registry manifest OK: $ACTUAL_ARCHS/$EXPECTED_ARCHS architectures" + else + echo "$registry manifest ERROR: $ACTUAL_ARCHS/$EXPECTED_ARCHS architectures" + exit 1 + fi + done + + summary: + name: "Build Summary" + needs: [build-images, create-manifests] + runs-on: ubuntu-22.04 + if: always() + + steps: + - name: Generate summary + run: | + cat >> $GITHUB_STEP_SUMMARY << 'EOF' + ## Multi-Architecture Docker Build Summary + + ### Build Results + EOF + + if [[ "${{ needs.build-images.result }}" == "success" ]]; then + echo "- Individual Architecture Builds: SUCCESS" >> $GITHUB_STEP_SUMMARY + else + echo "- Individual Architecture Builds: FAILED" >> $GITHUB_STEP_SUMMARY + fi + + if [[ "${{ needs.create-manifests.result }}" == "success" ]]; then + echo "- Multi-Architecture Manifests: SUCCESS" >> $GITHUB_STEP_SUMMARY + elif [[ "${{ needs.create-manifests.result }}" == "skipped" ]]; then + echo "- Multi-Architecture Manifests: SKIPPED" >> $GITHUB_STEP_SUMMARY + else + echo "- Multi-Architecture Manifests: FAILED" >> $GITHUB_STEP_SUMMARY + fi + + cat >> $GITHUB_STEP_SUMMARY << 'EOF' + + ### Architecture Support & Testing + - linux/amd64: ubuntu-22.04 (native testing) + - linux/arm64: ubuntu-22.04-arm (native testing) + + ### Images Built + - 18-3.5/bookworm: PostgreSQL 18beta1 + PostGIS 3.5 (Debian) + - 18-3.6/alpine3.22: PostgreSQL 18beta1 + PostGIS 3.6.0alpha1 (Alpine) + + ### Registry Configuration + EOF + + echo "- Primary Registry: ${{ env.REGISTRY }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY + + if [[ -n "${{ inputs.additional_registries }}" ]]; then + echo "- Additional Registries: ${{ inputs.additional_registries }}" >> $GITHUB_STEP_SUMMARY + else + echo "- Additional Registries: None" >> $GITHUB_STEP_SUMMARY + fi + + echo "- Push Images: ${{ inputs.push_images && 'Enabled' || 'Disabled' }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml new file mode 100644 index 000000000..2a333b4bf --- /dev/null +++ b/.github/workflows/update.yml @@ -0,0 +1,106 @@ +name: "update_dockerfiles" +# updating the image code and pushing to the local registry +on: + schedule: + - cron: '57 19 * * *' + workflow_dispatch: # Allow manual triggering + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + update_dockerfiles: + name: "update_dockerfiles" + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Fetch all history for all branches and tags + + - run: docker ps -a + - name: Login to dockerhub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + - run: pip3 install --upgrade pip + - run: pip3 install --upgrade lastversion check-jsonschema + - run: tools/install_manifest-tool.sh + - run: tools/environment_init.sh + - run: ./update.sh + - run: git status + - run: git diff versions.json + - run: check-jsonschema --schemafile versions.schema.json versions.json + + - name: Check if versions.json changed + id: version_check + run: | + if git diff --name-only | grep 'versions.json'; then + echo "versions_changed=true" >> $GITHUB_ENV + echo "versions_changed=true" + # Generate changed versions list + echo "versions_changed_list=$(./tools/get_versions_changes.sh)" >> $GITHUB_ENV + echo "versions_changed_list=$(./tools/get_versions_changes.sh)" + # Generate branch name with date and time + echo "BRANCH_NAME=updates/$(date +'%Y%m%d_%H%M')" >> $GITHUB_ENV + echo "BRANCH_NAME=updates/$(date +'%Y%m%d_%H%M')" + else + echo "versions.json not changed" + fi + + - name: Check for existing open PRs with label 'automated_pr' + if: env.versions_changed == 'true' + id: check_prs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + existing_prs=$(gh pr list --label automated_pr --json number --jq length) + if [ "$existing_prs" -eq "0" ]; then + echo "create_pr=true" >> $GITHUB_OUTPUT + else + echo "create_pr=false" >> $GITHUB_OUTPUT + echo "An automated PR already exists. Skipping PR creation." + fi + + # https://github.com/peter-evans/create-pull-request + - name: Create Pull Request + if: env.versions_changed == 'true' && steps.check_prs.outputs.create_pr == 'true' + id: create-pr + uses: peter-evans/create-pull-request@v7 + with: + committer: GitHub + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + commit-message: '🤖 Bump versions: ${{ env.versions_changed_list }}' + title: '🤖 Bump versions: ${{ env.versions_changed_list }}' + body: | + ## Automated Version Update + + This pull request was automatically generated by the `update_dockerfiles` workflow ( `.github/workflows/update.yml`) + to update docker-postgis versions.json and related Dockerfiles. + + ### Changes + ${{ env.versions_changed_list }} + + ### Important Notes + 1. **Verification Required**: Please carefully review the changes to ensure they are correct and appropriate. + 2. **PR Limit**: While this PR remains open, no new automated PRs will be created by this workflow. This ensures only one automated update is processed at a time. + + If you have any questions or concerns, please comment on this PR or contact the maintainers. + + labels: automated_pr + branch: ${{ env.BRANCH_NAME }} + delete-branch: true + + - name: Close and Reopen PR + if: steps.create-pr.outputs.pull-request-number + run: | + PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }} + gh pr close $PR_NUMBER --comment "Closing to trigger full CI/CD pipeline" + sleep 5 # Wait for 5 seconds to ensure the PR is fully closed + gh pr reopen $PR_NUMBER --comment "Reopening to trigger full CI/CD pipeline" + + - name: Comment PR + if: steps.create-pr.outputs.pull-request-number + run: | + PR_NUMBER=${{ steps.create-pr.outputs.pull-request-number }} + gh pr comment $PR_NUMBER --body "This PR was automatically created and reopened by the update_dockerfiles workflow to trigger the full CI/CD pipeline. Please review the changes carefully." diff --git a/.gitignore b/.gitignore index c43407444..70e8c3c68 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,9 @@ -_* \ No newline at end of file +.jq-template.awk +.template-helper-functions.jq +_* +.vscode/ +trivy_cache +tmp/ +_cache/ +venv-docker-postgis/ +tools/dive \ No newline at end of file diff --git a/.travis.yml.disabled b/.travis.yml.disabled deleted file mode 100644 index 1415e6fe3..000000000 --- a/.travis.yml.disabled +++ /dev/null @@ -1,44 +0,0 @@ ---- -language: bash -services: docker - -dist: xenial - -env: - - VERSION=13-master - - VERSION=13-3.0 - - VERSION=13-3.0 VARIANT=alpine - - VERSION=12-master - - VERSION=12-3.0 - - VERSION=12-3.0 VARIANT=alpine - - VERSION=12-2.5 - - VERSION=12-2.5 VARIANT=alpine - - VERSION=11-3.0 - - VERSION=11-3.0 VARIANT=alpine - - VERSION=11-2.5 - - VERSION=11-2.5 VARIANT=alpine - - VERSION=10-3.0 - - VERSION=10-3.0 VARIANT=alpine - - VERSION=10-2.5 - - VERSION=10-2.5 VARIANT=alpine - - VERSION=9.6-3.0 - - VERSION=9.6-3.0 VARIANT=alpine - - VERSION=9.6-2.5 - - VERSION=9.6-2.5 VARIANT=alpine - - VERSION=9.5-3.0 - - VERSION=9.5-3.0 VARIANT=alpine - - VERSION=9.5-2.5 - - VERSION=9.5-2.5 VARIANT=alpine - -jobs: - allow_failures: - - env: VERSION=12-master - - env: VERSION=13-master - -script: - - if [[ "$TRAVIS_PULL_REQUEST" == "false" && "$TRAVIS_BRANCH" == "master" ]]; then - echo "$DOCKERHUB_ACCESS_TOKEN" | docker login -u $DOCKERHUB_USERNAME --password-stdin && - make push ; - else - make test ; - fi diff --git a/11-3.3/Dockerfile b/11-3.3/Dockerfile deleted file mode 100644 index b09cd77e2..000000000 --- a/11-3.3/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:11-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.3.4+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 11 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.3.4+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/11-3.3/alpine/Dockerfile b/11-3.3/alpine/Dockerfile deleted file mode 100644 index 86b941650..000000000 --- a/11-3.3/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:11-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.3.4 spatial database extension with PostgreSQL 11 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.3.4 -ENV POSTGIS_SHA256 68507aa4ab7f9f7218fcefdcdd989911415e5f670128eb33acbbb362a24a998e - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/12-3.4/Dockerfile b/12-3.4/Dockerfile deleted file mode 100644 index b85e4fde5..000000000 --- a/12-3.4/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:12-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 12 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.4.0+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/12-3.4/alpine/Dockerfile b/12-3.4/alpine/Dockerfile deleted file mode 100644 index 9b0ce6aa5..000000000 --- a/12-3.4/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:12-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0 spatial database extension with PostgreSQL 12 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.4.0 -ENV POSTGIS_SHA256 3acdf303adfd58d73543a70e6ebe99af29301262c56cf32220d42caa3efab024 - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/13-3.3/alpine3.21/Dockerfile b/13-3.3/alpine3.21/Dockerfile new file mode 100644 index 000000000..018bfa79c --- /dev/null +++ b/13-3.3/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:13-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.3.8 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=cfb70d6229096d2474d79d097768dd19ef04a840 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.3.8" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.3.8" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/12-3.4/initdb-postgis.sh b/13-3.3/alpine3.21/initdb-postgis.sh similarity index 81% rename from 12-3.4/initdb-postgis.sh rename to 13-3.3/alpine3.21/initdb-postgis.sh index e38ad7d66..21f8c373d 100644 --- a/12-3.4/initdb-postgis.sh +++ b/13-3.3/alpine3.21/initdb-postgis.sh @@ -1,19 +1,19 @@ #!/bin/bash - +# shellcheck disable=SC2154 set -e # Perform all actions as $POSTGRES_USER export PGUSER="$POSTGRES_USER" # Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' +"${psql[@]}" <<-'EOSQL' CREATE DATABASE template_postgis IS_TEMPLATE true; EOSQL # Load PostGIS into both template_database and $POSTGRES_DB for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS postgis_topology; -- Reconnect to update pg_setting.resetval diff --git a/13-3.3/alpine3.21/tags b/13-3.3/alpine3.21/tags new file mode 100644 index 000000000..e0c9d84cf --- /dev/null +++ b/13-3.3/alpine3.21/tags @@ -0,0 +1 @@ +13-3.3-alpine3.21 13-3.3.8-alpine3.21 diff --git a/11-3.3/alpine/update-postgis.sh b/13-3.3/alpine3.21/update-postgis.sh similarity index 100% rename from 11-3.3/alpine/update-postgis.sh rename to 13-3.3/alpine3.21/update-postgis.sh diff --git a/13-3.4/Dockerfile b/13-3.4/Dockerfile deleted file mode 100644 index b20c0d9f7..000000000 --- a/13-3.4/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:13-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 13 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.4.0+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/13-3.4/alpine/Dockerfile b/13-3.4/alpine/Dockerfile deleted file mode 100644 index c8445b93e..000000000 --- a/13-3.4/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:13-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0 spatial database extension with PostgreSQL 13 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.4.0 -ENV POSTGIS_SHA256 3acdf303adfd58d73543a70e6ebe99af29301262c56cf32220d42caa3efab024 - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/13-3.4/alpine/initdb-postgis.sh b/13-3.4/alpine/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/13-3.4/alpine/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/13-3.4/alpine3.21/Dockerfile b/13-3.4/alpine3.21/Dockerfile new file mode 100644 index 000000000..117b3c7a3 --- /dev/null +++ b/13-3.4/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:13-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/12-3.4/alpine/initdb-postgis.sh b/13-3.4/alpine3.21/initdb-postgis.sh similarity index 81% rename from 12-3.4/alpine/initdb-postgis.sh rename to 13-3.4/alpine3.21/initdb-postgis.sh index e38ad7d66..21f8c373d 100644 --- a/12-3.4/alpine/initdb-postgis.sh +++ b/13-3.4/alpine3.21/initdb-postgis.sh @@ -1,19 +1,19 @@ #!/bin/bash - +# shellcheck disable=SC2154 set -e # Perform all actions as $POSTGRES_USER export PGUSER="$POSTGRES_USER" # Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' +"${psql[@]}" <<-'EOSQL' CREATE DATABASE template_postgis IS_TEMPLATE true; EOSQL # Load PostGIS into both template_database and $POSTGRES_DB for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS postgis_topology; -- Reconnect to update pg_setting.resetval diff --git a/13-3.4/alpine3.21/tags b/13-3.4/alpine3.21/tags new file mode 100644 index 000000000..7e94d0d91 --- /dev/null +++ b/13-3.4/alpine3.21/tags @@ -0,0 +1 @@ +13-3.4-alpine3.21 13-3.4.4-alpine3.21 diff --git a/11-3.3/update-postgis.sh b/13-3.4/alpine3.21/update-postgis.sh similarity index 100% rename from 11-3.3/update-postgis.sh rename to 13-3.4/alpine3.21/update-postgis.sh diff --git a/13-3.4/alpine3.22/Dockerfile b/13-3.4/alpine3.22/Dockerfile new file mode 100644 index 000000000..e4b5b93c9 --- /dev/null +++ b/13-3.4/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:13-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/11-3.3/initdb-postgis.sh b/13-3.4/alpine3.22/initdb-postgis.sh similarity index 81% rename from 11-3.3/initdb-postgis.sh rename to 13-3.4/alpine3.22/initdb-postgis.sh index e38ad7d66..21f8c373d 100644 --- a/11-3.3/initdb-postgis.sh +++ b/13-3.4/alpine3.22/initdb-postgis.sh @@ -1,19 +1,19 @@ #!/bin/bash - +# shellcheck disable=SC2154 set -e # Perform all actions as $POSTGRES_USER export PGUSER="$POSTGRES_USER" # Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' +"${psql[@]}" <<-'EOSQL' CREATE DATABASE template_postgis IS_TEMPLATE true; EOSQL # Load PostGIS into both template_database and $POSTGRES_DB for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS postgis_topology; -- Reconnect to update pg_setting.resetval diff --git a/13-3.4/alpine3.22/tags b/13-3.4/alpine3.22/tags new file mode 100644 index 000000000..007526bf5 --- /dev/null +++ b/13-3.4/alpine3.22/tags @@ -0,0 +1 @@ +13-3.4-alpine3.22 13-3.4.4-alpine3.22 13-3.4-alpine diff --git a/12-3.4/alpine/update-postgis.sh b/13-3.4/alpine3.22/update-postgis.sh similarity index 100% rename from 12-3.4/alpine/update-postgis.sh rename to 13-3.4/alpine3.22/update-postgis.sh diff --git a/13-3.4/initdb-postgis.sh b/13-3.4/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/13-3.4/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/13-3.5/alpine3.21/Dockerfile b/13-3.5/alpine3.21/Dockerfile new file mode 100644 index 000000000..926e950f8 --- /dev/null +++ b/13-3.5/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:13-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/11-3.3/alpine/initdb-postgis.sh b/13-3.5/alpine3.21/initdb-postgis.sh similarity index 81% rename from 11-3.3/alpine/initdb-postgis.sh rename to 13-3.5/alpine3.21/initdb-postgis.sh index e38ad7d66..21f8c373d 100644 --- a/11-3.3/alpine/initdb-postgis.sh +++ b/13-3.5/alpine3.21/initdb-postgis.sh @@ -1,19 +1,19 @@ #!/bin/bash - +# shellcheck disable=SC2154 set -e # Perform all actions as $POSTGRES_USER export PGUSER="$POSTGRES_USER" # Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' +"${psql[@]}" <<-'EOSQL' CREATE DATABASE template_postgis IS_TEMPLATE true; EOSQL # Load PostGIS into both template_database and $POSTGRES_DB for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' CREATE EXTENSION IF NOT EXISTS postgis; CREATE EXTENSION IF NOT EXISTS postgis_topology; -- Reconnect to update pg_setting.resetval diff --git a/13-3.5/alpine3.21/tags b/13-3.5/alpine3.21/tags new file mode 100644 index 000000000..feaaf4678 --- /dev/null +++ b/13-3.5/alpine3.21/tags @@ -0,0 +1 @@ +13-3.5-alpine3.21 13-3.5.3-alpine3.21 diff --git a/12-3.4/update-postgis.sh b/13-3.5/alpine3.21/update-postgis.sh similarity index 100% rename from 12-3.4/update-postgis.sh rename to 13-3.5/alpine3.21/update-postgis.sh diff --git a/13-3.5/alpine3.22/Dockerfile b/13-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..e7b0b301b --- /dev/null +++ b/13-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:13-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 13 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/13-3.5/alpine3.22/initdb-postgis.sh b/13-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/13-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/13-3.5/alpine3.22/tags b/13-3.5/alpine3.22/tags new file mode 100644 index 000000000..0aea81a6d --- /dev/null +++ b/13-3.5/alpine3.22/tags @@ -0,0 +1 @@ +13-3.5-alpine3.22 13-3.5.3-alpine3.22 13-3.5-alpine diff --git a/13-3.4/alpine/update-postgis.sh b/13-3.5/alpine3.22/update-postgis.sh similarity index 100% rename from 13-3.4/alpine/update-postgis.sh rename to 13-3.5/alpine3.22/update-postgis.sh diff --git a/13-3.5/bookworm/Dockerfile b/13-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..a1405ee02 --- /dev/null +++ b/13-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:13-bookworm +ARG PGIS1_POSTGRES_MAJOR=13 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/13-3.5/bookworm/initdb-postgis.sh b/13-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/13-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/13-3.5/bookworm/tags b/13-3.5/bookworm/tags new file mode 100644 index 000000000..68bb74be7 --- /dev/null +++ b/13-3.5/bookworm/tags @@ -0,0 +1 @@ +13-3.5-bookworm 13-3.5.3-bookworm 13-3.5 diff --git a/13-3.4/update-postgis.sh b/13-3.5/bookworm/update-postgis.sh similarity index 100% rename from 13-3.4/update-postgis.sh rename to 13-3.5/bookworm/update-postgis.sh diff --git a/13-3.5/bullseye/Dockerfile b/13-3.5/bullseye/Dockerfile new file mode 100644 index 000000000..518f11058 --- /dev/null +++ b/13-3.5/bullseye/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:13-bullseye +ARG PGIS1_POSTGRES_MAJOR=13 +ARG PGIS1_POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/13-3.5/bullseye/initdb-postgis.sh b/13-3.5/bullseye/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/13-3.5/bullseye/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/13-3.5/bullseye/tags b/13-3.5/bullseye/tags new file mode 100644 index 000000000..e73b91587 --- /dev/null +++ b/13-3.5/bullseye/tags @@ -0,0 +1 @@ +13-3.5-bullseye 13-3.5.2-bullseye diff --git a/14-3.4/alpine/update-postgis.sh b/13-3.5/bullseye/update-postgis.sh similarity index 100% rename from 14-3.4/alpine/update-postgis.sh rename to 13-3.5/bullseye/update-postgis.sh diff --git a/14-3.3/alpine3.21/Dockerfile b/14-3.3/alpine3.21/Dockerfile new file mode 100644 index 000000000..9d435b65e --- /dev/null +++ b/14-3.3/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:14-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.3.8 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=cfb70d6229096d2474d79d097768dd19ef04a840 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.3.8" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.3.8" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/14-3.3/alpine3.21/initdb-postgis.sh b/14-3.3/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.3/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.3/alpine3.21/tags b/14-3.3/alpine3.21/tags new file mode 100644 index 000000000..ee59f5760 --- /dev/null +++ b/14-3.3/alpine3.21/tags @@ -0,0 +1 @@ +14-3.3-alpine3.21 14-3.3.8-alpine3.21 diff --git a/14-3.4/update-postgis.sh b/14-3.3/alpine3.21/update-postgis.sh similarity index 100% rename from 14-3.4/update-postgis.sh rename to 14-3.3/alpine3.21/update-postgis.sh diff --git a/14-3.4/Dockerfile b/14-3.4/Dockerfile deleted file mode 100644 index 36d79b7fd..000000000 --- a/14-3.4/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:14-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 14 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.4.0+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/14-3.4/alpine/Dockerfile b/14-3.4/alpine/Dockerfile deleted file mode 100644 index ed36cfcaf..000000000 --- a/14-3.4/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:14-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0 spatial database extension with PostgreSQL 14 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.4.0 -ENV POSTGIS_SHA256 3acdf303adfd58d73543a70e6ebe99af29301262c56cf32220d42caa3efab024 - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/14-3.4/alpine/initdb-postgis.sh b/14-3.4/alpine/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/14-3.4/alpine/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/14-3.4/alpine3.21/Dockerfile b/14-3.4/alpine3.21/Dockerfile new file mode 100644 index 000000000..562526676 --- /dev/null +++ b/14-3.4/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:14-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/14-3.4/alpine3.21/initdb-postgis.sh b/14-3.4/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.4/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.4/alpine3.21/tags b/14-3.4/alpine3.21/tags new file mode 100644 index 000000000..ae61d44a4 --- /dev/null +++ b/14-3.4/alpine3.21/tags @@ -0,0 +1 @@ +14-3.4-alpine3.21 14-3.4.4-alpine3.21 diff --git a/15-3.4/alpine/update-postgis.sh b/14-3.4/alpine3.21/update-postgis.sh similarity index 100% rename from 15-3.4/alpine/update-postgis.sh rename to 14-3.4/alpine3.21/update-postgis.sh diff --git a/14-3.4/alpine3.22/Dockerfile b/14-3.4/alpine3.22/Dockerfile new file mode 100644 index 000000000..b051253ef --- /dev/null +++ b/14-3.4/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:14-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/14-3.4/alpine3.22/initdb-postgis.sh b/14-3.4/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.4/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.4/alpine3.22/tags b/14-3.4/alpine3.22/tags new file mode 100644 index 000000000..969e16bcd --- /dev/null +++ b/14-3.4/alpine3.22/tags @@ -0,0 +1 @@ +14-3.4-alpine3.22 14-3.4.4-alpine3.22 14-3.4-alpine diff --git a/15-3.4/update-postgis.sh b/14-3.4/alpine3.22/update-postgis.sh similarity index 100% rename from 15-3.4/update-postgis.sh rename to 14-3.4/alpine3.22/update-postgis.sh diff --git a/14-3.4/initdb-postgis.sh b/14-3.4/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/14-3.4/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/14-3.5/alpine3.21/Dockerfile b/14-3.5/alpine3.21/Dockerfile new file mode 100644 index 000000000..ae5a74512 --- /dev/null +++ b/14-3.5/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:14-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/14-3.5/alpine3.21/initdb-postgis.sh b/14-3.5/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.5/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.5/alpine3.21/tags b/14-3.5/alpine3.21/tags new file mode 100644 index 000000000..bba48bf67 --- /dev/null +++ b/14-3.5/alpine3.21/tags @@ -0,0 +1 @@ +14-3.5-alpine3.21 14-3.5.3-alpine3.21 diff --git a/15-master/update-postgis.sh b/14-3.5/alpine3.21/update-postgis.sh similarity index 100% rename from 15-master/update-postgis.sh rename to 14-3.5/alpine3.21/update-postgis.sh diff --git a/14-3.5/alpine3.22/Dockerfile b/14-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..22983afa9 --- /dev/null +++ b/14-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:14-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 14 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/14-3.5/alpine3.22/initdb-postgis.sh b/14-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.5/alpine3.22/tags b/14-3.5/alpine3.22/tags new file mode 100644 index 000000000..c5f2885c6 --- /dev/null +++ b/14-3.5/alpine3.22/tags @@ -0,0 +1 @@ +14-3.5-alpine3.22 14-3.5.3-alpine3.22 14-3.5-alpine diff --git a/16-3.4/alpine/update-postgis.sh b/14-3.5/alpine3.22/update-postgis.sh similarity index 100% rename from 16-3.4/alpine/update-postgis.sh rename to 14-3.5/alpine3.22/update-postgis.sh diff --git a/14-3.5/bookworm/Dockerfile b/14-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..3bdd2c63c --- /dev/null +++ b/14-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:14-bookworm +ARG PGIS1_POSTGRES_MAJOR=14 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/14-3.5/bookworm/initdb-postgis.sh b/14-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.5/bookworm/tags b/14-3.5/bookworm/tags new file mode 100644 index 000000000..6d9be9be5 --- /dev/null +++ b/14-3.5/bookworm/tags @@ -0,0 +1 @@ +14-3.5-bookworm 14-3.5.3-bookworm 14-3.5 diff --git a/16-3.4/update-postgis.sh b/14-3.5/bookworm/update-postgis.sh similarity index 100% rename from 16-3.4/update-postgis.sh rename to 14-3.5/bookworm/update-postgis.sh diff --git a/14-3.5/bullseye/Dockerfile b/14-3.5/bullseye/Dockerfile new file mode 100644 index 000000000..574b0977e --- /dev/null +++ b/14-3.5/bullseye/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:14-bullseye +ARG PGIS1_POSTGRES_MAJOR=14 +ARG PGIS1_POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/14-3.5/bullseye/initdb-postgis.sh b/14-3.5/bullseye/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-3.5/bullseye/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-3.5/bullseye/tags b/14-3.5/bullseye/tags new file mode 100644 index 000000000..ef08ff440 --- /dev/null +++ b/14-3.5/bullseye/tags @@ -0,0 +1 @@ +14-3.5-bullseye 14-3.5.2-bullseye diff --git a/16-master/update-postgis.sh b/14-3.5/bullseye/update-postgis.sh similarity index 100% rename from 16-master/update-postgis.sh rename to 14-3.5/bullseye/update-postgis.sh diff --git a/14-l3.1.9gcp/bookworm/Dockerfile b/14-l3.1.9gcp/bookworm/Dockerfile new file mode 100644 index 000000000..b788011ef --- /dev/null +++ b/14-l3.1.9gcp/bookworm/Dockerfile @@ -0,0 +1,673 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:14-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.1.9 +ARG PGIS1_GEOS_CHECKOUT=tags/3.6.6 +ARG PGIS1_GDAL_CHECKOUT=tags/v3.6.4 +ARG PGIS1_PROJ_CHECKOUT=tags/6.3.1 +ARG PGIS1_SFCGAL_CHECKOUT=tags/v1.5.1 +ARG PGIS1_CGAL_CHECKOUT=tags/v5.6 + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=95a641b1747721d7004c5f0133b918d034035319 +ARG PGIS1_GEOS_CHECKOUT_SHA1=36ea3034fb8719a639a7e7727e54ec8ab2e8a196 +ARG PGIS1_GDAL_CHECKOUT_SHA1=7ca88116f5a46d429251361634eb24629f315076 +ARG PGIS1_PROJ_CHECKOUT_SHA1=0e993d9744ecaa2f146bf62c43aecc61809a43ef +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=61f3b08ade49493b56c6bafa98c7c1f84addbc10 +ARG PGIS1_CGAL_CHECKOUT_SHA1=de4fa0d7d57b5a997012f2804161386ff4bc0d0f + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=minimal +# Minimal GDAL build ; no arrow, no parquet, no extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=minimal" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + +# + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ +# minimal GDAL build .. + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 14-l3.1.9gcp spatial database extension with PostgreSQL 14 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="14-l3.1.9gcp" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 14-l3.1.9gcp spatial database extension with PostgreSQL 14 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="14-l3.1.9gcp" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# minimal GDAL build; so no need extra dependencies + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/14-l3.1.9gcp/bookworm/initdb-postgis.sh b/14-l3.1.9gcp/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/14-l3.1.9gcp/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/14-l3.1.9gcp/bookworm/tags b/14-l3.1.9gcp/bookworm/tags new file mode 100644 index 000000000..43c6f2788 --- /dev/null +++ b/14-l3.1.9gcp/bookworm/tags @@ -0,0 +1 @@ +14-l3.1.9gcp-bookworm 14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm diff --git a/update-postgis.sh b/14-l3.1.9gcp/bookworm/update-postgis.sh similarity index 100% rename from update-postgis.sh rename to 14-l3.1.9gcp/bookworm/update-postgis.sh diff --git a/15-3.3/alpine3.21/Dockerfile b/15-3.3/alpine3.21/Dockerfile new file mode 100644 index 000000000..a557898d8 --- /dev/null +++ b/15-3.3/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:15-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.3.8 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=cfb70d6229096d2474d79d097768dd19ef04a840 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.3.8" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.3.8" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/15-3.3/alpine3.21/initdb-postgis.sh b/15-3.3/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.3/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.3/alpine3.21/tags b/15-3.3/alpine3.21/tags new file mode 100644 index 000000000..6f838a72c --- /dev/null +++ b/15-3.3/alpine3.21/tags @@ -0,0 +1 @@ +15-3.3-alpine3.21 15-3.3.8-alpine3.21 diff --git a/15-3.3/alpine3.21/update-postgis.sh b/15-3.3/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.3/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.4/Dockerfile b/15-3.4/Dockerfile deleted file mode 100644 index 05fd64114..000000000 --- a/15-3.4/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:15-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 15 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.4.0+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/15-3.4/alpine/Dockerfile b/15-3.4/alpine/Dockerfile deleted file mode 100644 index 21f1cd275..000000000 --- a/15-3.4/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:15-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0 spatial database extension with PostgreSQL 15 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.4.0 -ENV POSTGIS_SHA256 3acdf303adfd58d73543a70e6ebe99af29301262c56cf32220d42caa3efab024 - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/15-3.4/alpine/initdb-postgis.sh b/15-3.4/alpine/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/15-3.4/alpine/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/15-3.4/alpine3.21/Dockerfile b/15-3.4/alpine3.21/Dockerfile new file mode 100644 index 000000000..bc3efd664 --- /dev/null +++ b/15-3.4/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:15-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/15-3.4/alpine3.21/initdb-postgis.sh b/15-3.4/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.4/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.4/alpine3.21/tags b/15-3.4/alpine3.21/tags new file mode 100644 index 000000000..effe2085b --- /dev/null +++ b/15-3.4/alpine3.21/tags @@ -0,0 +1 @@ +15-3.4-alpine3.21 15-3.4.4-alpine3.21 diff --git a/15-3.4/alpine3.21/update-postgis.sh b/15-3.4/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.4/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.4/alpine3.22/Dockerfile b/15-3.4/alpine3.22/Dockerfile new file mode 100644 index 000000000..b0d46e954 --- /dev/null +++ b/15-3.4/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:15-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/15-3.4/alpine3.22/initdb-postgis.sh b/15-3.4/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.4/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.4/alpine3.22/tags b/15-3.4/alpine3.22/tags new file mode 100644 index 000000000..384e3bae3 --- /dev/null +++ b/15-3.4/alpine3.22/tags @@ -0,0 +1 @@ +15-3.4-alpine3.22 15-3.4.4-alpine3.22 15-3.4-alpine diff --git a/15-3.4/alpine3.22/update-postgis.sh b/15-3.4/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.4/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.4/initdb-postgis.sh b/15-3.4/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/15-3.4/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/15-3.5/alpine3.21/Dockerfile b/15-3.5/alpine3.21/Dockerfile new file mode 100644 index 000000000..21769f1cf --- /dev/null +++ b/15-3.5/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:15-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/15-3.5/alpine3.21/initdb-postgis.sh b/15-3.5/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.5/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.5/alpine3.21/tags b/15-3.5/alpine3.21/tags new file mode 100644 index 000000000..b3f5aa56a --- /dev/null +++ b/15-3.5/alpine3.21/tags @@ -0,0 +1 @@ +15-3.5-alpine3.21 15-3.5.3-alpine3.21 diff --git a/15-3.5/alpine3.21/update-postgis.sh b/15-3.5/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.5/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.5/alpine3.22/Dockerfile b/15-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..400075e38 --- /dev/null +++ b/15-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:15-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 15 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/15-3.5/alpine3.22/initdb-postgis.sh b/15-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.5/alpine3.22/tags b/15-3.5/alpine3.22/tags new file mode 100644 index 000000000..6c8c94009 --- /dev/null +++ b/15-3.5/alpine3.22/tags @@ -0,0 +1 @@ +15-3.5-alpine3.22 15-3.5.3-alpine3.22 15-3.5-alpine diff --git a/15-3.5/alpine3.22/update-postgis.sh b/15-3.5/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.5/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.5/bookworm/Dockerfile b/15-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..7fc958aed --- /dev/null +++ b/15-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:15-bookworm +ARG PGIS1_POSTGRES_MAJOR=15 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/15-3.5/bookworm/initdb-postgis.sh b/15-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.5/bookworm/tags b/15-3.5/bookworm/tags new file mode 100644 index 000000000..78091337f --- /dev/null +++ b/15-3.5/bookworm/tags @@ -0,0 +1 @@ +15-3.5-bookworm 15-3.5.3-bookworm 15-3.5 diff --git a/15-3.5/bookworm/update-postgis.sh b/15-3.5/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.5/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-3.5/bullseye/Dockerfile b/15-3.5/bullseye/Dockerfile new file mode 100644 index 000000000..f38055051 --- /dev/null +++ b/15-3.5/bullseye/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:15-bullseye +ARG PGIS1_POSTGRES_MAJOR=15 +ARG PGIS1_POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/15-3.5/bullseye/initdb-postgis.sh b/15-3.5/bullseye/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/15-3.5/bullseye/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/15-3.5/bullseye/tags b/15-3.5/bullseye/tags new file mode 100644 index 000000000..e52a90c4f --- /dev/null +++ b/15-3.5/bullseye/tags @@ -0,0 +1 @@ +15-3.5-bullseye 15-3.5.2-bullseye diff --git a/15-3.5/bullseye/update-postgis.sh b/15-3.5/bullseye/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/15-3.5/bullseye/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/15-master/Dockerfile b/15-master/Dockerfile deleted file mode 100644 index 8a20da1b3..000000000 --- a/15-master/Dockerfile +++ /dev/null @@ -1,462 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -# "Experimental"; solely for testing purposes. Anticipate frequent changes! -# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. - -ARG DOCKER_CMAKE_BUILD_TYPE=Release -ARG CGAL_GIT_BRANCH=5.6.x-branch -FROM postgres:15-bullseye as builder - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL 15 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -WORKDIR / - -# apt-get install -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic1.74.0 \ - libboost-chrono1.74.0 \ - libboost-date-time1.74.0 \ - libboost-filesystem1.74.0 \ - libboost-program-options1.74.0 \ - libboost-serialization1.74.0 \ - libboost-system1.74.0 \ - libboost-test1.74.0 \ - libboost-thread1.74.0 \ - libboost-timer1.74.0 \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # build dependency - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libpq-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - make \ - pkg-config \ - protobuf-c-compiler \ - xsltproc \ - # gdal+ - libblosc-dev \ - libcfitsio-dev \ - libfreexl-dev \ - libfyba-dev \ - libhdf5-dev \ - libkml-dev \ - liblz4-dev \ - liblzma-dev \ - libopenjp2-7-dev \ - libqhull-dev \ - libwebp-dev \ - libzstd-dev - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -# cgal & sfcgal -# By utilizing the latest commit of the CGAL 5.x.x-branch and implementing a header-only build for SFCGAL, -# one can benefit from the latest CGAL patches while avoiding compatibility issues. -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH 3c8e2053721271119499506ea1d8a49dee89e30c -ENV SFCGAL_GIT_HASH fc4dc5640e402c8b00426b5a3562324226725df9 -RUN set -ex \ - && mkdir -p /usr/src \ - && cd /usr/src \ - && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ - && cd cgal \ - && git checkout ${CGAL5X_GIT_HASH} \ - && git log -1 > /_pgis_cgal_last_commit.txt \ - && cd /usr/src \ - && git clone https://gitlab.com/Oslandia/SFCGAL.git \ - && cd SFCGAL \ - && git checkout ${SFCGAL_GIT_HASH} \ - && git log -1 > /_pgis_sfcgal_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. \ - -DCGAL_DIR=/usr/src/cgal \ - -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ - -DSFCGAL_BUILD_BENCH=OFF \ - -DSFCGAL_BUILD_EXAMPLES=OFF \ - -DSFCGAL_BUILD_TESTS=OFF \ - -DSFCGAL_WITH_OSG=OFF \ - && make -j$(nproc) \ - && make install \ - # - ## testing with -DSFCGAL_BUILD_TESTS=ON - # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ - # - # clean - && rm -fr /usr/src/SFCGAL \ - && rm -fr /usr/src/cgal - -# proj -ENV PROJ_GIT_HASH d4ebd920c1e1ecd0e192790ab4fdb98c7b982176 -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/PROJ.git \ - && cd PROJ \ - && git checkout ${PROJ_GIT_HASH} \ - && git log -1 > /_pgis_proj_last_commit.txt \ - # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 - && if [ -f "autogen.sh" ] ; then \ - set -eux \ - && echo "autotools version: 'autogen.sh' exists! Older version!" \ - && ./autogen.sh \ - && ./configure --disable-static \ - && make -j$(nproc) \ - && make install \ - ; \ - else \ - set -eux \ - && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ - && mkdir build \ - && cd build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - ; \ - fi \ - \ - && rm -fr /usr/src/PROJ - -# geos -ENV GEOS_GIT_HASH 1033161eca3684e0d9479daeafd35a4e0fb1800e -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/libgeos/geos.git \ - && cd geos \ - && git checkout ${GEOS_GIT_HASH} \ - && git log -1 > /_pgis_geos_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/geos - -# gdal -ENV GDAL_GIT_HASH 43e51bc48e7d48795ae60731ddc1414611ec5d3e -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/gdal.git \ - && cd gdal \ - && git checkout ${GDAL_GIT_HASH} \ - && git log -1 > /_pgis_gdal_last_commit.txt \ - \ - # gdal project directory structure - has been changed ! - && if [ -d "gdal" ] ; then \ - echo "Directory 'gdal' dir exists -> older version!" ; \ - cd gdal ; \ - else \ - echo "Directory 'gdal' does not exists! Newer version! " ; \ - fi \ - \ - && if [ -f "./autogen.sh" ]; then \ - # Building with autoconf ( old/deprecated ) - set -eux \ - && ./autogen.sh \ - && ./configure --disable-static \ - ; \ - else \ - # Building with cmake - set -eux \ - && mkdir build \ - && cd build \ - # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - -DBUILD_DOCS=OFF \ - \ - -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ - -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ - -DGDAL_USE_BLOSC=ON \ - -DGDAL_USE_CFITSIO=ON \ - -DGDAL_USE_CURL=ON \ - -DGDAL_USE_DEFLATE=ON \ - -DGDAL_USE_EXPAT=ON \ - -DGDAL_USE_FREEXL=ON \ - -DGDAL_USE_FYBA=ON \ - -DGDAL_USE_GEOS=ON \ - -DGDAL_USE_HDF5=ON \ - -DGDAL_USE_JSONC=ON \ - -DGDAL_USE_LERC_INTERNAL=ON \ - -DGDAL_USE_LIBKML=ON \ - -DGDAL_USE_LIBLZMA=ON \ - -DGDAL_USE_LZ4=ON \ - -DGDAL_USE_OPENJPEG=ON \ - -DGDAL_USE_POSTGRESQL=ON \ - -DGDAL_USE_QHULL=ON \ - -DGDAL_USE_SQLITE3=ON \ - -DGDAL_USE_TIFF=ON \ - -DGDAL_USE_WEBP=ON \ - -DGDAL_USE_ZSTD=ON \ - \ - # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 - # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ - -DGDAL_USE_ECW=OFF \ - -DGDAL_USE_GEOTIFF=OFF \ - -DGDAL_USE_HEIF=OFF \ - -DGDAL_USE_SPATIALITE=OFF \ - ; \ - fi \ - \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/gdal - -# Minimal command line test. -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - && pcre-config --version - -# ------------------------------------------- -# STAGE final -# ------------------------------------------- -FROM postgres:15-bullseye - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic1.74.0 \ - libboost-chrono1.74.0 \ - libboost-date-time1.74.0 \ - libboost-filesystem1.74.0 \ - libboost-program-options1.74.0 \ - libboost-serialization1.74.0 \ - libboost-system1.74.0 \ - libboost-test1.74.0 \ - libboost-thread1.74.0 \ - libboost-timer1.74.0 \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libpcre3 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # gdal+ - libblosc1 \ - libcfitsio9 \ - libfreexl1 \ - libfyba0 \ - libhdf5-103-1 \ - libkmlbase1 \ - libkmldom1 \ - libkmlengine1 \ - libopenjp2-7 \ - libqhull-r8.0 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=builder /_pgis*.* / -COPY --from=builder /usr/local /usr/local - -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH 3c8e2053721271119499506ea1d8a49dee89e30c -ENV SFCGAL_GIT_HASH fc4dc5640e402c8b00426b5a3562324226725df9 -ENV PROJ_GIT_HASH d4ebd920c1e1ecd0e192790ab4fdb98c7b982176 -ENV GEOS_GIT_HASH 1033161eca3684e0d9479daeafd35a4e0fb1800e -ENV GDAL_GIT_HASH 43e51bc48e7d48795ae60731ddc1414611ec5d3e - -# Minimal command line test ( fail fast ) -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Testing ogr2ogr PostgreSQL driver. - && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ - || echo "ogr2ogr missing PostgreSQL driver" && exit 1 - -# install postgis -ENV POSTGIS_GIT_HASH d7b58458ea7cf8157d09f59e955820d3a4321892 - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcunit1-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && cd \ - # postgis - && cd /usr/src/ \ - && git clone https://github.com/postgis/postgis.git \ - && cd postgis \ - && git checkout ${POSTGIS_GIT_HASH} \ - && git log -1 > /_pgis_last_commit.txt \ - && ./autogen.sh \ -# configure options taken from: -# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ -# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# regress check - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && ldconfig \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apt-get purge -y --autoremove \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - -# last final test -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Is the "ca-certificates" package installed? (for accessing remote raster files) - # https://github.com/postgis/docker-postgis/issues/307 - && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ - \ - # list last commits. - && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ - # list postgresql, postgis version - && cat _pgis_full_version.txt diff --git a/15-master/initdb-postgis.sh b/15-master/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/15-master/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/16-3.3/alpine3.21/Dockerfile b/16-3.3/alpine3.21/Dockerfile new file mode 100644 index 000000000..ba979dc61 --- /dev/null +++ b/16-3.3/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:16-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.3.8 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=cfb70d6229096d2474d79d097768dd19ef04a840 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.3.8" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.3.8" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/16-3.3/alpine3.21/initdb-postgis.sh b/16-3.3/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.3/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.3/alpine3.21/tags b/16-3.3/alpine3.21/tags new file mode 100644 index 000000000..2c98c09a9 --- /dev/null +++ b/16-3.3/alpine3.21/tags @@ -0,0 +1 @@ +16-3.3-alpine3.21 16-3.3.8-alpine3.21 diff --git a/16-3.3/alpine3.21/update-postgis.sh b/16-3.3/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.3/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.4/Dockerfile b/16-3.4/Dockerfile deleted file mode 100644 index 0d16c535a..000000000 --- a/16-3.4/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -FROM postgres:16-bullseye - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0+dfsg-1.pgdg110+1 spatial database extension with PostgreSQL 16 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR 3 -ENV POSTGIS_VERSION 3.4.0+dfsg-1.pgdg110+1 - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/16-3.4/alpine/Dockerfile b/16-3.4/alpine/Dockerfile deleted file mode 100644 index 5fb7cc3cd..000000000 --- a/16-3.4/alpine/Dockerfile +++ /dev/null @@ -1,124 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# -ARG BASE_IMAGE=postgres:16-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS 3.4.0 spatial database extension with PostgreSQL 16 Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION 3.4.0 -ENV POSTGIS_SHA256 3acdf303adfd58d73543a70e6ebe99af29301262c56cf32220d42caa3efab024 - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/16-3.4/alpine/initdb-postgis.sh b/16-3.4/alpine/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/16-3.4/alpine/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/16-3.4/alpine3.21/Dockerfile b/16-3.4/alpine3.21/Dockerfile new file mode 100644 index 000000000..b8b6b993a --- /dev/null +++ b/16-3.4/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:16-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/16-3.4/alpine3.21/initdb-postgis.sh b/16-3.4/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.4/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.4/alpine3.21/tags b/16-3.4/alpine3.21/tags new file mode 100644 index 000000000..a47b0b923 --- /dev/null +++ b/16-3.4/alpine3.21/tags @@ -0,0 +1 @@ +16-3.4-alpine3.21 16-3.4.4-alpine3.21 diff --git a/16-3.4/alpine3.21/update-postgis.sh b/16-3.4/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.4/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.4/alpine3.22/Dockerfile b/16-3.4/alpine3.22/Dockerfile new file mode 100644 index 000000000..d6b9e62aa --- /dev/null +++ b/16-3.4/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:16-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/16-3.4/alpine3.22/initdb-postgis.sh b/16-3.4/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.4/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.4/alpine3.22/tags b/16-3.4/alpine3.22/tags new file mode 100644 index 000000000..0a3e028dc --- /dev/null +++ b/16-3.4/alpine3.22/tags @@ -0,0 +1 @@ +16-3.4-alpine3.22 16-3.4.4-alpine3.22 16-3.4-alpine diff --git a/16-3.4/alpine3.22/update-postgis.sh b/16-3.4/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.4/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.4/initdb-postgis.sh b/16-3.4/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/16-3.4/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/16-3.5-bundle0/bookworm/Dockerfile b/16-3.5-bundle0/bookworm/Dockerfile new file mode 100644 index 000000000..dd41470c9 --- /dev/null +++ b/16-3.5-bundle0/bookworm/Dockerfile @@ -0,0 +1,369 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.bundle0.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +# Experimental Geo Bundle package. +# This is a work in progress and not yet ready for production. +# Some packages will be removed from this bundle and others will be added. +# The goal is to have a bundle that includes all the most popular extensions with PostGIS + +# set the base image , make build-* is overwriting with the actual value ! + +ARG REGISTRY=docker.io +ARG REPO_NAME=imresamu +ARG IMAGE_NAME=postgis-amd64 + +ARG PGIS1_BASE_IMAGE=${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:16-3.5-bookworm + +ARG PGIS1_PGSQL_GZIP_REPOSITORY=https://github.com/pramsey/pgsql-gzip.git +ARG PGIS1_PGSQL_GZIP_CHECKOUT=tags/v1.0.0 +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1=7c26e8b0056631ec0bb7c8fdd9bf2a24076e4a49 + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY=https://github.com/ossc-db/pg_hint_plan.git +ARG PGIS1_PG_HINT_PLAN_CHECKOUT=tags/REL16_1_6_1 +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1=54b4b0358a6c96dc80b2b836bba50937415753b6 + +ARG PGIS1_DUCKDB_CHECKOUT=tags/v1.3.1 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} AS builder + +ARG PGIS1_DUCKDB_CHECKOUT +ARG PGIS1_OPTIMIZATION_FLAGS + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + curl \ + flex \ + g++ \ + git \ + make \ + pgxnclient \ + postgresql-server-dev-$PG_MAJOR \ + unzip \ + wget \ + # pgsql-gzip + zlib1g-dev \ + # sqlite_fdw + sqlite3 \ + # bytemagic + libmagic-dev \ + # pgsoudium \ + libsodium-dev \ + # pg_curl + libcurl4-gnutls-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +FROM builder as builder-gzip + +ARG PGIS1_PGSQL_GZIP_REPOSITORY +ARG PGIS1_PGSQL_GZIP_CHECKOUT +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1 + +RUN set -eux \ + && mkdir -p /pgsql-gzip \ + && cd pgsql-gzip \ + && git init \ + && git remote add origin ${PGIS1_PGSQL_GZIP_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PGSQL_GZIP_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PGSQL_GZIP_CHECKOUT_SHA1" ]; then exit 1; fi \ + && git log -1 > /_pgsql_gzip_last_commit.txt \ + && make -j$(nproc) \ + && make install + + +FROM builder as builder-pgxn + +RUN pgxn install --verbose byteamagic +RUN pgxn install --verbose ddlx +RUN pgxn install --verbose dsef +RUN pgxn install --verbose json_accessors +RUN pgxn install --verbose lostgis +RUN pgxn install --verbose permuteseq +RUN pgxn install --verbose pg_curl # https://github.com/RekGRpth/pg_curl +RUN pgxn install --verbose pg_roaringbitmap +RUN pgxn install --verbose pg_rowalesce +RUN pgxn install --verbose pg_uuidv7 +RUN pgxn install --verbose pg_xenophile +RUN pgxn install --verbose pg_xxhash +RUN pgxn install --verbose pgsodium +RUN pgxn install --verbose pgsql_tweaks +# RUN pgxn install --verbose sqlite_fdw + +# pg_duckdb +RUN set -eux \ + && curl -sfL https://install.pgx.sh -o /tmp/pgx-install.sh \ + && chmod +x /tmp/pgx-install.sh \ + && /tmp/pgx-install.sh \ + && rm /tmp/pgx-install.sh +RUN pgxman install pg_duckdb + +#RUN pgxman install hydra_columnar +#RUN pgxman install pgvectorscale +#RUN pgxman install pg_quack + +FROM builder as builder-other + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY +ARG PGIS1_PG_HINT_PLAN_CHECKOUT +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1 + +# install pg_hint_plan +RUN set -eux \ + && mkdir pg_hint_plan \ + && cd pg_hint_plan \ + && git init \ + && git remote add origin ${PGIS1_PG_HINT_PLAN_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PG_HINT_PLAN_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1" ]; then exit 1; fi \ + && make -j$(nproc) \ + && make install + +RUN set -eux \ + && git clone --depth 1 https://github.com/NikolayS/postgres_dba.git \ + && cd postgres_dba \ + && rm -rf .git + +RUN set -eux \ + && git clone --depth 1 https://github.com/dr-jts/pg_svg.git \ + && cd pg_svg \ + && rm -rf .git + #install: psql < /pg_svg/pg-svg-lib.sql + +FROM ${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:16-3.5-bookworm + +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_TIMESCALEDB_TELEMETRY + +# Export build environment for child images (enterprise-grade package version locking) +RUN set -eux \ + # Ensure docker-postgis-env.sh exists (create empty if missing) + && touch /usr/local/share/docker-postgis-env.sh \ + # Export bundle-specific build versions for child images + && echo "# Bundle0 Extension Versions" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_OPTIMIZATION_FLAGS='${PGIS1_OPTIMIZATION_FLAGS}'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PG_HINT_PLAN_CHECKOUT='tags/REL16_1_6_1'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_DUCKDB_CHECKOUT='tags/v1.3.1'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PGSQL_GZIP_CHECKOUT='tags/v1.0.0'" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + # Source the environment after populating it + && . /usr/local/share/docker-postgis-env.sh + +# Only override opencontainers labels for bundle-specific info +# org.postgis.base.* labels are inherited from base image and should NOT be overridden +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS Bundle - 16-3.5-bookworm with MobilityDB, TimescaleDB, DuckDB and 40+ extensions" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3+dfsg-1~exp1.pgdg120+1-bundle0" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # Bundle-specific additional extensions (base PostGIS extensions inherited from org.postgis.base.extensions) + org.postgis.bundle0.additional.extensions="timescaledb,mobilitydb,pgsql_http,pgsql_gzip,pgrouting,pgvector,h3,pointcloud,pgaudit,byteamagic,ddlx,dsef,json_accessors,lostgis,permuteseq,pg_curl,pg_roaringbitmap,pg_rowalesce,pg_uuidv7,pg_xenophile,pg_xxhash,pgsodium,pgsql_tweaks,sqlite_fdw,age,decoderbufs,asn1oid,extra_window_functions,first_last_agg,hll,hypopg,icu_ext,jsquery,numeral,ogr_fdw,partman,periods,pg_fact_loader,pg_failover_slots,pg_stat_kcache,pg_wait_sampling,pgl_ddl_deploy,pglogical,pgmp,pgpcre,pgq3,pgsphere,pgtap,pldebugger,plpgsql_check,prefix,prioritize,q3c,repack,rum,show_plans,squeeze" \ + org.postgis.bundle0.permanently.excluded="parray_gin,pg_quack" \ + org.postgis.bundle0.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.bundle0.timescaledb.telemetry="${PGIS1_TIMESCALEDB_TELEMETRY}" \ + org.postgis.bundle0.duckdb.version="tags/v1.3.1" + +# install all utf8 locales; +# helping: https://github.com/docker-library/docs/tree/master/postgres#locale-customization +RUN set -eux \ + && sed -i -e 's/# \(.*\.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + \ + bzip2 \ + curl \ + jq \ + unzip \ + wget \ + \ + gdal-bin \ + proj-bin \ + sqlite3 \ + \ + pipx \ + python-is-python3 \ + python3 \ + python3-geoalchemy2 \ + python3-pglast \ + python3-pip \ + python3-psycopg2 \ + python3-setuptools \ + python3-sqlalchemy \ + \ + postgis \ + postgresql \ + postgresql-client-common \ + postgresql-common \ + postgresql-contrib \ + postgresql-plpython3-$PG_MAJOR \ + postgresql-postgis \ + postgresql-postgis-scripts \ + \ + pg-activity \ + pgbackrest \ + pgbadger \ + pgtap \ + pgtop \ + pspg \ + vip-manager \ + \ + # add any exceptions for PG17 or PPG16 here + # PostgreSQL 16 and earlier packages + \ + postgresql-$PG_MAJOR-age \ + postgresql-$PG_MAJOR-asn1oid \ + postgresql-$PG_MAJOR-auto-failover \ + postgresql-$PG_MAJOR-credcheck \ + postgresql-$PG_MAJOR-cron \ + postgresql-$PG_MAJOR-decoderbufs \ + postgresql-$PG_MAJOR-extra-window-functions \ + postgresql-$PG_MAJOR-first-last-agg \ + postgresql-$PG_MAJOR-h3 \ + postgresql-$PG_MAJOR-hll \ + postgresql-$PG_MAJOR-http \ + postgresql-$PG_MAJOR-hypopg \ + postgresql-$PG_MAJOR-icu-ext \ + postgresql-$PG_MAJOR-jsquery \ + postgresql-$PG_MAJOR-mobilitydb \ + postgresql-$PG_MAJOR-numeral \ + postgresql-$PG_MAJOR-ogr-fdw \ + postgresql-$PG_MAJOR-partman \ + postgresql-$PG_MAJOR-periods \ + postgresql-$PG_MAJOR-pg-fact-loader \ + postgresql-$PG_MAJOR-pg-failover-slots \ + postgresql-$PG_MAJOR-pg-stat-kcache \ + postgresql-$PG_MAJOR-pg-wait-sampling \ + postgresql-$PG_MAJOR-pgaudit \ + postgresql-$PG_MAJOR-pgl-ddl-deploy \ + postgresql-$PG_MAJOR-pglogical \ + postgresql-$PG_MAJOR-pgmp \ + postgresql-$PG_MAJOR-pgpcre \ + postgresql-$PG_MAJOR-pgq3 \ + postgresql-$PG_MAJOR-pgrouting \ + postgresql-$PG_MAJOR-pgrouting-scripts \ + postgresql-$PG_MAJOR-pgsphere \ + postgresql-$PG_MAJOR-pgtap \ + postgresql-$PG_MAJOR-pgvector \ + postgresql-$PG_MAJOR-pldebugger \ + postgresql-$PG_MAJOR-plpgsql-check \ + postgresql-$PG_MAJOR-pointcloud \ + postgresql-$PG_MAJOR-prefix \ + postgresql-$PG_MAJOR-prioritize \ + postgresql-$PG_MAJOR-q3c \ + postgresql-$PG_MAJOR-repack \ + postgresql-$PG_MAJOR-rum \ + postgresql-$PG_MAJOR-show-plans \ + postgresql-$PG_MAJOR-squeeze \ + postgresql-$PG_MAJOR-timescaledb \ + # MeCab based tokenizer for pgdg-pgroonga + groonga-tokenizer-mecab \ + # bytemagic + libmagic1 libmagic-mgc \ + # pgsodium + libsodium23 \ + \ + && rm -Rf /root/.cache/pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_DUCKDB_CHECKOUT +ENV PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT} +RUN arch=$(uname -m) \ + && DUCKDB_VERSION=$(echo "$PGIS1_DUCKDB_CHECKOUT" | sed -E 's|^.*/||; s|^tags/||; s|^v||') \ + && echo "DUCKDB_VERSION=${DUCKDB_VERSION}" \ + && echo "PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT}" \ + && case "$arch" in \ + x86_64) \ + duck_binary="duckdb_cli-linux-amd64.zip" ;; \ + aarch64) \ + duck_binary="duckdb_cli-linux-arm64.zip" ;; \ + *) \ + echo "Unsupported architecture: $arch"; exit 1 ;; \ + esac \ + && wget https://github.com/duckdb/duckdb/releases/download/v${DUCKDB_VERSION}/$duck_binary \ + && unzip $duck_binary -d /usr/local/bin \ + && rm $duck_binary \ + && duckdb --version + +# install duckdb extensions +ENV DUCKDB_EXTENSIONS="excel fts httpfs inet postgres_scanner spatial sqlite_scanner tpcds tpch" +RUN for e in ${DUCKDB_EXTENSIONS} ; do \ + echo "Installing $e ..."; \ + if duckdb -c "INSTALL $e;" 2>&1 | tee /tmp/duckdb-install-$e.log; then \ + echo "Successfully installed $e"; \ + echo "LOAD $e;" >> $HOME/.duckdbrc; \ + else \ + echo "Failed to install $e, check /tmp/duckdb-install-$e.log"; \ + fi; \ + done \ + # Add core extensions to .duckdbrc (these are built-in) + && echo "LOAD autocomplete;" >> $HOME/.duckdbrc \ + && echo "LOAD icu;" >> $HOME/.duckdbrc \ + && echo "LOAD json;" >> $HOME/.duckdbrc \ + && echo "LOAD parquet;" >> $HOME/.duckdbrc + +# Install from stages +COPY --from=builder-gzip /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-gzip /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-pgxn /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-pgxn /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-other /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /postgres_dba /postgres_dba +COPY --from=builder-other /pg_svg /pg_svg + +# check any missing dependencies +RUN set -eux \ + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true + +# multiple LLVM existance is not optimal; so we give a warning. +# known problem: duplicated LLVM +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "WARNING: More than one llvm package or none at all found!"; \ + dpkg -l | grep llvm ; \ + fi + +# add MobilityDB requirements +RUN set -eux \ + && cp -v /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample.orig; \ + # add MobilityDB and TimescaleDB requirements + echo "shared_preload_libraries = 'postgis-3,pg_stat_statements,timescaledb'" >> /usr/share/postgresql/postgresql.conf.sample ; \ + # MobilityDB recomendation + echo "max_locks_per_transaction = 128" >> /usr/share/postgresql/postgresql.conf.sample; \ + echo "timescaledb.telemetry_level=off" >> /usr/share/postgresql/postgresql.conf.sample + +# for postgres_dba Use ":dba" to see menu +RUN printf "%s %s %s %s\n" \\set dba \'\\\\i /postgres_dba/start.psql\' >> ~/.psqlrc + +COPY ./initdb-bundle0.sh /docker-entrypoint-initdb.d/11_bundle0.sh diff --git a/16-3.5-bundle0/bookworm/initdb-bundle0.sh b/16-3.5-bundle0/bookworm/initdb-bundle0.sh new file mode 100644 index 000000000..5f2c5d116 --- /dev/null +++ b/16-3.5-bundle0/bookworm/initdb-bundle0.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# install pg-svg-lib +"${psql[@]}" /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/16-3.5/alpine3.21/initdb-postgis.sh b/16-3.5/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.5/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.5/alpine3.21/tags b/16-3.5/alpine3.21/tags new file mode 100644 index 000000000..0091e1098 --- /dev/null +++ b/16-3.5/alpine3.21/tags @@ -0,0 +1 @@ +16-3.5-alpine3.21 16-3.5.3-alpine3.21 diff --git a/16-3.5/alpine3.21/update-postgis.sh b/16-3.5/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.5/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.5/alpine3.22/Dockerfile b/16-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..cfcd8c723 --- /dev/null +++ b/16-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:16-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 16 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/16-3.5/alpine3.22/initdb-postgis.sh b/16-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.5/alpine3.22/tags b/16-3.5/alpine3.22/tags new file mode 100644 index 000000000..c632febe0 --- /dev/null +++ b/16-3.5/alpine3.22/tags @@ -0,0 +1 @@ +16-3.5-alpine3.22 16-3.5.3-alpine3.22 16-3.5-alpine diff --git a/16-3.5/alpine3.22/update-postgis.sh b/16-3.5/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.5/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.5/bookworm/Dockerfile b/16-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..d5f2f7034 --- /dev/null +++ b/16-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:16-bookworm +ARG PGIS1_POSTGRES_MAJOR=16 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/16-3.5/bookworm/initdb-postgis.sh b/16-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.5/bookworm/tags b/16-3.5/bookworm/tags new file mode 100644 index 000000000..08919e7b3 --- /dev/null +++ b/16-3.5/bookworm/tags @@ -0,0 +1 @@ +16-3.5-bookworm 16-3.5.3-bookworm 16-3.5 diff --git a/16-3.5/bookworm/update-postgis.sh b/16-3.5/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.5/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-3.5/bullseye/Dockerfile b/16-3.5/bullseye/Dockerfile new file mode 100644 index 000000000..93c74d17a --- /dev/null +++ b/16-3.5/bullseye/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:16-bullseye +ARG PGIS1_POSTGRES_MAJOR=16 +ARG PGIS1_POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/16-3.5/bullseye/initdb-postgis.sh b/16-3.5/bullseye/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-3.5/bullseye/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-3.5/bullseye/tags b/16-3.5/bullseye/tags new file mode 100644 index 000000000..5a0e9d77e --- /dev/null +++ b/16-3.5/bullseye/tags @@ -0,0 +1 @@ +16-3.5-bullseye 16-3.5.2-bullseye diff --git a/16-3.5/bullseye/update-postgis.sh b/16-3.5/bullseye/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-3.5/bullseye/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-master/Dockerfile b/16-master/Dockerfile deleted file mode 100644 index 2c2efae4d..000000000 --- a/16-master/Dockerfile +++ /dev/null @@ -1,462 +0,0 @@ -# -# NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY. -# - -# "Experimental"; solely for testing purposes. Anticipate frequent changes! -# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. - -ARG DOCKER_CMAKE_BUILD_TYPE=Release -ARG CGAL_GIT_BRANCH=5.6.x-branch -FROM postgres:16-bullseye as builder - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL 16 bullseye" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -WORKDIR / - -# apt-get install -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic1.74.0 \ - libboost-chrono1.74.0 \ - libboost-date-time1.74.0 \ - libboost-filesystem1.74.0 \ - libboost-program-options1.74.0 \ - libboost-serialization1.74.0 \ - libboost-system1.74.0 \ - libboost-test1.74.0 \ - libboost-thread1.74.0 \ - libboost-timer1.74.0 \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # build dependency - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libpq-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - make \ - pkg-config \ - protobuf-c-compiler \ - xsltproc \ - # gdal+ - libblosc-dev \ - libcfitsio-dev \ - libfreexl-dev \ - libfyba-dev \ - libhdf5-dev \ - libkml-dev \ - liblz4-dev \ - liblzma-dev \ - libopenjp2-7-dev \ - libqhull-dev \ - libwebp-dev \ - libzstd-dev - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -# cgal & sfcgal -# By utilizing the latest commit of the CGAL 5.x.x-branch and implementing a header-only build for SFCGAL, -# one can benefit from the latest CGAL patches while avoiding compatibility issues. -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH 3c8e2053721271119499506ea1d8a49dee89e30c -ENV SFCGAL_GIT_HASH fc4dc5640e402c8b00426b5a3562324226725df9 -RUN set -ex \ - && mkdir -p /usr/src \ - && cd /usr/src \ - && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ - && cd cgal \ - && git checkout ${CGAL5X_GIT_HASH} \ - && git log -1 > /_pgis_cgal_last_commit.txt \ - && cd /usr/src \ - && git clone https://gitlab.com/Oslandia/SFCGAL.git \ - && cd SFCGAL \ - && git checkout ${SFCGAL_GIT_HASH} \ - && git log -1 > /_pgis_sfcgal_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. \ - -DCGAL_DIR=/usr/src/cgal \ - -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ - -DSFCGAL_BUILD_BENCH=OFF \ - -DSFCGAL_BUILD_EXAMPLES=OFF \ - -DSFCGAL_BUILD_TESTS=OFF \ - -DSFCGAL_WITH_OSG=OFF \ - && make -j$(nproc) \ - && make install \ - # - ## testing with -DSFCGAL_BUILD_TESTS=ON - # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ - # - # clean - && rm -fr /usr/src/SFCGAL \ - && rm -fr /usr/src/cgal - -# proj -ENV PROJ_GIT_HASH d4ebd920c1e1ecd0e192790ab4fdb98c7b982176 -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/PROJ.git \ - && cd PROJ \ - && git checkout ${PROJ_GIT_HASH} \ - && git log -1 > /_pgis_proj_last_commit.txt \ - # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 - && if [ -f "autogen.sh" ] ; then \ - set -eux \ - && echo "autotools version: 'autogen.sh' exists! Older version!" \ - && ./autogen.sh \ - && ./configure --disable-static \ - && make -j$(nproc) \ - && make install \ - ; \ - else \ - set -eux \ - && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ - && mkdir build \ - && cd build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - ; \ - fi \ - \ - && rm -fr /usr/src/PROJ - -# geos -ENV GEOS_GIT_HASH 1033161eca3684e0d9479daeafd35a4e0fb1800e -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/libgeos/geos.git \ - && cd geos \ - && git checkout ${GEOS_GIT_HASH} \ - && git log -1 > /_pgis_geos_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/geos - -# gdal -ENV GDAL_GIT_HASH 43e51bc48e7d48795ae60731ddc1414611ec5d3e -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/gdal.git \ - && cd gdal \ - && git checkout ${GDAL_GIT_HASH} \ - && git log -1 > /_pgis_gdal_last_commit.txt \ - \ - # gdal project directory structure - has been changed ! - && if [ -d "gdal" ] ; then \ - echo "Directory 'gdal' dir exists -> older version!" ; \ - cd gdal ; \ - else \ - echo "Directory 'gdal' does not exists! Newer version! " ; \ - fi \ - \ - && if [ -f "./autogen.sh" ]; then \ - # Building with autoconf ( old/deprecated ) - set -eux \ - && ./autogen.sh \ - && ./configure --disable-static \ - ; \ - else \ - # Building with cmake - set -eux \ - && mkdir build \ - && cd build \ - # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - -DBUILD_DOCS=OFF \ - \ - -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ - -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ - -DGDAL_USE_BLOSC=ON \ - -DGDAL_USE_CFITSIO=ON \ - -DGDAL_USE_CURL=ON \ - -DGDAL_USE_DEFLATE=ON \ - -DGDAL_USE_EXPAT=ON \ - -DGDAL_USE_FREEXL=ON \ - -DGDAL_USE_FYBA=ON \ - -DGDAL_USE_GEOS=ON \ - -DGDAL_USE_HDF5=ON \ - -DGDAL_USE_JSONC=ON \ - -DGDAL_USE_LERC_INTERNAL=ON \ - -DGDAL_USE_LIBKML=ON \ - -DGDAL_USE_LIBLZMA=ON \ - -DGDAL_USE_LZ4=ON \ - -DGDAL_USE_OPENJPEG=ON \ - -DGDAL_USE_POSTGRESQL=ON \ - -DGDAL_USE_QHULL=ON \ - -DGDAL_USE_SQLITE3=ON \ - -DGDAL_USE_TIFF=ON \ - -DGDAL_USE_WEBP=ON \ - -DGDAL_USE_ZSTD=ON \ - \ - # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 - # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ - -DGDAL_USE_ECW=OFF \ - -DGDAL_USE_GEOTIFF=OFF \ - -DGDAL_USE_HEIF=OFF \ - -DGDAL_USE_SPATIALITE=OFF \ - ; \ - fi \ - \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/gdal - -# Minimal command line test. -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - && pcre-config --version - -# ------------------------------------------- -# STAGE final -# ------------------------------------------- -FROM postgres:16-bullseye - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic1.74.0 \ - libboost-chrono1.74.0 \ - libboost-date-time1.74.0 \ - libboost-filesystem1.74.0 \ - libboost-program-options1.74.0 \ - libboost-serialization1.74.0 \ - libboost-system1.74.0 \ - libboost-test1.74.0 \ - libboost-thread1.74.0 \ - libboost-timer1.74.0 \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libpcre3 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # gdal+ - libblosc1 \ - libcfitsio9 \ - libfreexl1 \ - libfyba0 \ - libhdf5-103-1 \ - libkmlbase1 \ - libkmldom1 \ - libkmlengine1 \ - libopenjp2-7 \ - libqhull-r8.0 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=builder /_pgis*.* / -COPY --from=builder /usr/local /usr/local - -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH 3c8e2053721271119499506ea1d8a49dee89e30c -ENV SFCGAL_GIT_HASH fc4dc5640e402c8b00426b5a3562324226725df9 -ENV PROJ_GIT_HASH d4ebd920c1e1ecd0e192790ab4fdb98c7b982176 -ENV GEOS_GIT_HASH 1033161eca3684e0d9479daeafd35a4e0fb1800e -ENV GDAL_GIT_HASH 43e51bc48e7d48795ae60731ddc1414611ec5d3e - -# Minimal command line test ( fail fast ) -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Testing ogr2ogr PostgreSQL driver. - && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ - || echo "ogr2ogr missing PostgreSQL driver" && exit 1 - -# install postgis -ENV POSTGIS_GIT_HASH d7b58458ea7cf8157d09f59e955820d3a4321892 - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcunit1-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && cd \ - # postgis - && cd /usr/src/ \ - && git clone https://github.com/postgis/postgis.git \ - && cd postgis \ - && git checkout ${POSTGIS_GIT_HASH} \ - && git log -1 > /_pgis_last_commit.txt \ - && ./autogen.sh \ -# configure options taken from: -# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ -# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# regress check - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && ldconfig \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apt-get purge -y --autoremove \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - -# last final test -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Is the "ca-certificates" package installed? (for accessing remote raster files) - # https://github.com/postgis/docker-postgis/issues/307 - && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ - \ - # list last commits. - && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ - # list postgresql, postgis version - && cat _pgis_full_version.txt diff --git a/16-master/bookworm/Dockerfile b/16-master/bookworm/Dockerfile new file mode 100644 index 000000000..8eac66b78 --- /dev/null +++ b/16-master/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:16-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=master +ARG PGIS1_GEOS_CHECKOUT=main +ARG PGIS1_GDAL_CHECKOUT=master +ARG PGIS1_PROJ_CHECKOUT=master +ARG PGIS1_SFCGAL_CHECKOUT=master +ARG PGIS1_CGAL_CHECKOUT=master + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GEOS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GDAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_PROJ_CHECKOUT_SHA1=nocheck +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_CGAL_CHECKOUT_SHA1=nocheck + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 16-master spatial database extension with PostgreSQL 16 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="16-master" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 16-master spatial database extension with PostgreSQL 16 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="16-master" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/16-master/bookworm/initdb-postgis.sh b/16-master/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-master/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-master/bookworm/tags b/16-master/bookworm/tags new file mode 100644 index 000000000..b9d1ddd89 --- /dev/null +++ b/16-master/bookworm/tags @@ -0,0 +1 @@ +16-master-bookworm 16-master diff --git a/16-master/bookworm/update-postgis.sh b/16-master/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-master/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/16-master/initdb-postgis.sh b/16-master/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/16-master/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/16-recent/bookworm/Dockerfile b/16-recent/bookworm/Dockerfile new file mode 100644 index 000000000..c8611d3dc --- /dev/null +++ b/16-recent/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:16-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_GEOS_CHECKOUT=tags/3.13.1 +ARG PGIS1_GDAL_CHECKOUT=tags/v3.11.0 +ARG PGIS1_PROJ_CHECKOUT=tags/9.6.2 +ARG PGIS1_SFCGAL_CHECKOUT=tags/v2.1.0 +ARG PGIS1_CGAL_CHECKOUT=tags/v6.0.1 + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 +ARG PGIS1_GEOS_CHECKOUT_SHA1=431568d6e311e0bbfb057b4ec3d44d0d3ba3335f +ARG PGIS1_GDAL_CHECKOUT_SHA1=447eb5238bb6ef2837e68bf2ec742c64007b680b +ARG PGIS1_PROJ_CHECKOUT_SHA1=7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54 +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=60573cfb6b3fc01eceda563d275a226317ba01db +ARG PGIS1_CGAL_CHECKOUT_SHA1=50cfbde3b84dbeae8338268db2d78fe4fcb522de + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 16-recent spatial database extension with PostgreSQL 16 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="16-recent" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 16-recent spatial database extension with PostgreSQL 16 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="16-recent" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/16-recent/bookworm/initdb-postgis.sh b/16-recent/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/16-recent/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/16-recent/bookworm/tags b/16-recent/bookworm/tags new file mode 100644 index 000000000..061fc06f8 --- /dev/null +++ b/16-recent/bookworm/tags @@ -0,0 +1 @@ +16-recent-bookworm 16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 16-recent diff --git a/16-recent/bookworm/update-postgis.sh b/16-recent/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/16-recent/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.4/alpine3.21/Dockerfile b/17-3.4/alpine3.21/Dockerfile new file mode 100644 index 000000000..12603292a --- /dev/null +++ b/17-3.4/alpine3.21/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:17-alpine3.21 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.21" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.21" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/17-3.4/alpine3.21/initdb-postgis.sh b/17-3.4/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.4/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.4/alpine3.21/tags b/17-3.4/alpine3.21/tags new file mode 100644 index 000000000..646c3ccf4 --- /dev/null +++ b/17-3.4/alpine3.21/tags @@ -0,0 +1 @@ +17-3.4-alpine3.21 17-3.4.4-alpine3.21 diff --git a/17-3.4/alpine3.21/update-postgis.sh b/17-3.4/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.4/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.4/alpine3.22/Dockerfile b/17-3.4/alpine3.22/Dockerfile new file mode 100644 index 000000000..e155a8b32 --- /dev/null +++ b/17-3.4/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:17-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.4.4 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.4.4" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.4.4" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/17-3.4/alpine3.22/initdb-postgis.sh b/17-3.4/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.4/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.4/alpine3.22/tags b/17-3.4/alpine3.22/tags new file mode 100644 index 000000000..355da8042 --- /dev/null +++ b/17-3.4/alpine3.22/tags @@ -0,0 +1 @@ +17-3.4-alpine3.22 17-3.4.4-alpine3.22 17-3.4-alpine diff --git a/17-3.4/alpine3.22/update-postgis.sh b/17-3.4/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.4/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.5-bundle0/bookworm/Dockerfile b/17-3.5-bundle0/bookworm/Dockerfile new file mode 100644 index 000000000..0e8f34704 --- /dev/null +++ b/17-3.5-bundle0/bookworm/Dockerfile @@ -0,0 +1,364 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.bundle0.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +# Experimental Geo Bundle package. +# This is a work in progress and not yet ready for production. +# Some packages will be removed from this bundle and others will be added. +# The goal is to have a bundle that includes all the most popular extensions with PostGIS + +# set the base image , make build-* is overwriting with the actual value ! + +ARG REGISTRY=docker.io +ARG REPO_NAME=imresamu +ARG IMAGE_NAME=postgis-amd64 + +ARG PGIS1_BASE_IMAGE=${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:17-3.5-bookworm + +ARG PGIS1_PGSQL_GZIP_REPOSITORY=https://github.com/pramsey/pgsql-gzip.git +ARG PGIS1_PGSQL_GZIP_CHECKOUT=tags/v1.0.0 +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1=7c26e8b0056631ec0bb7c8fdd9bf2a24076e4a49 + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY=https://github.com/ossc-db/pg_hint_plan.git +ARG PGIS1_PG_HINT_PLAN_CHECKOUT=tags/REL17_1_7_0 +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1=85e07af6ca4675a26fa2281370c37371b883b2a9 + +ARG PGIS1_DUCKDB_CHECKOUT=tags/v1.3.1 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} AS builder + +ARG PGIS1_DUCKDB_CHECKOUT +ARG PGIS1_OPTIMIZATION_FLAGS + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + curl \ + flex \ + g++ \ + git \ + make \ + pgxnclient \ + postgresql-server-dev-$PG_MAJOR \ + unzip \ + wget \ + # pgsql-gzip + zlib1g-dev \ + # sqlite_fdw + sqlite3 \ + # bytemagic + libmagic-dev \ + # pgsoudium \ + libsodium-dev \ + # pg_curl + libcurl4-gnutls-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +FROM builder as builder-gzip + +ARG PGIS1_PGSQL_GZIP_REPOSITORY +ARG PGIS1_PGSQL_GZIP_CHECKOUT +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1 + +RUN set -eux \ + && mkdir -p /pgsql-gzip \ + && cd pgsql-gzip \ + && git init \ + && git remote add origin ${PGIS1_PGSQL_GZIP_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PGSQL_GZIP_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PGSQL_GZIP_CHECKOUT_SHA1" ]; then exit 1; fi \ + && git log -1 > /_pgsql_gzip_last_commit.txt \ + && make -j$(nproc) \ + && make install + + +FROM builder as builder-pgxn + +RUN pgxn install --verbose byteamagic +RUN pgxn install --verbose ddlx +RUN pgxn install --verbose dsef +RUN pgxn install --verbose json_accessors +RUN pgxn install --verbose lostgis +RUN pgxn install --verbose permuteseq +RUN pgxn install --verbose pg_curl # https://github.com/RekGRpth/pg_curl +RUN pgxn install --verbose pg_roaringbitmap +RUN pgxn install --verbose pg_rowalesce +RUN pgxn install --verbose pg_uuidv7 +RUN pgxn install --verbose pg_xenophile +RUN pgxn install --verbose pg_xxhash +RUN pgxn install --verbose pgsodium +RUN pgxn install --verbose pgsql_tweaks +# RUN pgxn install --verbose sqlite_fdw + +# pgxman pg_duckdb is not available / not working for PG17 yet + +#RUN pgxman install hydra_columnar +#RUN pgxman install pgvectorscale +#RUN pgxman install pg_quack + +FROM builder as builder-other + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY +ARG PGIS1_PG_HINT_PLAN_CHECKOUT +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1 + +# install pg_hint_plan +RUN set -eux \ + && mkdir pg_hint_plan \ + && cd pg_hint_plan \ + && git init \ + && git remote add origin ${PGIS1_PG_HINT_PLAN_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PG_HINT_PLAN_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1" ]; then exit 1; fi \ + && make -j$(nproc) \ + && make install + +RUN set -eux \ + && git clone --depth 1 https://github.com/NikolayS/postgres_dba.git \ + && cd postgres_dba \ + && rm -rf .git + +RUN set -eux \ + && git clone --depth 1 https://github.com/dr-jts/pg_svg.git \ + && cd pg_svg \ + && rm -rf .git + #install: psql < /pg_svg/pg-svg-lib.sql + +FROM ${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:17-3.5-bookworm + +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_TIMESCALEDB_TELEMETRY + +# Export build environment for child images (enterprise-grade package version locking) +RUN set -eux \ + # Ensure docker-postgis-env.sh exists (create empty if missing) + && touch /usr/local/share/docker-postgis-env.sh \ + # Export bundle-specific build versions for child images + && echo "# Bundle0 Extension Versions" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_OPTIMIZATION_FLAGS='${PGIS1_OPTIMIZATION_FLAGS}'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PG_HINT_PLAN_CHECKOUT='tags/REL17_1_7_0'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_DUCKDB_CHECKOUT='tags/v1.3.1'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PGSQL_GZIP_CHECKOUT='tags/v1.0.0'" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + # Source the environment after populating it + && . /usr/local/share/docker-postgis-env.sh + +# Only override opencontainers labels for bundle-specific info +# org.postgis.base.* labels are inherited from base image and should NOT be overridden +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS Bundle - 17-3.5-bookworm with MobilityDB, TimescaleDB, DuckDB and 40+ extensions" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3+dfsg-1~exp1.pgdg120+1-bundle0" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # Bundle-specific additional extensions (base PostGIS extensions inherited from org.postgis.base.extensions) + org.postgis.bundle0.additional.extensions="timescaledb,mobilitydb,pgsql_http,pgsql_gzip,pgrouting,pgvector,h3,pointcloud,pgaudit,byteamagic,ddlx,dsef,json_accessors,lostgis,permuteseq,pg_curl,pg_roaringbitmap,pg_rowalesce,pg_uuidv7,pg_xenophile,pg_xxhash,pgsodium,pgsql_tweaks,asn1oid,extra_window_functions,first_last_agg,hll,hypopg,icu_ext,jsquery,numeral,ogr_fdw,partman,periods,pg_fact_loader,pg_failover_slots,pg_stat_kcache,pg_wait_sampling,pgl_ddl_deploy,pglogical,pgmp,pgpcre,pgq3,pgsphere,pgtap,pldebugger,plpgsql_check,prefix,prioritize,q3c,repack,rum,show_plans,squeeze" \ + org.postgis.bundle0.excluded.pg17="sqlite_fdw,age,decoderbufs" \ + org.postgis.bundle0.permanently.excluded="parray_gin,pg_quack" \ + org.postgis.bundle0.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.bundle0.timescaledb.telemetry="${PGIS1_TIMESCALEDB_TELEMETRY}" \ + org.postgis.bundle0.duckdb.version="tags/v1.3.1" + +# install all utf8 locales; +# helping: https://github.com/docker-library/docs/tree/master/postgres#locale-customization +RUN set -eux \ + && sed -i -e 's/# \(.*\.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + \ + bzip2 \ + curl \ + jq \ + unzip \ + wget \ + \ + gdal-bin \ + proj-bin \ + sqlite3 \ + \ + pipx \ + python-is-python3 \ + python3 \ + python3-geoalchemy2 \ + python3-pglast \ + python3-pip \ + python3-psycopg2 \ + python3-setuptools \ + python3-sqlalchemy \ + \ + postgis \ + postgresql \ + postgresql-client-common \ + postgresql-common \ + postgresql-contrib \ + postgresql-plpython3-$PG_MAJOR \ + postgresql-postgis \ + postgresql-postgis-scripts \ + \ + pg-activity \ + pgbackrest \ + pgbadger \ + pgtap \ + pgtop \ + pspg \ + vip-manager \ + \ + # add any exceptions for PG17 or PPG16 here + # PostgreSQL 17 specific packages + \ + postgresql-$PG_MAJOR-age \ + postgresql-$PG_MAJOR-asn1oid \ + postgresql-$PG_MAJOR-auto-failover \ + postgresql-$PG_MAJOR-credcheck \ + postgresql-$PG_MAJOR-cron \ + postgresql-$PG_MAJOR-decoderbufs \ + postgresql-$PG_MAJOR-extra-window-functions \ + postgresql-$PG_MAJOR-first-last-agg \ + postgresql-$PG_MAJOR-h3 \ + postgresql-$PG_MAJOR-hll \ + postgresql-$PG_MAJOR-http \ + postgresql-$PG_MAJOR-hypopg \ + postgresql-$PG_MAJOR-icu-ext \ + postgresql-$PG_MAJOR-jsquery \ + postgresql-$PG_MAJOR-mobilitydb \ + postgresql-$PG_MAJOR-numeral \ + postgresql-$PG_MAJOR-ogr-fdw \ + postgresql-$PG_MAJOR-partman \ + postgresql-$PG_MAJOR-periods \ + postgresql-$PG_MAJOR-pg-fact-loader \ + postgresql-$PG_MAJOR-pg-failover-slots \ + postgresql-$PG_MAJOR-pg-stat-kcache \ + postgresql-$PG_MAJOR-pg-wait-sampling \ + postgresql-$PG_MAJOR-pgaudit \ + postgresql-$PG_MAJOR-pgl-ddl-deploy \ + postgresql-$PG_MAJOR-pglogical \ + postgresql-$PG_MAJOR-pgmp \ + postgresql-$PG_MAJOR-pgpcre \ + postgresql-$PG_MAJOR-pgq3 \ + postgresql-$PG_MAJOR-pgrouting \ + postgresql-$PG_MAJOR-pgrouting-scripts \ + postgresql-$PG_MAJOR-pgsphere \ + postgresql-$PG_MAJOR-pgtap \ + postgresql-$PG_MAJOR-pgvector \ + postgresql-$PG_MAJOR-pldebugger \ + postgresql-$PG_MAJOR-plpgsql-check \ + postgresql-$PG_MAJOR-pointcloud \ + postgresql-$PG_MAJOR-prefix \ + postgresql-$PG_MAJOR-prioritize \ + postgresql-$PG_MAJOR-q3c \ + postgresql-$PG_MAJOR-repack \ + postgresql-$PG_MAJOR-rum \ + postgresql-$PG_MAJOR-show-plans \ + postgresql-$PG_MAJOR-squeeze \ + postgresql-$PG_MAJOR-timescaledb \ + # MeCab based tokenizer for pgdg-pgroonga + groonga-tokenizer-mecab \ + # bytemagic + libmagic1 libmagic-mgc \ + # pgsodium + libsodium23 \ + \ + && rm -Rf /root/.cache/pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_DUCKDB_CHECKOUT +ENV PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT} +RUN arch=$(uname -m) \ + && DUCKDB_VERSION=$(echo "$PGIS1_DUCKDB_CHECKOUT" | sed -E 's|^.*/||; s|^tags/||; s|^v||') \ + && echo "DUCKDB_VERSION=${DUCKDB_VERSION}" \ + && echo "PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT}" \ + && case "$arch" in \ + x86_64) \ + duck_binary="duckdb_cli-linux-amd64.zip" ;; \ + aarch64) \ + duck_binary="duckdb_cli-linux-arm64.zip" ;; \ + *) \ + echo "Unsupported architecture: $arch"; exit 1 ;; \ + esac \ + && wget https://github.com/duckdb/duckdb/releases/download/v${DUCKDB_VERSION}/$duck_binary \ + && unzip $duck_binary -d /usr/local/bin \ + && rm $duck_binary \ + && duckdb --version + +# install duckdb extensions +ENV DUCKDB_EXTENSIONS="excel fts httpfs inet postgres_scanner spatial sqlite_scanner tpcds tpch" +RUN for e in ${DUCKDB_EXTENSIONS} ; do \ + echo "Installing $e ..."; \ + if duckdb -c "INSTALL $e;" 2>&1 | tee /tmp/duckdb-install-$e.log; then \ + echo "Successfully installed $e"; \ + echo "LOAD $e;" >> $HOME/.duckdbrc; \ + else \ + echo "Failed to install $e, check /tmp/duckdb-install-$e.log"; \ + fi; \ + done \ + # Add core extensions to .duckdbrc (these are built-in) + && echo "LOAD autocomplete;" >> $HOME/.duckdbrc \ + && echo "LOAD icu;" >> $HOME/.duckdbrc \ + && echo "LOAD json;" >> $HOME/.duckdbrc \ + && echo "LOAD parquet;" >> $HOME/.duckdbrc + +# Install from stages +COPY --from=builder-gzip /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-gzip /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-pgxn /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-pgxn /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-other /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /postgres_dba /postgres_dba +COPY --from=builder-other /pg_svg /pg_svg + +# check any missing dependencies +RUN set -eux \ + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true + +# multiple LLVM existance is not optimal; so we give a warning. +# known problem: duplicated LLVM +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "WARNING: More than one llvm package or none at all found!"; \ + dpkg -l | grep llvm ; \ + fi + +# add MobilityDB requirements +RUN set -eux \ + && cp -v /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample.orig; \ + # add MobilityDB and TimescaleDB requirements + echo "shared_preload_libraries = 'postgis-3,pg_stat_statements,timescaledb'" >> /usr/share/postgresql/postgresql.conf.sample ; \ + # MobilityDB recomendation + echo "max_locks_per_transaction = 128" >> /usr/share/postgresql/postgresql.conf.sample; \ + echo "timescaledb.telemetry_level=off" >> /usr/share/postgresql/postgresql.conf.sample + +# for postgres_dba Use ":dba" to see menu +RUN printf "%s %s %s %s\n" \\set dba \'\\\\i /postgres_dba/start.psql\' >> ~/.psqlrc + +COPY ./initdb-bundle0.sh /docker-entrypoint-initdb.d/11_bundle0.sh diff --git a/17-3.5-bundle0/bookworm/initdb-bundle0.sh b/17-3.5-bundle0/bookworm/initdb-bundle0.sh new file mode 100644 index 000000000..5f2c5d116 --- /dev/null +++ b/17-3.5-bundle0/bookworm/initdb-bundle0.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# install pg-svg-lib +"${psql[@]}" /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/17-3.5/alpine3.21/initdb-postgis.sh b/17-3.5/alpine3.21/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.5/alpine3.21/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.5/alpine3.21/tags b/17-3.5/alpine3.21/tags new file mode 100644 index 000000000..f1667dd61 --- /dev/null +++ b/17-3.5/alpine3.21/tags @@ -0,0 +1 @@ +17-3.5-alpine3.21 17-3.5.3-alpine3.21 diff --git a/17-3.5/alpine3.21/update-postgis.sh b/17-3.5/alpine3.21/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.5/alpine3.21/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.5/alpine3.22/Dockerfile b/17-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..85c5c75e0 --- /dev/null +++ b/17-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:17-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/17-3.5/alpine3.22/initdb-postgis.sh b/17-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.5/alpine3.22/tags b/17-3.5/alpine3.22/tags new file mode 100644 index 000000000..73ede3e95 --- /dev/null +++ b/17-3.5/alpine3.22/tags @@ -0,0 +1 @@ +17-3.5-alpine3.22 17-3.5.3-alpine3.22 17-3.5-alpine alpine diff --git a/17-3.5/alpine3.22/update-postgis.sh b/17-3.5/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.5/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.5/bookworm/Dockerfile b/17-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..b3e5b6d85 --- /dev/null +++ b/17-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:17-bookworm +ARG PGIS1_POSTGRES_MAJOR=17 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/17-3.5/bookworm/initdb-postgis.sh b/17-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.5/bookworm/tags b/17-3.5/bookworm/tags new file mode 100644 index 000000000..f147f4a94 --- /dev/null +++ b/17-3.5/bookworm/tags @@ -0,0 +1 @@ +17-3.5-bookworm 17-3.5.3-bookworm 17-3.5 latest diff --git a/17-3.5/bookworm/update-postgis.sh b/17-3.5/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.5/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.5/bullseye/Dockerfile b/17-3.5/bullseye/Dockerfile new file mode 100644 index 000000000..e5dda44da --- /dev/null +++ b/17-3.5/bullseye/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:17-bullseye +ARG PGIS1_POSTGRES_MAJOR=17 +ARG PGIS1_POSTGIS_VERSION=3.5.2+dfsg-1.pgdg110+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bullseye" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/17-3.5/bullseye/initdb-postgis.sh b/17-3.5/bullseye/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.5/bullseye/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.5/bullseye/tags b/17-3.5/bullseye/tags new file mode 100644 index 000000000..2e5ab6fb3 --- /dev/null +++ b/17-3.5/bullseye/tags @@ -0,0 +1 @@ +17-3.5-bullseye 17-3.5.2-bullseye diff --git a/17-3.5/bullseye/update-postgis.sh b/17-3.5/bullseye/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.5/bullseye/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-3.6/alpine3.22/Dockerfile b/17-3.6/alpine3.22/Dockerfile new file mode 100644 index 000000000..03e6ec1dc --- /dev/null +++ b/17-3.6/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:17-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.6.0alpha1 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=b32829d707ef65515df1224361b9f2d5889db348 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.6.0alpha1" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 17 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.6.0alpha1" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/17-3.6/alpine3.22/initdb-postgis.sh b/17-3.6/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-3.6/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-3.6/alpine3.22/tags b/17-3.6/alpine3.22/tags new file mode 100644 index 000000000..e98f9f8ce --- /dev/null +++ b/17-3.6/alpine3.22/tags @@ -0,0 +1 @@ +17-3.6.0alpha1-alpine3.22 17-3.6.0alpha1-alpine diff --git a/17-3.6/alpine3.22/update-postgis.sh b/17-3.6/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-3.6/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-master/bookworm/Dockerfile b/17-master/bookworm/Dockerfile new file mode 100644 index 000000000..874955641 --- /dev/null +++ b/17-master/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:17-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=master +ARG PGIS1_GEOS_CHECKOUT=main +ARG PGIS1_GDAL_CHECKOUT=master +ARG PGIS1_PROJ_CHECKOUT=master +ARG PGIS1_SFCGAL_CHECKOUT=master +ARG PGIS1_CGAL_CHECKOUT=master + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GEOS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GDAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_PROJ_CHECKOUT_SHA1=nocheck +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_CGAL_CHECKOUT_SHA1=nocheck + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 17-master spatial database extension with PostgreSQL 17 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="17-master" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 17-master spatial database extension with PostgreSQL 17 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="17-master" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/17-master/bookworm/initdb-postgis.sh b/17-master/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-master/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-master/bookworm/tags b/17-master/bookworm/tags new file mode 100644 index 000000000..1358267c6 --- /dev/null +++ b/17-master/bookworm/tags @@ -0,0 +1 @@ +17-master-bookworm 17-master diff --git a/17-master/bookworm/update-postgis.sh b/17-master/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-master/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/17-recent/bookworm/Dockerfile b/17-recent/bookworm/Dockerfile new file mode 100644 index 000000000..84fcee059 --- /dev/null +++ b/17-recent/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:17-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_GEOS_CHECKOUT=tags/3.13.1 +ARG PGIS1_GDAL_CHECKOUT=tags/v3.11.0 +ARG PGIS1_PROJ_CHECKOUT=tags/9.6.2 +ARG PGIS1_SFCGAL_CHECKOUT=tags/v2.1.0 +ARG PGIS1_CGAL_CHECKOUT=tags/v6.0.1 + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 +ARG PGIS1_GEOS_CHECKOUT_SHA1=431568d6e311e0bbfb057b4ec3d44d0d3ba3335f +ARG PGIS1_GDAL_CHECKOUT_SHA1=447eb5238bb6ef2837e68bf2ec742c64007b680b +ARG PGIS1_PROJ_CHECKOUT_SHA1=7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54 +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=60573cfb6b3fc01eceda563d275a226317ba01db +ARG PGIS1_CGAL_CHECKOUT_SHA1=50cfbde3b84dbeae8338268db2d78fe4fcb522de + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 17-recent spatial database extension with PostgreSQL 17 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="17-recent" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 17-recent spatial database extension with PostgreSQL 17 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="17-recent" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/17-recent/bookworm/initdb-postgis.sh b/17-recent/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/17-recent/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/17-recent/bookworm/tags b/17-recent/bookworm/tags new file mode 100644 index 000000000..2506da7a5 --- /dev/null +++ b/17-recent/bookworm/tags @@ -0,0 +1 @@ +17-recent-bookworm 17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 17-recent recent diff --git a/17-recent/bookworm/update-postgis.sh b/17-recent/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/17-recent/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/18-3.5/alpine3.22/Dockerfile b/18-3.5/alpine3.22/Dockerfile new file mode 100644 index 000000000..4b81af82e --- /dev/null +++ b/18-3.5/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:18beta1-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 18 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.5.3" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 18 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.5.3" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/18-3.5/alpine3.22/initdb-postgis.sh b/18-3.5/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/18-3.5/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/18-3.5/alpine3.22/tags b/18-3.5/alpine3.22/tags new file mode 100644 index 000000000..b03529025 --- /dev/null +++ b/18-3.5/alpine3.22/tags @@ -0,0 +1 @@ +18beta1-3.5-alpine3.22 18beta1-3.5.3-alpine3.22 18beta1-3.5-alpine diff --git a/18-3.5/alpine3.22/update-postgis.sh b/18-3.5/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/18-3.5/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/18-3.5/bookworm/Dockerfile b/18-3.5/bookworm/Dockerfile new file mode 100644 index 000000000..8b1a47438 --- /dev/null +++ b/18-3.5/bookworm/Dockerfile @@ -0,0 +1,93 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.debian.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +ARG PGIS1_BASE_IMAGE=postgres:18beta1-bookworm +ARG PGIS1_POSTGRES_MAJOR=18 +ARG PGIS1_POSTGIS_VERSION=3.5.3+dfsg-1~exp1.pgdg120+1 +ARG PGIS1_POSTGIS_MAJOR=3 + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/18-3.5/bookworm/initdb-postgis.sh b/18-3.5/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/18-3.5/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/18-3.5/bookworm/tags b/18-3.5/bookworm/tags new file mode 100644 index 000000000..69158bc12 --- /dev/null +++ b/18-3.5/bookworm/tags @@ -0,0 +1 @@ +18beta1-3.5-bookworm 18beta1-3.5.3-bookworm 18beta1-3.5 diff --git a/18-3.5/bookworm/update-postgis.sh b/18-3.5/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/18-3.5/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/18-3.6/alpine3.22/Dockerfile b/18-3.6/alpine3.22/Dockerfile new file mode 100644 index 000000000..4e6032450 --- /dev/null +++ b/18-3.6/alpine3.22/Dockerfile @@ -0,0 +1,222 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.alpine.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +ARG PGIS1_BASE_IMAGE=postgres:18beta1-alpine3.22 +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.6.0alpha1 +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=b32829d707ef65515df1224361b9f2d5889db348 + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 18 alpine3.22" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="3.6.0alpha1" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL 18 alpine3.22" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="3.6.0alpha1" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/18-3.6/alpine3.22/initdb-postgis.sh b/18-3.6/alpine3.22/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/18-3.6/alpine3.22/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/18-3.6/alpine3.22/tags b/18-3.6/alpine3.22/tags new file mode 100644 index 000000000..54c6f7cf4 --- /dev/null +++ b/18-3.6/alpine3.22/tags @@ -0,0 +1 @@ +18beta1-3.6.0alpha1-alpine3.22 18beta1-3.6.0alpha1-alpine diff --git a/18-3.6/alpine3.22/update-postgis.sh b/18-3.6/alpine3.22/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/18-3.6/alpine3.22/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/18-master/bookworm/Dockerfile b/18-master/bookworm/Dockerfile new file mode 100644 index 000000000..56a6fe614 --- /dev/null +++ b/18-master/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:18beta1-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=master +ARG PGIS1_GEOS_CHECKOUT=main +ARG PGIS1_GDAL_CHECKOUT=master +ARG PGIS1_PROJ_CHECKOUT=master +ARG PGIS1_SFCGAL_CHECKOUT=master +ARG PGIS1_CGAL_CHECKOUT=master + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GEOS_CHECKOUT_SHA1=nocheck +ARG PGIS1_GDAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_PROJ_CHECKOUT_SHA1=nocheck +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=nocheck +ARG PGIS1_CGAL_CHECKOUT_SHA1=nocheck + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 18-master spatial database extension with PostgreSQL 18 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="18-master" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 18-master spatial database extension with PostgreSQL 18 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="18-master" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/18-master/bookworm/initdb-postgis.sh b/18-master/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/18-master/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/18-master/bookworm/tags b/18-master/bookworm/tags new file mode 100644 index 000000000..62a4c5766 --- /dev/null +++ b/18-master/bookworm/tags @@ -0,0 +1 @@ +18beta1-master-bookworm 18beta1-master diff --git a/18-master/bookworm/update-postgis.sh b/18-master/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/18-master/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/18-recent/bookworm/Dockerfile b/18-recent/bookworm/Dockerfile new file mode 100644 index 000000000..3337020d9 --- /dev/null +++ b/18-recent/bookworm/Dockerfile @@ -0,0 +1,772 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" +# source: "./templates/Dockerfile.master.template" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:18beta1-bookworm + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT=tags/3.5.3 +ARG PGIS1_GEOS_CHECKOUT=tags/3.13.1 +ARG PGIS1_GDAL_CHECKOUT=tags/v3.11.0 +ARG PGIS1_PROJ_CHECKOUT=tags/9.6.2 +ARG PGIS1_SFCGAL_CHECKOUT=tags/v2.1.0 +ARG PGIS1_CGAL_CHECKOUT=tags/v6.0.1 + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1=aab5f55897aa2e8eb5f17c3996b61268c5f1ec91 +ARG PGIS1_GEOS_CHECKOUT_SHA1=431568d6e311e0bbfb057b4ec3d44d0d3ba3335f +ARG PGIS1_GDAL_CHECKOUT_SHA1=447eb5238bb6ef2837e68bf2ec742c64007b680b +ARG PGIS1_PROJ_CHECKOUT_SHA1=7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54 +ARG PGIS1_SFCGAL_CHECKOUT_SHA1=60573cfb6b3fc01eceda563d275a226317ba01db +ARG PGIS1_CGAL_CHECKOUT_SHA1=50cfbde3b84dbeae8338268db2d78fe4fcb522de + +ARG PGIS1_BOOST_VERSION=1.74.0 +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD=with_extra +# Full GDAL build ; with arrow, parquet and extra dependencies + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD=with_extra" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - 18-recent spatial database extension with PostgreSQL 18 bookworm" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="18-recent" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - 18-recent spatial database extension with PostgreSQL 18 bookworm" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="18-recent" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ + libtiff6 \ + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-bookworm.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-bookworm.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ + libcfitsio10 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/18-recent/bookworm/initdb-postgis.sh b/18-recent/bookworm/initdb-postgis.sh new file mode 100644 index 000000000..21f8c373d --- /dev/null +++ b/18-recent/bookworm/initdb-postgis.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# Create the 'template_postgis' template db +"${psql[@]}" <<-'EOSQL' +CREATE DATABASE template_postgis IS_TEMPLATE true; +EOSQL + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB"; do + echo "Loading PostGIS extensions into $DB" + "${psql[@]}" --dbname="$DB" <<-'EOSQL' + CREATE EXTENSION IF NOT EXISTS postgis; + CREATE EXTENSION IF NOT EXISTS postgis_topology; + -- Reconnect to update pg_setting.resetval + -- See https://github.com/postgis/docker-postgis/issues/288 + \c + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; +EOSQL +done diff --git a/18-recent/bookworm/tags b/18-recent/bookworm/tags new file mode 100644 index 000000000..711dce662 --- /dev/null +++ b/18-recent/bookworm/tags @@ -0,0 +1 @@ +18beta1-recent-bookworm 18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 18beta1-recent diff --git a/18-recent/bookworm/update-postgis.sh b/18-recent/bookworm/update-postgis.sh new file mode 100755 index 000000000..f98abd261 --- /dev/null +++ b/18-recent/bookworm/update-postgis.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +POSTGIS_VERSION="${POSTGIS_VERSION%%+*}" + +# Load PostGIS into both template_database and $POSTGRES_DB +for DB in template_postgis "$POSTGRES_DB" "${@}"; do + echo "Updating PostGIS extensions '$DB' to $POSTGIS_VERSION" + psql --dbname="$DB" -c " + -- Upgrade PostGIS (includes raster) + CREATE EXTENSION IF NOT EXISTS postgis VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis UPDATE TO '$POSTGIS_VERSION'; + + -- Upgrade Topology + CREATE EXTENSION IF NOT EXISTS postgis_topology VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_topology UPDATE TO '$POSTGIS_VERSION'; + + -- Install Tiger dependencies in case not already installed + CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; + -- Upgrade US Tiger Geocoder + CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder VERSION '$POSTGIS_VERSION'; + ALTER EXTENSION postgis_tiger_geocoder UPDATE TO '$POSTGIS_VERSION'; + " +done diff --git a/Dockerfile.alpine.template b/Dockerfile.alpine.template deleted file mode 100644 index 8ed94dd79..000000000 --- a/Dockerfile.alpine.template +++ /dev/null @@ -1,124 +0,0 @@ -# -# %%TXT_AUTOGENERATED%% -# -ARG BASE_IMAGE=postgres:%%PG_MAJOR%%-alpine3.18 -FROM ${BASE_IMAGE} - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS %%POSTGIS_VERSION%% spatial database extension with PostgreSQL %%PG_MAJOR%% Alpine" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_VERSION %%POSTGIS_VERSION%% -ENV POSTGIS_SHA256 %%POSTGIS_SHA256%% - -RUN set -eux \ - && apk add --no-cache --virtual .fetch-deps \ - ca-certificates \ - openssl \ - tar \ - \ - && wget -O postgis.tar.gz "https://github.com/postgis/postgis/archive/${POSTGIS_VERSION}.tar.gz" \ - && echo "${POSTGIS_SHA256} *postgis.tar.gz" | sha256sum -c - \ - && mkdir -p /usr/src/postgis \ - && tar \ - --extract \ - --file postgis.tar.gz \ - --directory /usr/src/postgis \ - --strip-components 1 \ - && rm postgis.tar.gz \ - \ - && apk add --no-cache --virtual .build-deps \ - \ - gdal-dev \ - geos-dev \ - proj-dev \ - proj-util \ - sfcgal-dev \ - \ - # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains - # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. - # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 - $DOCKER_PG_LLVM_DEPS \ - \ - autoconf \ - automake \ - cunit-dev \ - file \ - g++ \ - gcc \ - gettext-dev \ - git \ - json-c-dev \ - libtool \ - libxml2-dev \ - make \ - pcre2-dev \ - perl \ - protobuf-c-dev \ - \ -# build PostGIS - with Link Time Optimization (LTO) enabled - && cd /usr/src/postgis \ - && gettextize \ - && ./autogen.sh \ - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ - \ -# This section is for refreshing the proj data for the regression tests. -# It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 -# This increases the Docker image size by about 1 MB. - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# This section performs a regression check. - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# add .postgis-rundeps - && apk add --no-cache --virtual .postgis-rundeps \ - \ - gdal \ - geos \ - proj \ - sfcgal \ - \ - json-c \ - libstdc++ \ - pcre2 \ - protobuf-c \ - \ - # ca-certificates: for accessing remote raster files - # fix https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apk del .fetch-deps .build-deps \ -# At the end of the build, we print the collected information -# from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. - && cat /_pgis_full_version.txt - -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin diff --git a/Dockerfile.master.template b/Dockerfile.master.template deleted file mode 100644 index 0b78eb15c..000000000 --- a/Dockerfile.master.template +++ /dev/null @@ -1,462 +0,0 @@ -# -# %%TXT_AUTOGENERATED%% -# - -# "Experimental"; solely for testing purposes. Anticipate frequent changes! -# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. - -ARG DOCKER_CMAKE_BUILD_TYPE=Release -ARG CGAL_GIT_BRANCH=5.6.x-branch -FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% as builder - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS - master spatial database extension with PostgreSQL %%PG_MAJOR%% %%DEBIAN_VERSION%%" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -WORKDIR / - -# apt-get install -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic%%BOOST_VERSION%% \ - libboost-chrono%%BOOST_VERSION%% \ - libboost-date-time%%BOOST_VERSION%% \ - libboost-filesystem%%BOOST_VERSION%% \ - libboost-program-options%%BOOST_VERSION%% \ - libboost-serialization%%BOOST_VERSION%% \ - libboost-system%%BOOST_VERSION%% \ - libboost-test%%BOOST_VERSION%% \ - libboost-thread%%BOOST_VERSION%% \ - libboost-timer%%BOOST_VERSION%% \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # build dependency - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libpq-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - make \ - pkg-config \ - protobuf-c-compiler \ - xsltproc \ - # gdal+ - libblosc-dev \ - libcfitsio-dev \ - libfreexl-dev \ - libfyba-dev \ - libhdf5-dev \ - libkml-dev \ - liblz4-dev \ - liblzma-dev \ - libopenjp2-7-dev \ - libqhull-dev \ - libwebp-dev \ - libzstd-dev - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -# cgal & sfcgal -# By utilizing the latest commit of the CGAL 5.x.x-branch and implementing a header-only build for SFCGAL, -# one can benefit from the latest CGAL patches while avoiding compatibility issues. -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH %%CGAL5X_GIT_HASH%% -ENV SFCGAL_GIT_HASH %%SFCGAL_GIT_HASH%% -RUN set -ex \ - && mkdir -p /usr/src \ - && cd /usr/src \ - && git clone --branch ${CGAL_GIT_BRANCH} https://github.com/CGAL/cgal \ - && cd cgal \ - && git checkout ${CGAL5X_GIT_HASH} \ - && git log -1 > /_pgis_cgal_last_commit.txt \ - && cd /usr/src \ - && git clone https://gitlab.com/Oslandia/SFCGAL.git \ - && cd SFCGAL \ - && git checkout ${SFCGAL_GIT_HASH} \ - && git log -1 > /_pgis_sfcgal_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. \ - -DCGAL_DIR=/usr/src/cgal \ - -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} \ - -DSFCGAL_BUILD_BENCH=OFF \ - -DSFCGAL_BUILD_EXAMPLES=OFF \ - -DSFCGAL_BUILD_TESTS=OFF \ - -DSFCGAL_WITH_OSG=OFF \ - && make -j$(nproc) \ - && make install \ - # - ## testing with -DSFCGAL_BUILD_TESTS=ON - # && CTEST_OUTPUT_ON_FAILURE=TRUE ctest \ - # - # clean - && rm -fr /usr/src/SFCGAL \ - && rm -fr /usr/src/cgal - -# proj -ENV PROJ_GIT_HASH %%PROJ_GIT_HASH%% -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/PROJ.git \ - && cd PROJ \ - && git checkout ${PROJ_GIT_HASH} \ - && git log -1 > /_pgis_proj_last_commit.txt \ - # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 - && if [ -f "autogen.sh" ] ; then \ - set -eux \ - && echo "autotools version: 'autogen.sh' exists! Older version!" \ - && ./autogen.sh \ - && ./configure --disable-static \ - && make -j$(nproc) \ - && make install \ - ; \ - else \ - set -eux \ - && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ - && mkdir build \ - && cd build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - ; \ - fi \ - \ - && rm -fr /usr/src/PROJ - -# geos -ENV GEOS_GIT_HASH %%GEOS_GIT_HASH%% -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/libgeos/geos.git \ - && cd geos \ - && git checkout ${GEOS_GIT_HASH} \ - && git log -1 > /_pgis_geos_last_commit.txt \ - && mkdir cmake-build \ - && cd cmake-build \ - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/geos - -# gdal -ENV GDAL_GIT_HASH %%GDAL_GIT_HASH%% -RUN set -ex \ - && cd /usr/src \ - && git clone https://github.com/OSGeo/gdal.git \ - && cd gdal \ - && git checkout ${GDAL_GIT_HASH} \ - && git log -1 > /_pgis_gdal_last_commit.txt \ - \ - # gdal project directory structure - has been changed ! - && if [ -d "gdal" ] ; then \ - echo "Directory 'gdal' dir exists -> older version!" ; \ - cd gdal ; \ - else \ - echo "Directory 'gdal' does not exists! Newer version! " ; \ - fi \ - \ - && if [ -f "./autogen.sh" ]; then \ - # Building with autoconf ( old/deprecated ) - set -eux \ - && ./autogen.sh \ - && ./configure --disable-static \ - ; \ - else \ - # Building with cmake - set -eux \ - && mkdir build \ - && cd build \ - # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules - && cmake .. -DCMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ - -DBUILD_DOCS=OFF \ - \ - -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ - -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ - -DGDAL_USE_BLOSC=ON \ - -DGDAL_USE_CFITSIO=ON \ - -DGDAL_USE_CURL=ON \ - -DGDAL_USE_DEFLATE=ON \ - -DGDAL_USE_EXPAT=ON \ - -DGDAL_USE_FREEXL=ON \ - -DGDAL_USE_FYBA=ON \ - -DGDAL_USE_GEOS=ON \ - -DGDAL_USE_HDF5=ON \ - -DGDAL_USE_JSONC=ON \ - -DGDAL_USE_LERC_INTERNAL=ON \ - -DGDAL_USE_LIBKML=ON \ - -DGDAL_USE_LIBLZMA=ON \ - -DGDAL_USE_LZ4=ON \ - -DGDAL_USE_OPENJPEG=ON \ - -DGDAL_USE_POSTGRESQL=ON \ - -DGDAL_USE_QHULL=ON \ - -DGDAL_USE_SQLITE3=ON \ - -DGDAL_USE_TIFF=ON \ - -DGDAL_USE_WEBP=ON \ - -DGDAL_USE_ZSTD=ON \ - \ - # OFF and Not working https://github.com/OSGeo/gdal/issues/7100 - # -DRENAME_INTERNAL_GEOTIFF_SYMBOLS=ON \ - -DGDAL_USE_ECW=OFF \ - -DGDAL_USE_GEOTIFF=OFF \ - -DGDAL_USE_HEIF=OFF \ - -DGDAL_USE_SPATIALITE=OFF \ - ; \ - fi \ - \ - && make -j$(nproc) \ - && make install \ - && cd / \ - && rm -fr /usr/src/gdal - -# Minimal command line test. -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - && pcre-config --version - -# ------------------------------------------- -# STAGE final -# ------------------------------------------- -FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% - -ARG DOCKER_CMAKE_BUILD_TYPE -ENV DOCKER_CMAKE_BUILD_TYPE=${DOCKER_CMAKE_BUILD_TYPE} - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - curl \ - libboost-atomic%%BOOST_VERSION%% \ - libboost-chrono%%BOOST_VERSION%% \ - libboost-date-time%%BOOST_VERSION%% \ - libboost-filesystem%%BOOST_VERSION%% \ - libboost-program-options%%BOOST_VERSION%% \ - libboost-serialization%%BOOST_VERSION%% \ - libboost-system%%BOOST_VERSION%% \ - libboost-test%%BOOST_VERSION%% \ - libboost-thread%%BOOST_VERSION%% \ - libboost-timer%%BOOST_VERSION%% \ - libcurl3-gnutls \ - libexpat1 \ - libgmp10 \ - libgmpxx4ldbl \ - libjson-c5 \ - libmpfr6 \ - libpcre3 \ - libprotobuf-c1 \ - libtiff5 \ - libxml2 \ - sqlite3 \ - # gdal+ - libblosc1 \ - libcfitsio9 \ - libfreexl1 \ - libfyba0 \ - libhdf5-103-1 \ - libkmlbase1 \ - libkmldom1 \ - libkmlengine1 \ - libopenjp2-7 \ - libqhull-r8.0 \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -COPY --from=builder /_pgis*.* / -COPY --from=builder /usr/local /usr/local - -ARG CGAL_GIT_BRANCH -ENV CGAL_GIT_BRANCH=${CGAL_GIT_BRANCH} -ENV CGAL5X_GIT_HASH %%CGAL5X_GIT_HASH%% -ENV SFCGAL_GIT_HASH %%SFCGAL_GIT_HASH%% -ENV PROJ_GIT_HASH %%PROJ_GIT_HASH%% -ENV GEOS_GIT_HASH %%GEOS_GIT_HASH%% -ENV GDAL_GIT_HASH %%GDAL_GIT_HASH%% - -# Minimal command line test ( fail fast ) -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Testing ogr2ogr PostgreSQL driver. - && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ - || echo "ogr2ogr missing PostgreSQL driver" && exit 1 - -# install postgis -ENV POSTGIS_GIT_HASH %%POSTGIS_GIT_HASH%% - -RUN set -ex \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - ca-certificates \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcunit1-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && cd \ - # postgis - && cd /usr/src/ \ - && git clone https://github.com/postgis/postgis.git \ - && cd postgis \ - && git checkout ${POSTGIS_GIT_HASH} \ - && git log -1 > /_pgis_last_commit.txt \ - && ./autogen.sh \ -# configure options taken from: -# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie - && ./configure \ - --enable-lto \ - && make -j$(nproc) \ - && make install \ -# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 - && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ - && projsync --system-directory --file us_noaa_eshpgn \ - && projsync --system-directory --file us_noaa_prvi \ - && projsync --system-directory --file us_noaa_wmhpgn \ -# regress check - && mkdir /tempdb \ - && chown -R postgres:postgres /tempdb \ - && su postgres -c 'pg_ctl -D /tempdb init' \ - && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ - && ldconfig \ - && cd regress \ - && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ - \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ - && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ - && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ - && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ - \ - && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ - && rm -rf /tempdb \ - && rm -rf /tmp/logfile \ - && rm -rf /tmp/pgis_reg \ -# clean - && cd / \ - && rm -rf /usr/src/postgis \ - && apt-get purge -y --autoremove \ - autoconf \ - automake \ - autotools-dev \ - bison \ - build-essential \ - cmake \ - docbook-xml \ - docbook5-xml \ - g++ \ - git \ - libboost-all-dev \ - libcurl4-gnutls-dev \ - libgmp-dev \ - libjson-c-dev \ - libmpfr-dev \ - libpcre3-dev \ - libprotobuf-c-dev \ - libsqlite3-dev \ - libtiff-dev \ - libtool \ - libxml2-dev \ - libxml2-utils \ - make \ - pkg-config \ - postgresql-server-dev-$PG_MAJOR \ - protobuf-c-compiler \ - xsltproc \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - -# last final test -RUN set -ex \ - && ldconfig \ - && cs2cs \ - && ldd $(which gdalinfo) \ - && gdalinfo --version \ - && gdal-config --formats \ - && geos-config --version \ - && ogr2ogr --version \ - && proj \ - && sfcgal-config --version \ - \ - # Is the "ca-certificates" package installed? (for accessing remote raster files) - # https://github.com/postgis/docker-postgis/issues/307 - && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ - \ - # list last commits. - && find /_pgis_*_last_commit.txt -type f -print -exec cat {} \; \ - # list postgresql, postgis version - && cat _pgis_full_version.txt diff --git a/Dockerfile.template b/Dockerfile.template deleted file mode 100644 index cc3cd2772..000000000 --- a/Dockerfile.template +++ /dev/null @@ -1,28 +0,0 @@ -# -# %%TXT_AUTOGENERATED%% -# - -FROM postgres:%%PG_MAJOR%%-%%DEBIAN_VERSION%% - -LABEL maintainer="PostGIS Project - https://postgis.net" \ - org.opencontainers.image.description="PostGIS %%POSTGIS_VERSION%% spatial database extension with PostgreSQL %%PG_MAJOR%% %%DEBIAN_VERSION%%" \ - org.opencontainers.image.source="https://github.com/postgis/docker-postgis" - -ENV POSTGIS_MAJOR %%POSTGIS_MAJOR%% -ENV POSTGIS_VERSION %%POSTGIS_VERSION%% - -RUN apt-get update \ - && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ - && apt-get install -y --no-install-recommends \ - # ca-certificates: for accessing remote raster files; - # fix: https://github.com/postgis/docker-postgis/issues/307 - ca-certificates \ - \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ - postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ - && rm -rf /var/lib/apt/lists/* - -RUN mkdir -p /docker-entrypoint-initdb.d -COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh -COPY ./update-postgis.sh /usr/local/bin - diff --git a/Makefile b/Makefile index d8e7c6747..76207116c 100644 --- a/Makefile +++ b/Makefile @@ -1,151 +1,511 @@ +# The registry, repository and image names default to the official but can be overriden +# via environment variables. +# For testing, You can start a local registry with: +# docker run -d -p 5000:5000 --restart=always --name registry registry:2 +# with REGISTRY ?= localhost:5000 -# When processing the rules for tagging and pushing container images with the -# "latest" tag, the following variable will be the version that is considered -# to be the latest. -LATEST_VERSION=16-3.4 - -# The following flags are set based on VERSION and VARIANT environment variables -# that may have been specified, and are used by rules to determine which -# versions/variants are to be processed. If no VERSION or VARIANT environment -# variables were specified, process everything (the default). -do_default=true -do_alpine=true - -# The following logic evaluates VERSION and VARIANT variables that may have -# been previously specified, and modifies the "do" flags depending on the values. -# The VERSIONS variable is also set to contain the version(s) to be processed. -ifdef VERSION - VERSIONS=$(VERSION) # If a version was specified, VERSIONS only contains the specified version - ifdef VARIANT # If a variant is specified, unset all do flags and allow subsequent logic to set them again where appropriate - do_default=false - do_alpine=false - ifeq ($(VARIANT),default) - do_default=true - endif - ifeq ($(VARIANT),alpine) - do_alpine=true - endif - endif - ifeq ("$(wildcard $(VERSION)/alpine)","") # If no alpine subdirectory exists, don't process the alpine version - do_alpine=false - endif -else # If no version was specified, VERSIONS should contain all versions - VERSIONS = $(foreach df,$(wildcard */Dockerfile),$(df:%/Dockerfile=%)) -endif - -# The "latest" tag will only be provided for default images (no variant) so -# only define the dependencies when the default image will be built. -ifeq ($(do_default),true) - BUILD_LATEST_DEP=build-$(LATEST_VERSION) - PUSH_LATEST_DEP=push-$(LATEST_VERSION) - PUSH_DEP=push-latest $(PUSH_LATEST_DEP) - # The "latest" tag shouldn't be processed if a VERSION was explicitly - # specified but does not correspond to the latest version. - ifdef VERSION - ifneq ($(VERSION),$(LATEST_VERSION)) - PUSH_LATEST_DEP= - BUILD_LATEST_DEP= - PUSH_DEP= - endif - endif +ENVFILE = .env +ifeq ($(TEST),true) + ENVFILE = .env.test endif +-include $(ENVFILE) +export -# The repository and image names default to the official but can be overriden -# via environment variables. +REGISTRY ?= docker.io REPO_NAME ?= postgis IMAGE_NAME ?= postgis -DOCKER=docker -DOCKERHUB_DESC_IMG=peterevans/dockerhub-description:latest +ifeq ($(shell uname -m),x86_64) + IMAGE_ARCH=amd64 +else ifeq ($(shell uname -m),aarch64) + IMAGE_ARCH=arm64 +else + $(error Architecture not supported) +endif -GIT=git -OFFIMG_LOCAL_CLONE=$(HOME)/official-images -OFFIMG_REPO_URL=https://github.com/docker-library/official-images.git +PUBLIC_IMAGE_NAME:=$(IMAGE_NAME) +ifeq ($(ENABLE_IMAGE_ARCH),true) + IMAGE_NAME:=$(IMAGE_NAME)-$(IMAGE_ARCH) +endif +IMAGE_VERSION_ID :="" +ifeq ($(ENABLE_IMAGE_VERSION_ID),true) +# Note: Make sure to keep this synchronized with the corresponding section in ./tools/environment_init.sh +ifeq ($(shell git rev-parse --git-dir 2>/dev/null),) +$(warning Warning: Not in a git repository. Using fallback values for IMAGE_VERSION_ID.) +COMMIT_DATE=00000000 +COMMIT_HASH=00000000 +else +COMMIT_DATE=$(shell git log -1 --format='%cd' --date=format:'%Y%m%d') +COMMIT_HASH=$(shell git log -1 --pretty=format:'%h') +endif +BUILD_WEEK=$(shell date '+%Yw%V') +IMAGE_VERSION_ID=-ver$(COMMIT_DATE)-$(COMMIT_HASH)-$(BUILD_WEEK) +endif -build: $(foreach version,$(VERSIONS),build-$(version)) +PUSH_FULL_IMAGENAME = ;$(DOCKER) image push $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME): +FULL_IMAGENAME_WITH_T = -t $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME): -all: update build test +DOCKER ?=docker +DOCKERHUB_DESC_IMG=peterevans/dockerhub-description:latest +DOCKER_BUILDOPT ?= --network=host --progress=plain -update: - $(DOCKER) run --rm -v $$(pwd):/work -w /work buildpack-deps ./update.sh +GIT ?=git +OFFIMG_LOCAL_CLONE ?=$(HOME)/official-images +OFFIMG_REPO_URL ?=https://github.com/docker-library/official-images.git +# Default target: help +.DEFAULT_GOAL := help -### RULES FOR BUILDING ### +# Dynamically determine versions and variants based on +# the existence of Dockerfile at the depth of two directories +# where the first directory names starting with a number. +DOCKERFILE_DIRS := $(shell find . -mindepth 2 -maxdepth 2 -type d -exec test -e '{}/Dockerfile' \; -print | sed 's|./||' | awk '/^[0-9]/ {print}') +VERSIONS := $(sort $(foreach dir,$(DOCKERFILE_DIRS),$(firstword $(subst /, ,$(dir))))) +VARIANTS := $(sort $(foreach dir,$(DOCKERFILE_DIRS),$(lastword $(subst /, ,$(dir))))) -define build-version -build-$1: -ifeq ($(do_default),true) - $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) $1 - $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1) -endif -ifeq ($(do_alpine),true) -ifneq ("$(wildcard $1/alpine)","") - $(DOCKER) build --pull -t $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine $1/alpine - $(DOCKER) images $(REPO_NAME)/$(IMAGE_NAME):$(shell echo $1)-alpine +check_variant: +ifeq ($(VARIANT),default) + $(error VARIANT is set to 'default', which is not allowed!) endif +ifeq ($(VARIANT),alpine) + $(error VARIANT is set to 'alpine', which is not allowed!) endif + +# Build targets for each version-variant combination +define build-target +build-$(1)-$(2): check_variant \ + $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),build-$(shell echo $(1) | cut -d- -f1,2)-$(2)) + @echo '::Building $(FULL_IMAGENAME_WITH_T)$(1)-$(2) $(IMAGE_VERSION_ID)' + @echo ':::::: dependency: $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),build-$(shell echo $(1) | cut -d- -f1,2)-$(2)) ' + $(DOCKER) build $(DOCKER_BUILDOPT) \ + --build-arg="REGISTRY=$(REGISTRY)" \ + --build-arg="REPO_NAME=$(REPO_NAME)" \ + --build-arg="IMAGE_NAME=$(IMAGE_NAME)" \ + $(if $(filter 1,$(shell echo $(1) | grep -o '-' | wc -l)), --pull ) \ + $(shell cat $(1)/$(2)/tags | sed 's#\([a-zA-Z0-9.-]*\)#$(subst $,,$(FULL_IMAGENAME_WITH_T))\1#g' ) \ + $(if $(IMAGE_VERSION_ID),$(shell cat $(1)/$(2)/tags | sed 's#\([a-zA-Z0-9.-]*\)#$(subst $,,$(FULL_IMAGENAME_WITH_T))\1$(IMAGE_VERSION_ID)#g' ),) \ + $(1)/$(2) + $(DOCKER) image ls $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) + $(DOCKER) image ls $(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) + $(DOCKER) image inspect $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call build-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) + +# Build targets for each version +define build-version-target +build-$(1): $(shell echo '$(DOCKERFILE_DIRS)' | tr ' ' '\n' | grep ^$(1)/ | sed 's|$(1)/|build-$(1)-|') endef -$(foreach version,$(VERSIONS),$(eval $(call build-version,$(version)))) +$(foreach version,$(VERSIONS),$(eval $(call build-version-target,$(version)))) +# General build target +build: $(foreach dir,$(DOCKERFILE_DIRS),build-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))) -## RULES FOR TESTING ### +# -------------------------------------------------- test-prepare: ifeq ("$(wildcard $(OFFIMG_LOCAL_CLONE))","") + @echo '::Cloning official-images $(OFFIMG_LOCAL_CLONE)' $(GIT) clone $(OFFIMG_REPO_URL) $(OFFIMG_LOCAL_CLONE) +else + @echo '::Updating official-images : $(OFFIMG_LOCAL_CLONE)' + cd $(OFFIMG_LOCAL_CLONE) && $(GIT) pull origin master endif -test: $(foreach version,$(VERSIONS),test-$(version)) +# Test targets for each version-variant combination +define test-target +test-$(1)-$(2): test-prepare \ + build-$1-$(2) \ + $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),test-$(shell echo $(1) | cut -d- -f1,2)-$(2)) + @echo ':Testing $(1)/$(2)' - $(shell cat $(1)/$(2)/tags | cut -d' ' -f1) + @echo ':::::: dependency: $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),test-$(shell echo $(1) | cut -d- -f1,2)-$(2)) ' + $(OFFIMG_LOCAL_CLONE)/test/run.sh \ + -c $(OFFIMG_LOCAL_CLONE)/test/config.sh \ + -c test/postgis-config.sh \ + $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) -define test-version -test-$1: test-prepare build-$1 -ifeq ($(do_default),true) - $(OFFIMG_LOCAL_CLONE)/test/run.sh -c $(OFFIMG_LOCAL_CLONE)/test/config.sh -c test/postgis-config.sh $(REPO_NAME)/$(IMAGE_NAME):$(version) -endif -ifeq ($(do_alpine),true) -ifneq ("$(wildcard $1/alpine)","") - $(OFFIMG_LOCAL_CLONE)/test/run.sh -c $(OFFIMG_LOCAL_CLONE)/test/config.sh -c test/postgis-config.sh $(REPO_NAME)/$(IMAGE_NAME):$(version)-alpine -endif -endif endef -$(foreach version,$(VERSIONS),$(eval $(call test-version,$(version)))) +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call test-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# Build targets for each version +define test-version-target +test-$(1): $(shell echo '$(DOCKERFILE_DIRS)' | tr ' ' '\n' | grep ^$(1)/ | sed 's|$(1)/|test-$(1)-|') +endef +$(foreach version,$(VERSIONS),$(eval $(call test-version-target,$(version)))) +# General test target +test: $(foreach dir,$(DOCKERFILE_DIRS),test-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))) -### RULES FOR TAGGING ### +# -------------------------------------------------- +# Push targets for each version-variant combination +define push-target +push-$(1)-$(2): $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),push-$(shell echo $(1) | cut -d- -f1,2)-$(2)) + @echo '::push $(1)/$(2)' + # push all image tags + $(foreach tag,$(shell cat $(1)/$(2)/tags), \ + echo " --> push1: $(tag) " && \ + $(DOCKER) image push $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(tag) ; \ + ) -tag-latest: $(BUILD_LATEST_DEP) - $(DOCKER) image tag $(REPO_NAME)/$(IMAGE_NAME):$(LATEST_VERSION) $(REPO_NAME)/$(IMAGE_NAME):latest + $(if $(IMAGE_VERSION_ID), \ + # push all image tags - with version id ( -verYYYYMMDD-XXXXXX-YYYYwW W) + $(foreach tag,$(shell cat $(1)/$(2)/tags), \ + echo " --> push2: $(tag)$(IMAGE_VERSION_ID) " && \ + $(DOCKER) image push $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(tag)$(IMAGE_VERSION_ID) ; \ + ),) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call push-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# Build targets for each version +define push-version-target +push-$(1): $(shell echo '$(DOCKERFILE_DIRS)' | tr ' ' '\n' | grep ^$(1)/ | sed 's|$(1)/|push-$(1)-|') +endef +$(foreach version,$(VERSIONS),$(eval $(call push-version-target,$(version)))) +# General push target +push: $(foreach dir,$(DOCKERFILE_DIRS),push-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))) -### RULES FOR PUSHING ### -push: $(foreach version,$(VERSIONS),push-$(version)) $(PUSH_DEP) +# -------------------------------------------------- +# Manifest targets for each version-variant combination +define manifest-target +manifest-$(1)-$(2): $(if $(filter 2,$(shell echo $(1) | grep -o '-' | wc -l)),manifest-$(shell echo $(1) | cut -d- -f1,2)-$(2)) + @echo '::Manifest $(1)/$(2)' + $(foreach tag,$(shell cat $(1)/$(2)/tags), \ + echo " --> manifest: $(1)/$(2):$(tag) " && \ + manifest-tool \ + $(if $(findstring localhost,$(REGISTRY)),--insecure --plain-http) \ + push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template $(REGISTRY)/$(REPO_NAME)/$(PUBLIC_IMAGE_NAME)-ARCHVARIANT:$(tag) \ + --target $(REGISTRY)/$(REPO_NAME)/$(PUBLIC_IMAGE_NAME):$(tag) || true; \ + ) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call manifest-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) -define push-version -push-$1: test-$1 -ifeq ($(do_default),true) - $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):$(version) -endif -ifeq ($(do_alpine),true) -ifneq ("$(wildcard $1/alpine)","") - $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):$(version)-alpine -endif -endif +# Manifest targets for each version +define manifest-version-target +manifest-$(1): $(shell echo '$(DOCKERFILE_DIRS)' | tr ' ' '\n' | grep ^$(1)/ | sed 's|$(1)/|manifest-$(1)-|') endef -$(foreach version,$(VERSIONS),$(eval $(call push-version,$(version)))) +$(foreach version,$(VERSIONS),$(eval $(call manifest-version-target,$(version)))) +# General manifest target +manifest: $(foreach dir,$(DOCKERFILE_DIRS),manifest-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))) + + + +# -------------------------------------------------- +push-readme: + @echo 'Docker pull $(DOCKERHUB_DESC_IMG)' + $(DOCKER) pull $(DOCKERHUB_DESC_IMG); + @echo 'Docker push README $(DOCKERHUB_DESC_IMG)' + @echo 'DOCKERHUB_REPOSITORY="$(DOCKERHUB_README_REPOSITORY)"' + $(DOCKER) run -v "$(PWD)":/workspace \ + -e DOCKERHUB_USERNAME="$(DOCKERHUB_USERNAME)" \ + -e DOCKERHUB_PASSWORD="$(DOCKERHUB_ACCESS_TOKEN)" \ + -e DOCKERHUB_REPOSITORY="$(DOCKERHUB_README_REPOSITORY)" \ + -e README_FILEPATH="/workspace/README.md" $(DOCKERHUB_DESC_IMG); + + +#---------------------------------------------------------- +define scan-target +scan-$(1)-$(2): + $(DOCKER) run \ + --pull always --rm -v $$(pwd)/trivy_cache:/root/.cache/ \ + ghcr.io/aquasecurity/trivy:latest image --ignore-unfixed \ + $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call scan-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# -------------------------------------------------- + +#---------------------------------------------------------- +define dive-target +dive-$(1)-$(2): + CI=true tools/dive \ + $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call dive-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# -------------------------------------------------- + + +# -------------------------------------------------- +# password: f62ba0 == echo -n "postgis" | md5sum | cut -c 1-6 +define start-target +start-$(1)-$(2): + $(DOCKER) run \ + --name postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) \ + -e POSTGRES_PASSWORD="pwf62ba0-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1)" \ + -v postgisdataf62ba0-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1):/var/lib/postgresql/data \ + -d $(REGISTRY)/$(REPO_NAME)/$(IMAGE_NAME):$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call start-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# -------------------------------------------------- +define stop-target +stop-$(1)-$(2): + $(DOCKER) stop postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call stop-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# -------------------------------------------------- +define psql-target +psql-$(1)-$(2): + $(DOCKER) exec -ti postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1) psql -U postgres +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call psql-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) +# -------------------------------------------------- +define clean-target +clean-$(1)-$(2): + @if [ "$$(docker ps -a -q -f name=postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1))" ]; then \ + $(DOCKER) rm $$(docker ps -a -q -f name=postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1)); \ + else \ + echo "No such container to remove : postgis-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1)"; \ + fi + @if [ "$$(docker volume ls -q -f name=postgisdataf62ba0-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1))" ]; then \ + docker volume rm postgisdataf62ba0-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1); \ + else \ + echo "No such volume to remove : postgisdataf62ba0-$(shell cat $(1)/$(2)/tags | cut -d' ' -f1)"; \ + fi +endef +$(foreach dir,$(DOCKERFILE_DIRS),$(eval $(call clean-target,$(word 1,$(subst /, ,$(dir))),$(word 2,$(subst /, ,$(dir)))))) + +# docker rm $(docker ps -a -f name=changedetection.io -q) +# -------------------------------------------------- +all: check_variant update build test + +dockerlist: + docker images | grep "${REPO_NAME}/${IMAGE_NAME}" || true + +update: + @echo '::Updating Dockerfiles' + $(DOCKER) pull buildpack-deps + $(DOCKER) run --rm -v $$(pwd):/work -w /work buildpack-deps ./update.sh + +check-gh-rate: + @echo 'Checking github ratelimit ...' + @curl -sI https://api.github.com/users/octocat | grep x-ratelimit + +check_version: + @echo "ENABLE_IMAGE_ARCH=$(ENABLE_IMAGE_ARCH)" + @echo "ENABLE_IMAGE_VERSION_ID=$(ENABLE_IMAGE_VERSION_ID)" + @echo "IMAGE_ARCH=$(IMAGE_ARCH)" + @echo "IMAGE_VERSION_ID=$(IMAGE_VERSION_ID)" + +# Rule to run shellcheck on all .sh files in the current directory, subdirectories, and sub-subdirectories. +lint: + shellcheck *.sh ./*/*.sh ./*/*/*.sh ./*/*/*/*.sh -x + +shfmt: + shfmt -i 4 -w *.sh + shfmt -i 4 -w ./tools/*.sh + shfmt -i 4 -w ./test/*.sh + shfmt -i 4 -w ./test/tests/*/*.sh + +lregistryinfo: + echo " ---- Registry info ---- " + curl --location --silent --request GET "http://localhost:5000/v2/_catalog?page=1" | jq '.' + curl --location --silent --request GET "http://localhost:5000/v2/${REPO_NAME}/${IMAGE_NAME}/tags/list?page=1" | jq '.' + +# Remove all local images with the name localhost:5000/ and librarytest +# In a Makefile, the $ character has a special meaning, so you indeed need to escape it by using $$ instead of a single $. +imageclean: + docker image ls | grep "^librarytest" | awk '{print $$3}' | sort -u | xargs -rt docker rmi -f + docker image ls | grep "^localhost:5000/" | awk '{print $$3}' | sort -u | xargs -rt docker rmi -f + +imageclean_${REPO_NAME}_${IMAGE_NAME}: + docker image ls | grep "^${REPO_NAME}/${IMAGE_NAME}" | awk '{print $$3}' | sort -u | xargs -rt docker rmi -f -push-latest: tag-latest $(PUSH_LATEST_DEP) - $(DOCKER) image push $(REPO_NAME)/$(IMAGE_NAME):latest - @$(DOCKER) run -v "$(PWD)":/workspace \ - -e DOCKERHUB_USERNAME='$(DOCKERHUB_USERNAME)' \ - -e DOCKERHUB_PASSWORD='$(DOCKERHUB_ACCESS_TOKEN)' \ - -e DOCKERHUB_REPOSITORY='$(REPO_NAME)/$(IMAGE_NAME)' \ - -e README_FILEPATH='/workspace/README.md' $(DOCKERHUB_DESC_IMG) +# Add new PostgreSQL version support +# Usage: make add-postgres-version PG_VERSION=19 POSTGIS_VERSION=3.5 TYPE=master +# TYPE options: master (latest debian), postgis (all debian+alpine variants), bundle (latest debian) +add-postgres-version: + @if [ -z "$(PG_VERSION)" ]; then \ + echo "Error: PG_VERSION is required."; \ + echo "Usage: make add-postgres-version PG_VERSION=19 POSTGIS_VERSION=3.5 TYPE=master"; \ + echo " TYPE options: master (latest debian), postgis (all debian+alpine), bundle (latest debian)"; \ + exit 1; \ + fi + @if [ -z "$(POSTGIS_VERSION)" ]; then \ + echo "Error: POSTGIS_VERSION is required."; \ + echo "Usage: make add-postgres-version PG_VERSION=19 POSTGIS_VERSION=3.5 TYPE=master"; \ + echo " TYPE options: master (latest debian), postgis (all debian+alpine), bundle (latest debian)"; \ + exit 1; \ + fi + @if [ -z "$(TYPE)" ]; then \ + echo "Error: TYPE is required."; \ + echo "Usage: make add-postgres-version PG_VERSION=19 POSTGIS_VERSION=3.5 TYPE=master"; \ + echo " TYPE options: master (latest debian), postgis (all debian+alpine), bundle (latest debian)"; \ + exit 1; \ + fi + @echo "Adding PostgreSQL $(PG_VERSION) with PostGIS $(POSTGIS_VERSION) support ($(TYPE) type)..." + @echo "Step 1: Adding $(PG_VERSION) to tools/versions.sh postgres_versions" + @if ! grep -q " $(PG_VERSION)" tools/versions.sh; then \ + sed -i 's/postgres_versions="\([^"]*\)"/postgres_versions="\1 $(PG_VERSION)"/' tools/versions.sh; \ + echo " Added $(PG_VERSION) to postgres_versions"; \ + else \ + echo " $(PG_VERSION) already exists in postgres_versions"; \ + fi + @echo "Step 2: Creating directory structure based on type $(TYPE)" + @DEBIAN_VARIANTS=$$(grep '^debian_variants=' tools/versions.sh | cut -d'"' -f2 | xargs); \ + ALPINE_VARIANTS=$$(grep '^alpine_variants=' tools/versions.sh | cut -d'"' -f2 | xargs); \ + DEBIAN_LATEST=$$(grep '^debian_latest=' tools/versions.sh | cut -d'"' -f2); \ + if [ "$(TYPE)" = "master" ]; then \ + echo " Creating master variant ($$DEBIAN_LATEST only)"; \ + mkdir -p $(PG_VERSION)-master/$$DEBIAN_LATEST; \ + touch $(PG_VERSION)-master/$$DEBIAN_LATEST/Dockerfile; \ + elif [ "$(TYPE)" = "postgis" ]; then \ + echo " Creating PostGIS variant (all debian + alpine variants)"; \ + for variant in $$DEBIAN_VARIANTS $$ALPINE_VARIANTS; do \ + echo " Creating $(PG_VERSION)-$(POSTGIS_VERSION)/$$variant"; \ + mkdir -p $(PG_VERSION)-$(POSTGIS_VERSION)/$$variant; \ + touch $(PG_VERSION)-$(POSTGIS_VERSION)/$$variant/Dockerfile; \ + done; \ + elif [ "$(TYPE)" = "bundle" ]; then \ + echo " Creating bundle variant ($$DEBIAN_LATEST only)"; \ + mkdir -p $(PG_VERSION)-$(POSTGIS_VERSION)-bundle0/$$DEBIAN_LATEST; \ + touch $(PG_VERSION)-$(POSTGIS_VERSION)-bundle0/$$DEBIAN_LATEST/Dockerfile; \ + else \ + echo "Error: Invalid TYPE. Must be master, postgis, or bundle"; \ + exit 1; \ + fi + @echo "Step 3: Adding configuration to locked.yml" + @if [ "$(TYPE)" = "master" ]; then \ + echo "" >> locked.yml; \ + echo "'$(PG_VERSION)-master':" >> locked.yml; \ + echo " 'bookworm':" >> locked.yml; \ + echo " _comment: \"source: ./locked.yml - PostgreSQL $(PG_VERSION) master testing\"" >> locked.yml; \ + echo " tags: '$(PG_VERSION)-master-bookworm $(PG_VERSION)-master'" >> locked.yml; \ + echo " postgis: 'master'" >> locked.yml; \ + echo " readme_group: 'test'" >> locked.yml; \ + echo " PG_MAJOR: '$(PG_VERSION)'" >> locked.yml; \ + echo " PG_DOCKER: '$(PG_VERSION)beta1'" >> locked.yml; \ + echo " arch: 'amd64 arm64'" >> locked.yml; \ + echo " template: 'Dockerfile.master.template'" >> locked.yml; \ + echo " initfile: 'initdb-postgis.sh'" >> locked.yml; \ + echo " POSTGIS_CHECKOUT: 'master'" >> locked.yml; \ + echo " POSTGIS_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " CGAL_CHECKOUT: 'master'" >> locked.yml; \ + echo " CGAL_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " SFCGAL_CHECKOUT: 'master'" >> locked.yml; \ + echo " SFCGAL_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " PROJ_CHECKOUT: 'master'" >> locked.yml; \ + echo " PROJ_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " GDAL_BUILD: 'with_extra'" >> locked.yml; \ + echo " GDAL_CHECKOUT: 'master'" >> locked.yml; \ + echo " GDAL_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " GEOS_CHECKOUT: 'main'" >> locked.yml; \ + echo " GEOS_CHECKOUT_SHA1: 'nocheck'" >> locked.yml; \ + echo " BOOST_VERSION: '1.74.0'" >> locked.yml; \ + echo " Added $(PG_VERSION)-master configuration to locked.yml"; \ + else \ + echo " For PostGIS/bundle variants, configuration will be auto-generated by update.sh"; \ + fi + @echo "Step 4: Adding optional pg_hint_plan support to tools/versions.sh" + @if ! grep -q "get_latest_version_and_hash_optional.*REL$(PG_VERSION)" tools/versions.sh; then \ + sed -i '/get_latest_version_and_hash_optional.*REL18/a get_latest_version_and_hash_optional "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL$(PG_VERSION) ""' tools/versions.sh; \ + echo " Added REL$(PG_VERSION) pg_hint_plan support"; \ + else \ + echo " REL$(PG_VERSION) pg_hint_plan support already exists"; \ + fi + @echo "" + @echo "✅ Successfully created PostgreSQL $(PG_VERSION) directory structure!" + @echo "" + @echo "Next steps:" + @echo " 1. Run update script: ./update.sh" + @if [ "$(TYPE)" = "master" ]; then \ + echo " 2. Build the image: make build-$(PG_VERSION)-master-bookworm"; \ + echo " 3. Test the image: make test-$(PG_VERSION)-master-bookworm"; \ + echo " 4. Start container: make start-$(PG_VERSION)-master-bookworm"; \ + echo " 5. Connect to DB: make psql-$(PG_VERSION)-master-bookworm"; \ + elif [ "$(TYPE)" = "postgis" ]; then \ + echo " 2. Build all variants: make build-$(PG_VERSION)-$(POSTGIS_VERSION)"; \ + echo " 3. Test all variants: make test-$(PG_VERSION)-$(POSTGIS_VERSION)"; \ + elif [ "$(TYPE)" = "bundle" ]; then \ + echo " 2. Build the bundle: make build-$(PG_VERSION)-$(POSTGIS_VERSION)-bundle0-bookworm"; \ + echo " 3. Test the bundle: make test-$(PG_VERSION)-$(POSTGIS_VERSION)-bundle0-bookworm"; \ + fi + @echo "" + @echo "Created directories:" + @DEBIAN_VARIANTS=$$(grep '^debian_variants=' tools/versions.sh | cut -d'"' -f2 | xargs); \ + ALPINE_VARIANTS=$$(grep '^alpine_variants=' tools/versions.sh | cut -d'"' -f2 | xargs); \ + DEBIAN_LATEST=$$(grep '^debian_latest=' tools/versions.sh | cut -d'"' -f2); \ + if [ "$(TYPE)" = "master" ]; then \ + echo " - $(PG_VERSION)-master/$$DEBIAN_LATEST/"; \ + elif [ "$(TYPE)" = "postgis" ]; then \ + for variant in $$DEBIAN_VARIANTS $$ALPINE_VARIANTS; do \ + echo " - $(PG_VERSION)-$(POSTGIS_VERSION)/$$variant/"; \ + done; \ + elif [ "$(TYPE)" = "bundle" ]; then \ + echo " - $(PG_VERSION)-$(POSTGIS_VERSION)-bundle0/$$DEBIAN_LATEST/"; \ + fi + @echo "" + @echo "Modified files:" + @echo " - tools/versions.sh (postgres_versions and pg_hint_plan)" + @if [ "$(TYPE)" = "master" ]; then \ + echo " - locked.yml (added $(PG_VERSION)-master configuration)"; \ + fi + @echo "" + @echo "Note: versions.json will be auto-generated when you run ./update.sh" +# Help target +help: check_variant + @echo ' Available make targets:' + @echo '------------------------------------ ' + @echo '# build : Build the docker image versions and variants' + @echo $(foreach version,$(VERSIONS),' build-$(version)') + @echo $(foreach dir,$(DOCKERFILE_DIRS),' build-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo ' ' + @echo '# test : Test the docker image versions and variants' + @echo $(foreach version,$(VERSIONS),' test-$(version)') + @echo $(foreach dir,$(DOCKERFILE_DIRS),' test-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo ' ' + @echo '# push : Push to the registry the docker image versions and variants' + @echo $(foreach version,$(VERSIONS),' push-$(version)') + @echo $(foreach dir,$(DOCKERFILE_DIRS),' push-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo ' ' + @echo '# manifest : Manifest registry the docker image versions and variants' + @echo $(foreach version,$(VERSIONS),' manifest-$(version)') + @echo $(foreach dir,$(DOCKERFILE_DIRS),' manifest-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo ' ' + @echo '# Scan the docker image, using aquasec/trivy' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' scan-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo '# Dive the docker image, using wagoodman/dive' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' dive-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo '# Start the docker image' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' start-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo '# Stop the docker image' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' stop-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo '# psql exec the docker image' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' psql-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo '# clean docker image and volume' + @echo $(foreach dir,$(DOCKERFILE_DIRS),' clean-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') + @echo ' ' + @echo 'add-postgres-version PG_VERSION=X PG_DOCKER_TAG=Y : Add new PostgreSQL version support' + @echo 'all : Local run: "update" "build" "test" (without push)' + @echo 'check_version: Check the architecture and version id' + @echo 'check-gh-rate: Check the github ratelimit' + @echo 'dockerlist : List the docker images' + @echo 'help : This help file' + @echo 'imageclean : Remove all local images with the name localhost:5000/ and librarytest' + @echo 'imageclean_${REPO_NAME}_${IMAGE_NAME} : Remove all local images with the name ${REPO_NAME}/${IMAGE_NAME}' + @echo 'lint : Run shellcheck on all .sh files' + @echo 'push-readme : Push README.md to Dockerhub' + @echo 'shfmt : Format the shell scripts' + @echo 'test-prepare : Clone official-images repository' + @echo 'update : Generate/Update all Dockerfiles' + @echo '------------------------------------ ' + @echo 'You can check the the command without executing: make -n ' + @echo ' ' -.PHONY: build all update test-prepare test tag-latest push push-latest \ - $(foreach version,$(VERSIONS),build-$(version)) \ - $(foreach version,$(VERSIONS),test-$(version)) \ - $(foreach version,$(VERSIONS),push-$(version)) +.PHONY: help build all update test-prepare test push push-readme manifest add-postgres-version \ + check-gh-rate check_version dockerlist lint imageclean imageclean_${REPO_NAME}_${IMAGE_NAME} \ + $(foreach version,$(VERSIONS),' build-$(version)') \ + $(foreach dir,$(DOCKERFILE_DIRS),' build-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach version,$(VERSIONS),' test-$(version)') \ + $(foreach dir,$(DOCKERFILE_DIRS),' test-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach version,$(VERSIONS),' push-$(version)') \ + $(foreach dir,$(DOCKERFILE_DIRS),' push-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach version,$(VERSIONS),' manifest-$(version)') \ + $(foreach dir,$(DOCKERFILE_DIRS),' manifest-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' scan-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' dive-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' start-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' stop-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' psql-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') \ + $(foreach dir,$(DOCKERFILE_DIRS),' clean-$(word 1,$(subst /, ,$(dir)))-$(word 2,$(subst /, ,$(dir)))') diff --git a/README.md b/README.md index 7877bc985..7c3e2ea36 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,23 @@ -# postgis/postgis +# 🚧🔧💡🧹 WIP: Experimental development: -[![Build Status](https://github.com/postgis/docker-postgis/workflows/Docker%20PostGIS%20CI/badge.svg)](https://github.com/postgis/docker-postgis/actions) [![Join the chat at https://gitter.im/postgis/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/postgis/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +* 🧪🐳 test images (amd64 + arm64) for the users: https://hub.docker.com/r/imresamu/postgis + * 🧪 internal amd64 only repo: https://hub.docker.com/r/imresamu/postgis-amd64/tags + * 🧪 internal arm64 only repo: https://hub.docker.com/r/imresamu/postgis-arm64/tags +* 🧪 code: https://github.com/ImreSamu/docker-postgis +* Status: Experimental, under active development -The `postgis/postgis` image provides tags for running Postgres with [PostGIS](http://postgis.net/) extensions installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for PostGIS 3.4.x, which is compatible with PostgreSQL versions 12, 13, 14, 15, and 16. For PostgreSQL version 11, the image supports PostGIS 3.3, as it is not compatible with PostGIS 3.4. Additionally, an image version is provided which is built from the latest two versions of Postgres (15, 16) with versions of PostGIS and its dependencies built from their respective master branches. +------------------------ +# 🐳🐘🌍 postgis/postgis +[![Build Status](https://github.com/imresamu/docker-postgis/workflows/Build%20PostGIS%20images/badge.svg)](https://github.com/imresamu/docker-postgis/actions) [![Join the chat at https://gitter.im/postgis/docker-postgis](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/postgis/docker-postgis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +**Important:** _Please note that this README document is larger than the 25,000 character limit set by Docker Hub. As a result, the version available on Docker Hub will be trimmed and not complete._ +_For the complete and untrimmed version of the README, it is recommended to visit the project GitHub page:_ https://github.com/ImreSamu/docker-postgis/blob/master/README.md + +The `imresamu/postgis` image provides tags for running Postgres with [PostGIS](http://postgis.net/) extensions installed. This image is based on the official [`postgres`](https://registry.hub.docker.com/_/postgres/) image and provides debian and alpine variants for PostGIS which is compatible with PostgreSQL versions 13, 14, 15, 16 and 17. Additionally, an image version is provided which is built from the latest two versions of Postgres (16,17) with versions of PostGIS and its dependencies built from their respective master branches. This image ensures that the default database created by the parent `postgres` image will have the following extensions installed: -| installed extensions | [initialized](https://github.com/postgis/docker-postgis/blob/master/initdb-postgis.sh)| +| installed extensions | [initialized](https://github.com/imresamu/docker-postgis/blob/master/initdb-postgis.sh)| |---------------------|-----| | `postgis` | yes | | `postgis_topology` | yes | @@ -18,64 +29,192 @@ This image ensures that the default database created by the parent `postgres` im Unless `-e POSTGRES_DB` is passed to the container at startup time, this database will be named after the admin user (either `postgres` or the user specified with `-e POSTGRES_USER`). If you would prefer to use the older template database mechanism for enabling PostGIS, the image also provides a PostGIS-enabled template database called `template_postgis`. -# Versions (2023-09-16) -Supported architecture: `amd64` (also known as X86-64)" +## Versions (2025-06-30) + -Recommended version for new users: `postgis/postgis:16-3.4` +We provide multi-platform image support for the following architectures: -### Debian based (recommended) +- `amd64`: Also known as x86-64. + - Use `--platform=linux/amd64` when specifying the platform. +- `arm64`: Also known as AArch64. + - Use `--platform=linux/arm64` when specifying the platform. -* This Docker-PostGIS version has a cautious release cycle to guarantee high stability. - * By "cautious", we mean it does not always have the latest versions of geos, proj, gdal, and sfcgal packages. -* We use PostGIS, geos, proj, gdal, and sfcgal packages from the Debian repository. - * In the Debian Bullseye repository, the versions are: geos=3.9, gdal=3.2, proj=7.2, and sfcgal=1.3.9. -* This version is easy to extend and has matured over time. -* PostgreSQL 11 is not compatible with PostGIS 3.4, so it remains on PostGIS 3.3. Please note that after November 9, 2023, PostgreSQL 11 will reach its [end-of-life (EOL)](https://www.postgresql.org/support/versioning/) and will no longer receive support. +Notes: +- The `arm64` architecture support is still experimental. Please refer to the 'arch' column in the version information to determine whether an `arm64` version is available for a specific release. +- We currently do not support 32-bit architectures. Our images are only available for 64-bit architectures. -| DockerHub image | Dockerfile | OS | Postgres | PostGIS | -| --------------- | ---------- | -- | -------- | ------- | -| [postgis/postgis:11-3.3](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=11-3.3) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/11-3.3/Dockerfile) | debian:bullseye | 11 | 3.3.4 | -| [postgis/postgis:12-3.4](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=12-3.4) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/12-3.4/Dockerfile) | debian:bullseye | 12 | 3.4.0 | -| [postgis/postgis:13-3.4](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.4) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/13-3.4/Dockerfile) | debian:bullseye | 13 | 3.4.0 | -| [postgis/postgis:14-3.4](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.4) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/14-3.4/Dockerfile) | debian:bullseye | 14 | 3.4.0 | -| [postgis/postgis:15-3.4](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.4) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/15-3.4/Dockerfile) | debian:bullseye | 15 | 3.4.0 | -| [postgis/postgis:16-3.4](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.4) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-3.4/Dockerfile) | debian:bullseye | 16 | 3.4.0 | +## Build Status -### Alpine based +| Arch | Build system | Status| +| ---- | :-: | :-: | +| Amd64| [GithubCI-logs](https://github.com/ImreSamu/docker-postgis/actions/workflows/main.yml) | [![Build PostGIS images](https://github.com/ImreSamu/docker-postgis/actions/workflows/main.yml/badge.svg)](https://github.com/ImreSamu/docker-postgis/actions/workflows/main.yml) | +| Arm64 | [CircleCI-logs](https://app.circleci.com/pipelines/github/ImreSamu/docker-postgis) | [![CircleCI](https://dl.circleci.com/status-badge/img/gh/ImreSamu/docker-postgis/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/ImreSamu/docker-postgis/tree/master) | -* The base operating system is [Alpine Linux](https://alpinelinux.org/). It is designed to be small, simple, and secure, and it's based on [musl libc](https://musl.libc.org/). -* In the Alpine 3.18 version, the package versions are: geos=3.11, gdal=3.6, proj=9.2, and sfcgal=1.4. -* PostGIS is compiled from source, making it a bit more challenging to extend. -* PostgreSQL 11 is not compatible with PostGIS 3.4, so it remains on PostGIS 3.3. Please note that after November 9, 2023, PostgreSQL 11 will reach its [end-of-life (EOL)](https://www.postgresql.org/support/versioning/) and will no longer receive support. +### 🌟Recommended Versions for New Users +For those new to PostGIS, we recommend the following image versions: -| DockerHub image | Dockerfile | OS | Postgres | PostGIS | -| --------------- | ---------- | -- | -------- | ------- | -| [postgis/postgis:11-3.3-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=11-3.3-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/11-3.3/alpine/Dockerfile) | alpine:3.18 | 11 | 3.3.4 | -| [postgis/postgis:12-3.4-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=12-3.4-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/12-3.4/alpine/Dockerfile) | alpine:3.18 | 12 | 3.4.0 | -| [postgis/postgis:13-3.4-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=13-3.4-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/13-3.4/alpine/Dockerfile) | alpine:3.18 | 13 | 3.4.0 | -| [postgis/postgis:14-3.4-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=14-3.4-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/14-3.4/alpine/Dockerfile) | alpine:3.18 | 14 | 3.4.0 | -| [postgis/postgis:15-3.4-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-3.4-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/15-3.4/alpine/Dockerfile) | alpine:3.18 | 15 | 3.4.0 | -| [postgis/postgis:16-3.4-alpine](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-3.4-alpine) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-3.4/alpine/Dockerfile) | alpine:3.18 | 16 | 3.4.0 | +- `imresamu/postgis:17-3.5-bookworm`: This image includes a minimal setup of PostgreSQL with the PostGIS extension. ( debian bookworm based, easy to extend with debian packages ) +- `imresamu/postgis:17-recent-bookworm`: (experimental) Latest postgis with the latest geos,proj,gdal,sfcgal. ( debian based, extending is complex ! ) +- `imresamu/postgis:16-3.5-bundle0-bookworm`: (experimental) This image includes additional geospatial-related extras along with PostgreSQL and PostGIS. -### Test images +### 🥇Debian - bookworm (recommended) -* We provide alpha, beta, release candidate (rc), and development (identified as ~master) versions. -* The template for the `*-master` images is updated manually, which might lead to a delay of a few weeks sometimes. -* The ~master SFCGAL version is 1.4 or higher. The cgal version is locked on the [5.6.x-branch](https://github.com/CGAL/cgal/tree/5.6.x-branch). +- This Docker-PostGIS version has a cautious release cycle to guarantee high stability. + - By "cautious", we mean it does not always have the latest versions of geos, proj, gdal, and sfcgal packages. +- We use PostGIS, geos, proj, gdal, and sfcgal packages from the Debian repository. + The versions are: geos=3.11, gdal=3.6, proj=9.1, and sfcgal=1.4. +- This version is easy to extend and has matured over time. + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`13-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5-bookworm), [`13-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5.3-bookworm), [`13-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 13 | 3.5.3 | +| [`14-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5-bookworm), [`14-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5.3-bookworm), [`14-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 14 | 3.5.3 | +| [`15-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5-bookworm), [`15-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5.3-bookworm), [`15-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 15 | 3.5.3 | +| [`16-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-bookworm), [`16-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5.3-bookworm), [`16-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 16 | 3.5.3 | +| [`17-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-bookworm), [`17-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.3-bookworm), [`17-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5), [`latest`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=latest) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 17 | 3.5.3 | + + +### 📘Debian - bullseye + +- We use PostGIS, geos, proj, gdal, and sfcgal packages from the Debian repository. + - In the Debian Bullseye repository, the versions are: geos=3.9, gdal=3.2, proj=7.2, and sfcgal=1.3.9. +- This version is easy to extend and has matured over time. + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`13-3.5-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5-bullseye), [`13-3.5.2-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5.2-bullseye) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.5/bullseye/Dockerfile) | amd64 arm64 | bullseye | 13 | 3.5.2 | +| [`14-3.5-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5-bullseye), [`14-3.5.2-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5.2-bullseye) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.5/bullseye/Dockerfile) | amd64 arm64 | bullseye | 14 | 3.5.2 | +| [`15-3.5-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5-bullseye), [`15-3.5.2-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5.2-bullseye) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.5/bullseye/Dockerfile) | amd64 arm64 | bullseye | 15 | 3.5.2 | +| [`16-3.5-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-bullseye), [`16-3.5.2-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5.2-bullseye) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.5/bullseye/Dockerfile) | amd64 arm64 | bullseye | 16 | 3.5.2 | +| [`17-3.5-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-bullseye), [`17-3.5.2-bullseye`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.2-bullseye) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.5/bullseye/Dockerfile) | amd64 arm64 | bullseye | 17 | 3.5.2 | + -| DockerHub image | Dockerfile | OS | Postgres | PostGIS | -| --------------- | ---------- | -- | -------- | ------- | -| [postgis/postgis:15-master](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=15-master) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/15-master/Dockerfile) | debian:bullseye | 15 | development: postgis, geos, proj, gdal | -| [postgis/postgis:16-master](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=16-master) | [Dockerfile](https://github.com/postgis/docker-postgis/blob/master/16-master/Dockerfile) | debian:bullseye | 16 | development: postgis, geos, proj, gdal | -## Usage +### 🧪Recent ( experimental ) + +* These images are similar to the debian-based `*-master` images ( same Dockerfile template ) However, for every build, we use the latest released tag from each library (such as postgis, geos, proj, gdal, cgal, sfcgal). +* These images are ideal for testing purposes, but expanding them is not straightforward. +* The specific versions of the libraries used (like postgis, geos, proj, gdal, cgal, sfcgal) can be found in the tags of the image or in the Dockerfile. + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`16-recent-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-recent-bookworm), [`16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm), [`16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm), [`16-recent`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-recent) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-recent/bookworm/Dockerfile) | amd64 arm64 | bookworm | 16 | postgis=tags/3.5.3, geos=tags/3.13.1, proj=tags/9.6.2, gdal=tags/v3.11.0, cgal=tags/v6.0.1, sfcgal=tags/v2.1.0 | +| [`17-recent-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-recent-bookworm), [`17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm), [`17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm), [`17-recent`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-recent), [`recent`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=recent) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-recent/bookworm/Dockerfile) | amd64 arm64 | bookworm | 17 | postgis=tags/3.5.3, geos=tags/3.13.1, proj=tags/9.6.2, gdal=tags/v3.11.0, cgal=tags/v6.0.1, sfcgal=tags/v2.1.0 | + + +### 🧪Debian Geo Bundle ( experimental ) + +This repository provides Debian-based PostGIS Docker images enriched with additional geospatial packages such as [pgRouting](https://pgrouting.org/), [h3-pg]( https://github.com/zachasme/h3-pg), [pgsql-ogr-fdw](https://github.com/pramsey/pgsql-ogr-fdw), [MobilityDB](https://mobilitydb.com/), [PL/Python3](https://www.postgresql.org/docs/current/plpython.html), [pgPointcloud](https://pgpointcloud.github.io/pointcloud/), [pgVector](https://github.com/pgvector/pgvector), [TimeScaleDB](https://www.timescale.com/) and others. +These images serve as a comprehensive solution for various server side geospatial needs. +Please note that the included package list is subject to change as we continue to refine the 'bundle0'. + + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`16-3.5-bundle0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-bundle0-bookworm), [`16-3.5.3-bundle0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5.3-bundle0-bookworm), [`16-3.5-bundle0`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-bundle0) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.5-bundle0/bookworm/Dockerfile) | amd64 arm64 | bookworm | 16 | 3.5.3 | +| [`17-3.5-bundle0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-bundle0-bookworm), [`17-3.5.3-bundle0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.3-bundle0-bookworm), [`17-3.5-bundle0`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-bundle0), [`bundle0`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=bundle0) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.5-bundle0/bookworm/Dockerfile) | amd64 arm64 | bookworm | 17 | 3.5.3 | + + + +### ⛰️Alpine 3.21 based + +- The base operating system is [Alpine Linux](https://alpinelinux.org/). It is designed to be small, simple, and secure, and it's based on [musl libc](https://musl.libc.org/). +- In the Alpine 3.21 version, the package versions are: geos=3.13, gdal=3.10, proj=9.5, and sfcgal=2.0 +- PostGIS is compiled from source, making it a bit more challenging to extend. + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`13-3.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.3-alpine3.21), [`13-3.3.8-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.3.8-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.3/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 13 | 3.3.8 | +| [`13-3.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.4-alpine3.21), [`13-3.4.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.4.4-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.4/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 13 | 3.4.4 | +| [`13-3.5-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5-alpine3.21), [`13-3.5.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5.3-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.5/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 13 | 3.5.3 | +| [`14-3.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.3-alpine3.21), [`14-3.3.8-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.3.8-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.3/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 14 | 3.3.8 | +| [`14-3.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.4-alpine3.21), [`14-3.4.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.4.4-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.4/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 14 | 3.4.4 | +| [`14-3.5-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5-alpine3.21), [`14-3.5.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5.3-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.5/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 14 | 3.5.3 | +| [`15-3.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.3-alpine3.21), [`15-3.3.8-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.3.8-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.3/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 15 | 3.3.8 | +| [`15-3.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.4-alpine3.21), [`15-3.4.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.4.4-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.4/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 15 | 3.4.4 | +| [`15-3.5-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5-alpine3.21), [`15-3.5.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5.3-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.5/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 15 | 3.5.3 | +| [`16-3.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.3-alpine3.21), [`16-3.3.8-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.3.8-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.3/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 16 | 3.3.8 | +| [`16-3.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.4-alpine3.21), [`16-3.4.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.4.4-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.4/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 16 | 3.4.4 | +| [`16-3.5-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-alpine3.21), [`16-3.5.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5.3-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.5/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 16 | 3.5.3 | +| [`17-3.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.4-alpine3.21), [`17-3.4.4-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.4.4-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.4/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 17 | 3.4.4 | +| [`17-3.5-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-alpine3.21), [`17-3.5.3-alpine3.21`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.3-alpine3.21) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.5/alpine3.21/Dockerfile) | amd64 arm64 | alpine3.21 | 17 | 3.5.3 | + + +### ⛰️Alpine 3.22 based + +- The base operating system is [Alpine Linux](https://alpinelinux.org/). It is designed to be small, simple, and secure, and it's based on [musl libc](https://musl.libc.org/). +- In the Alpine 3.22 version, the package versions are: geos=3.13.1, gdal=3.10.2, proj=9.6.0, and sfcgal=2.0.0 +- PostGIS is compiled from source, making it a bit more challenging to extend. + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`13-3.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.4-alpine3.22), [`13-3.4.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.4.4-alpine3.22), [`13-3.4-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.4-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.4/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 13 | 3.4.4 | +| [`13-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5-alpine3.22), [`13-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5.3-alpine3.22), [`13-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=13-3.5-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/13-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 13 | 3.5.3 | +| [`14-3.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.4-alpine3.22), [`14-3.4.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.4.4-alpine3.22), [`14-3.4-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.4-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.4/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 14 | 3.4.4 | +| [`14-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5-alpine3.22), [`14-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5.3-alpine3.22), [`14-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-3.5-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 14 | 3.5.3 | +| [`15-3.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.4-alpine3.22), [`15-3.4.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.4.4-alpine3.22), [`15-3.4-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.4-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.4/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 15 | 3.4.4 | +| [`15-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5-alpine3.22), [`15-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5.3-alpine3.22), [`15-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=15-3.5-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/15-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 15 | 3.5.3 | +| [`16-3.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.4-alpine3.22), [`16-3.4.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.4.4-alpine3.22), [`16-3.4-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.4-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.4/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 16 | 3.4.4 | +| [`16-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-alpine3.22), [`16-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5.3-alpine3.22), [`16-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-3.5-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 16 | 3.5.3 | +| [`17-3.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.4-alpine3.22), [`17-3.4.4-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.4.4-alpine3.22), [`17-3.4-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.4-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.4/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 17 | 3.4.4 | +| [`17-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-alpine3.22), [`17-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5.3-alpine3.22), [`17-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.5-alpine), [`alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 17 | 3.5.3 | + + + +### 🧪Locked ( experimental ) + +* Locked old postgis versions for testing. +* Definition in the [./locked.yml](locked.yml) + * and the image identifiers : -l + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`14-l3.1.9gcp-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-l3.1.9gcp-bookworm), [`14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/14-l3.1.9gcp/bookworm/Dockerfile) | amd64 arm64 | bookworm | 14 | postgis=tags/3.1.9, geos=tags/3.6.6, proj=tags/6.3.1, gdal=tags/v3.6.4, cgal=tags/v5.6, sfcgal=tags/v1.5.1 | + + +### 📋Test images + + These experimental images are designed for testing and development purposes. They include: + + **🔬 Pre-release versions (alpha, beta, rc):** Tagged versions of upcoming PostgreSQL or PostGIS releases that are not yet stable. These use specific version tags (e.g., + `18beta1`, `3.6.0alpha1`) and provide early access to new features for testing compatibility. + + **⚙️ Development builds (`*-master`):** Built from the latest development code in the main branches of PostgreSQL, PostGIS, and all geospatial dependencies (geos, proj, gdal, + cgal, sfcgal). These represent cutting-edge functionality but may contain unstable features. + + **⚠️ Important notes:** + - Pre-release and master images may have breaking changes or bugs + - The `*-master` template is updated manually and may lag behind actual development by a few weeks + - Master builds use SFCGAL 1.5+ and CGAL locked to the [5.6.x-branch](https://github.com/CGAL/cgal/tree/5.6.x-branch) + - Use these images for testing only, not in production environments + + +| `docker.io/imresamu/postgis:` tags | Dockerfile | Arch | OS | Postgres | PostGIS | +| ---- | :-: | :-: | :-: | :-: | :-: | +| [`16-master-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-master-bookworm), [`16-master`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=16-master) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/16-master/bookworm/Dockerfile) | amd64 arm64 | bookworm | 16 | development: postgis, geos, proj, gdal, cgal, sfcgal | +| [`17-3.6.0alpha1-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.6.0alpha1-alpine3.22), [`17-3.6.0alpha1-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-3.6.0alpha1-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-3.6/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 17 | 3.6.0alpha1 | +| [`17-master-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-master-bookworm), [`17-master`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=17-master) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/17-master/bookworm/Dockerfile) | amd64 arm64 | bookworm | 17 | development: postgis, geos, proj, gdal, cgal, sfcgal | +| [`18beta1-3.5-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5-alpine3.22), [`18beta1-3.5.3-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5.3-alpine3.22), [`18beta1-3.5-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/18-3.5/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 18beta1 | 3.5.3 | +| [`18beta1-3.5-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5-bookworm), [`18beta1-3.5.3-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5.3-bookworm), [`18beta1-3.5`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.5) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/18-3.5/bookworm/Dockerfile) | amd64 arm64 | bookworm | 18beta1 | 3.5.3 | +| [`18beta1-3.6.0alpha1-alpine3.22`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.6.0alpha1-alpine3.22), [`18beta1-3.6.0alpha1-alpine`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-3.6.0alpha1-alpine) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/18-3.6/alpine3.22/Dockerfile) | amd64 arm64 | alpine3.22 | 18beta1 | 3.6.0alpha1 | +| [`18beta1-master-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-master-bookworm), [`18beta1-master`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-master) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/18-master/bookworm/Dockerfile) | amd64 arm64 | bookworm | 18beta1 | development: postgis, geos, proj, gdal, cgal, sfcgal | +| [`18beta1-recent-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-recent-bookworm), [`18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm), [`18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm), [`18beta1-recent`](https://registry.hub.docker.com/r/imresamu/postgis/tags?page=1&name=18beta1-recent) | [Dockerfile](https://github.com/imresamu/docker-postgis/blob/master/18-recent/bookworm/Dockerfile) | amd64 arm64 | bookworm | 18beta1 | postgis=tags/3.5.3, geos=tags/3.13.1, proj=tags/9.6.2, gdal=tags/v3.11.0, cgal=tags/v6.0.1, sfcgal=tags/v2.1.0 | + + +## 🚀Usage In order to run a basic container capable of serving a PostGIS-enabled database, start a container as follows: - docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis + docker run --name some-postgis -e POSTGRES_PASSWORD=mysecretpassword -d imresamu/postgis For more detailed instructions about how to start and control your Postgres container, see the documentation for the `postgres` image [here](https://registry.hub.docker.com/_/postgres/). @@ -88,26 +227,26 @@ Once you have started a database container, you can then connect to the database docker network create some-network # Server container - docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d postgis/postgis + docker run --name some-postgis --network some-network -e POSTGRES_PASSWORD=mysecretpassword -d imresamu/postgis # Client container - docker run -it --rm --network some-network postgis/postgis psql -h some-postgis -U postgres + docker run -it --rm --network some-network imresamu/postgis psql -h some-postgis -U postgres Check the documentation on the [`postgres` image](https://registry.hub.docker.com/_/postgres/) and [Docker networking](https://docs.docker.com/network/) for more details and alternatives on connecting different containers. See [the PostGIS documentation](http://postgis.net/docs/postgis_installation.html#create_new_db_extensions) for more details on your options for creating and using a spatially-enabled database. -## Supported Environment Variables: +## 🔧Supported Environment Variables: Since the docker-postgis repository is an extension of the official Docker PostgreSQL repository, all environment variables supported there are also supported here: -* `POSTGRES_PASSWORD` -* `POSTGRES_USER` -* `POSTGRES_DB` -* `POSTGRES_INITDB_ARGS` -* `POSTGRES_INITDB_WALDIR` -* `POSTGRES_HOST_AUTH_METHOD` -* `PGDATA` +- `POSTGRES_PASSWORD` +- `POSTGRES_USER` +- `POSTGRES_DB` +- `POSTGRES_INITDB_ARGS` +- `POSTGRES_INITDB_WALDIR` +- `POSTGRES_HOST_AUTH_METHOD` +- `PGDATA` Read more: https://github.com/docker-library/docs/blob/master/postgres/README.md @@ -116,37 +255,62 @@ Warning: **the Docker specific variables will only have an effect if you start t It's important to note that the environment variables for the Docker image are different from those of the [libpq — C Library](https://www.postgresql.org/docs/current/libpq-envars.html) (`PGDATABASE`,`PGUSER`,`PGPASSWORD` ) -## Troubleshooting tips: +## ⚠️ Troubleshooting tips: Troubleshooting can often be challenging. It's important to know that the docker-postgis repository is an extension of the official Docker PostgreSQL repository. Therefore, if you encounter any issues, it's worth testing whether the problem can be reproduced with the [official PostgreSQL Docker images](https://hub.docker.com/_/postgres). If so, it's recommended to search for solutions based on this. The following websites are suggested: -* Upstream docker postgres repo: https://github.com/docker-library/postgres - * search for the open or closed issues ! -* Docker Community Forums: https://forums.docker.com -* Docker Community Slack: https://dockr.ly/slack -* Stack Overflow: https://stackoverflow.com/questions/tagged/docker+postgresql +- Upstream docker postgres repo: https://github.com/docker-library/postgres + - search for the open or closed issues ! +- Docker Community Forums: https://forums.docker.com +- Docker Community Slack: https://dockr.ly/slack +- Stack Overflow: https://stackoverflow.com/questions/tagged/docker+postgresql If your problem is Postgis related: -* Stack Overflow : docker + postgis https://stackoverflow.com/questions/tagged/docker+postgis -* Postgis issue tracker: https://trac.osgeo.org/postgis/report +- Stack Overflow : docker + postgis https://stackoverflow.com/questions/tagged/docker+postgis +- Postgis issue tracker: https://trac.osgeo.org/postgis/report And if you don't have a postgres docker experience - read this blog post: -* https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/ +- https://www.docker.com/blog/how-to-use-the-postgres-docker-official-image/ -## Security +## 🔒Security It's crucial to be aware that in a cloud environment, with default settings, these images are vulnerable, and there's a high risk of cryptominer infection if the ports are left open. ( [Read More](https://github.com/docker-library/postgres/issues/770#issuecomment-704460980) ) -* Note that ports which are not bound to the host (i.e., `-p 5432:5432` instead of `-p 127.0.0.1:5432:5432`) will be accessible from the outside. This also applies if you configured UFW to block this specific port, as Docker manages its own iptables rules. ( [Read More](https://docs.docker.com/network/iptables/) ) -Recomendations: -* You can add options for using SSL ( [see postgres example](https://github.com/docker-library/postgres/issues/989#issuecomment-1222648067) ) +- Note that ports which are not bound to the host (i.e., `-p 5432:5432` instead of `-p 127.0.0.1:5432:5432`) will be accessible from the outside. This also applies if you configured UFW to block this specific port, as Docker manages its own iptables rules. ( [Read More](https://docs.docker.com/network/iptables/) ) + +#### Recommendations: + +- You can add options for using SSL ( [see postgres example](https://github.com/docker-library/postgres/issues/989#issuecomment-1222648067) ) - `-c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key` -* Or you can use [SSH Tunnels](https://www.postgresql.org/docs/15/ssh-tunnels.html) with `-p 127.0.0.1:5432:5432` +- Or you can use [SSH Tunnels](https://www.postgresql.org/docs/15/ssh-tunnels.html) with `-p 127.0.0.1:5432:5432` -## Known Issues / Errors +#### Security scanner information: + +- Scan the base `postgres` docker Image: +It's important to also scan the base `postgres` Docker image for potential security issues. If your security scanner reports vulnerabilities (known as CVEs) in the image, you may wonder why. To get a better understanding, please read the Docker Library FAQ, especially the section titled ["Why does my security scanner show that an image has CVEs?"](https://github.com/docker-library/faq#why-does-my-security-scanner-show-that-an-image-has-cves) +For more specific issues related to the postgres docker image, you can search using these links: + - [search for repo:docker-library/postgres trivy](https://github.com/search?q=repo%3Adocker-library%2Fpostgres+trivy&type=issues) + - [search for repo:docker-library/postgres CVE](https://github.com/search?q=repo%3Adocker-library%2Fpostgres+CVE&type=issues) + +- Optimizing Security Scans: +It's advisable to focus on scanning and fixing issues that can be resolved. +Use this command to scan for fixable issues only: + * `trivy image --ignore-unfixed postgis/postgis:16-3.4-alpine` + * `trivy image --ignore-unfixed postgres:16-alpine` +For more details, you can read this article: https://pythonspeed.com/articles/docker-security-scanner/ + +#### Limitations on Updates: +Unfortunately, we don't have control over updates to Debian and Alpine distributions or the upstream `postgres` image. +Because of this, there might be some issues that we cannot fix right away. +On the positive side, the `postgis/postgis` images are regenerated every Monday. This process is to ensure they include the latest changes and improvements. As a result, these images are consistently kept up-to-date. + +#### Suggestions Welcome: +We are always open to suggestions to enhance security. If you have any ideas, please let us know. + +## ❗Known Issues / Errors When You encouter errors due to PostGIS update `OperationalError: could not access file "$libdir/postgis-X.X`, run: @@ -166,4 +330,3 @@ NOTICE: version "X.X.X" of extension "postgis_topology" is already installed NOTICE: version "X.X.X" of extension "postgis_tiger_geocoder" is already installed ALTER EXTENSION ``` - diff --git a/doc/developers.md b/doc/developers.md new file mode 100644 index 000000000..8ee1bacd2 --- /dev/null +++ b/doc/developers.md @@ -0,0 +1,34 @@ + +# Developer Documentation + +* 🧪 test images: https://hub.docker.com/r/imresamu/postgis +* 🧪 test github: https://github.com/ImreSamu/docker-postgis + +## Development Goals Prior to Public Discussion: + +- [x] Use Dockerfile templates and version.json, and follow best practices from the official PostgreSQL Dockerfiles as closely as possible. +- [x] Support for multiple Debian and Alpine releases (e.g., Buster, Bullseye, Alpine 3.18) +- [x] Release new Geo bundle version with pgRouting,MobilityDB,H3,... + - [ ] need more test, refactoring +- [x] Support multi tags + - `15-3.4-alpine3.18 15-3.4.0-alpine3.18 15-3.4-alpine alpine` + - `15-3.4-bundle-bookworm 15-3.4.0-bundle-bookworm 15-3.4-bundle bundle` + - `15-master-bookworm 15-master` +- [x] Special tags for the latest versions `alpine`,`bundle`,`latest` +- [x] Automatically update continuous integration (CI) scripts, and maintain `README.md` based on `./version.json` +- [x] Support development repositories with easier setup ( `.env` ) +- [ ] Implement multi-architecture multi-cloud support + - [x] Support amd64 via GitHub Actions `.github/workflows/main.yml` + - [x] Support arm64 via CircleCI (using native arm, not emulated) `.circleci/config.yml` + - [ ] Synchronize CI Tasks + - [ ] Handle manifest creation (complex task) +- [x] Shellcheck verify +- [x] Minimal test flow with local registy ( `./localtest.sh` ) +- [x] New Makefile; with `make help` +- [ ] Refactoring README.md ( Github API 25000 char limit ) +- [ ] Refactoring & Testing +- [ ] Provide developer documentation + + + +https://github.com/dvershinin/lastversion diff --git a/initdb-postgis.sh b/initdb-postgis.sh deleted file mode 100644 index e38ad7d66..000000000 --- a/initdb-postgis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -set -e - -# Perform all actions as $POSTGRES_USER -export PGUSER="$POSTGRES_USER" - -# Create the 'template_postgis' template db -"${psql[@]}" <<- 'EOSQL' -CREATE DATABASE template_postgis IS_TEMPLATE true; -EOSQL - -# Load PostGIS into both template_database and $POSTGRES_DB -for DB in template_postgis "$POSTGRES_DB"; do - echo "Loading PostGIS extensions into $DB" - "${psql[@]}" --dbname="$DB" <<-'EOSQL' - CREATE EXTENSION IF NOT EXISTS postgis; - CREATE EXTENSION IF NOT EXISTS postgis_topology; - -- Reconnect to update pg_setting.resetval - -- See https://github.com/postgis/docker-postgis/issues/288 - \c - CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; - CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder; -EOSQL -done diff --git a/locked.yml b/locked.yml new file mode 100644 index 000000000..f87be0b85 --- /dev/null +++ b/locked.yml @@ -0,0 +1,34 @@ + + +# unique locked versions we want to build +# initialize directory with : touch 14-l3.1.9gcp/bookworm/Dockerfile +# this file will be append to 'version.json' + +# - edited by manually, for locking/creating special versions. +# - this can be used for testing new debian based posgis versions - created from recent(master) template + +'14-l3.1.9gcp': + 'bookworm': + _comment: "source: ./locked.yml" + tags: '14-l3.1.9gcp-bookworm 14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm' + postgis: 'l3.1.9gcp' + readme_group: 'locked' + PG_MAJOR: '14' + PG_DOCKER: '14' + arch: 'amd64 arm64' + template: 'Dockerfile.master.template' + initfile: 'initdb-postgis.sh' + POSTGIS_CHECKOUT: 'tags/3.1.9' + POSTGIS_CHECKOUT_SHA1: '95a641b1747721d7004c5f0133b918d034035319' + PROJ_CHECKOUT: 'tags/6.3.1' + PROJ_CHECKOUT_SHA1: '0e993d9744ecaa2f146bf62c43aecc61809a43ef' + GDAL_BUILD: 'minimal' + GDAL_CHECKOUT: 'tags/v3.6.4' + GDAL_CHECKOUT_SHA1: '7ca88116f5a46d429251361634eb24629f315076' + GEOS_CHECKOUT: 'tags/3.6.6' + GEOS_CHECKOUT_SHA1: '36ea3034fb8719a639a7e7727e54ec8ab2e8a196' + SFCGAL_CHECKOUT: 'tags/v1.5.1' + SFCGAL_CHECKOUT_SHA1: '61f3b08ade49493b56c6bafa98c7c1f84addbc10' + CGAL_CHECKOUT: 'tags/v5.6' + CGAL_CHECKOUT_SHA1: 'de4fa0d7d57b5a997012f2804161386ff4bc0d0f' + BOOST_VERSION: '1.74.0' diff --git a/templates/Dockerfile.alpine.template b/templates/Dockerfile.alpine.template new file mode 100644 index 000000000..c54b65184 --- /dev/null +++ b/templates/Dockerfile.alpine.template @@ -0,0 +1,217 @@ + +ARG PGIS1_BASE_IMAGE=postgres:{{ .[env.variant].PG_DOCKER }}-{{ env.variant }} +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_POSTGIS_CHECKOUT={{ .[env.variant].POSTGIS_CHECKOUT }} +ARG PGIS1_POSTGIS_CHECKOUT_SHA1={{ .[env.variant].POSTGIS_CHECKOUT_SHA1 }} + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL {{ .[env.variant].PG_MAJOR }} {{ env.variant }}" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="{{ .[env.variant].POSTGIS_VERSION }}" \ + org.opencontainers.image.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_CHECKOUT} spatial database extension with PostgreSQL {{ .[env.variant].PG_MAJOR }} {{ env.variant }}" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="{{ .[env.variant].POSTGIS_VERSION }}" \ + org.postgis.base.revision="${PGIS1_POSTGIS_CHECKOUT_SHA1}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.base.source.repository="${PGIS1_POSTGIS_REPOSITORY}" + + +RUN set -eux \ + # Update package cache first + && apk update \ + # Get exact versions of available packages + && GDAL_VERSION=$(apk list --available gdal-dev | grep 'gdal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && GEOS_VERSION=$(apk list --available geos-dev | grep 'geos-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROJ_VERSION=$(apk list --available proj-dev | grep 'proj-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && SFCGAL_VERSION=$(apk list --available sfcgal-dev | grep 'sfcgal-dev-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && JSON_C_VERSION=$(apk list --available json-c | grep 'json-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PROTOBUF_C_VERSION=$(apk list --available protobuf-c | grep 'protobuf-c-' | head -1 | awk '{print $1}' | cut -d'-' -f3-) \ + && PCRE_VERSION=$(apk list --available pcre | grep '^pcre-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + && PERL_VERSION=$(apk list --available perl | grep '^perl-' | head -1 | awk '{print $1}' | cut -d'-' -f2-) \ + \ + # Export build environment for child images ( see example in the end of this file ) + && echo "export GDAL_VERSION=${GDAL_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export GEOS_VERSION=${GEOS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROJ_VERSION=${PROJ_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export SFCGAL_VERSION=${SFCGAL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export JSON_C_VERSION=${JSON_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PROTOBUF_C_VERSION=${PROTOBUF_C_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PCRE_VERSION=${PCRE_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PERL_VERSION=${PERL_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apk add --no-cache --virtual .build-deps \ + ca-certificates \ + gdal-dev=${GDAL_VERSION} \ + geos-dev=${GEOS_VERSION} \ + proj-dev=${PROJ_VERSION} \ + proj-util=${PROJ_VERSION} \ + sfcgal-dev=${SFCGAL_VERSION} \ + \ + # The upstream variable, '$DOCKER_PG_LLVM_DEPS' contains + # the correct versions of 'llvm-dev' and 'clang' for the current version of PostgreSQL. + # This improvement has been discussed in https://github.com/docker-library/postgres/pull/1077 + $DOCKER_PG_LLVM_DEPS \ + \ + autoconf \ + automake \ + bison \ + cunit-dev \ + file \ + g++ \ + gcc \ + gettext-dev \ + git \ + json-c-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + # Note: PCRE2 is not supported in older versions of PostGIS. + # To ensure compatibility with PostGIS version 3.0, PCRE 1 is required. + # If PCRE2 support is needed, please submit an issue on the docker-postgis GitHub repository. + pcre-dev \ + perl \ + protobuf-c-dev \ + \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_POSTGIS_CHECKOUT_SHA1" ]; then \ + echo "ERROR: SHA1 mismatch. Expected: $PGIS1_POSTGIS_CHECKOUT_SHA1, Got: $(git rev-parse HEAD)"; \ + exit 1; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + # build PostGIS - with Link Time Optimization (LTO) enabled + && cd /usr/src/postgis \ + && gettextize \ + && ./autogen.sh \ + && ./configure \ + --enable-lto \ + --with-optimization-flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + --disable-debug \ + && make -j$(nproc) \ + && make install \ + \ + # This section is for refreshing the proj data for the regression tests. + # It serves as a workaround for an issue documented at https://trac.osgeo.org/postgis/ticket/5316 + # This increases the Docker image size by about 1 MB. + && projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn \ + # This section performs a regression check. + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS="--extension --verbose" PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ + # add .postgis-rundeps + && apk add --no-cache --virtual .postgis-rundeps \ + gdal=${GDAL_VERSION} \ + geos=${GEOS_VERSION} \ + proj=${PROJ_VERSION} \ + sfcgal=${SFCGAL_VERSION} \ + json-c=${JSON_C_VERSION} \ + protobuf-c=${PROTOBUF_C_VERSION} \ + pcre=${PCRE_VERSION} \ + # for postgis_restore.pl ; ref: https://github.com/postgis/docker-postgis/issues/373 + perl=${PERL_VERSION} \ + # no locking, system componenets + libstdc++ \ + # ca-certificates: for accessing remote raster files ; need the latest, no locking + # fix https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + # clean + && cd / \ + && rm -rf \ + /usr/src/postgis \ + /usr/local/share/doc \ + /usr/local/share/man \ + && apk del .build-deps \ + # Add system package versions to version report + && apk list --installed | grep -E "(geos|proj|gdal|sfcgal)" >> /_pgis_full_version.txt \ + && echo "Optimization flags: ${PGIS1_OPTIMIZATION_FLAGS}" >> /_pgis_full_version.txt \ + # At the end of the build, we print the collected information + # from the '/_pgis_full_version.txt' file. This is for experimental and internal purposes. + && cat /_pgis_full_version.txt + +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + + +# Draft child image example ( pgrouting ) +#======================================================== +# FROM postgis/postgis:17-3.5-alpine3.22 +# LABEL \ +# # overwrite all org.opencontainers - labels +# maintainer="pgrouting maintainers" \ +# org.opencontainers.image.description="PostGIS with pgrouting" \ +# org.opencontainers.image.source="..." \ +# org.opencontainers.image.version="..." \ +# org.opencontainers.image.revision="..." \ +# org.opencontainers.image.created="..." \ +# org.opencontainers.image.base.name="postgis/postgis:17-3.5-alpine3.22" \ +# # add your org labels +# org.pgrouting.base.maintainer="..." \ +# org.pgrouting.base.optimization="...." +# +# # Install development packages with same versions +# RUN source /usr/local/share/docker-postgis-env.sh \ +# && apk add --no-cache --virtual .pgrouting-build-deps \ +# gdal-dev=${GDAL_VERSION} \ +# geos-dev=${GEOS_VERSION} \ +# $DOCKER_PG_LLVM_DEPS \ +# cmake \ +# boost-dev \ +# g++ \ +# gcc +# .... diff --git a/templates/Dockerfile.bundle0.template b/templates/Dockerfile.bundle0.template new file mode 100644 index 000000000..2f299df92 --- /dev/null +++ b/templates/Dockerfile.bundle0.template @@ -0,0 +1,377 @@ + +# Experimental Geo Bundle package. +# This is a work in progress and not yet ready for production. +# Some packages will be removed from this bundle and others will be added. +# The goal is to have a bundle that includes all the most popular extensions with PostGIS + +# set the base image , make build-* is overwriting with the actual value ! + +ARG REGISTRY={{ env.REGISTRY }} +ARG REPO_NAME={{ env.REPO_NAME }} +ARG IMAGE_NAME={{ env.IMAGE_NAME }} + +ARG PGIS1_BASE_IMAGE=${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:{{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }} + +ARG PGIS1_PGSQL_GZIP_REPOSITORY=https://github.com/pramsey/pgsql-gzip.git +ARG PGIS1_PGSQL_GZIP_CHECKOUT={{ .[env.variant].PGSQL_GZIP_CHECKOUT }} +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1={{ .[env.variant].PGSQL_GZIP_CHECKOUT_SHA1 }} + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY=https://github.com/ossc-db/pg_hint_plan.git +ARG PGIS1_PG_HINT_PLAN_CHECKOUT={{ .[env.variant].PG_HINT_PLAN_CHECKOUT }} +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1={{ .[env.variant].PG_HINT_PLAN_CHECKOUT_SHA1 }} + +ARG PGIS1_DUCKDB_CHECKOUT={{ .[env.variant].DUCKDB_CHECKOUT }} + +# usable for forking the image +ARG PGIS1_OPTIMIZATION_FLAGS=" -O3 -mtune=generic " +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} AS builder + +ARG PGIS1_DUCKDB_CHECKOUT +ARG PGIS1_OPTIMIZATION_FLAGS + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + curl \ + flex \ + g++ \ + git \ + make \ + pgxnclient \ + postgresql-server-dev-$PG_MAJOR \ + unzip \ + wget \ + # pgsql-gzip + zlib1g-dev \ + # sqlite_fdw + sqlite3 \ + # bytemagic + libmagic-dev \ + # pgsoudium \ + libsodium-dev \ + # pg_curl + libcurl4-gnutls-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +FROM builder as builder-gzip + +ARG PGIS1_PGSQL_GZIP_REPOSITORY +ARG PGIS1_PGSQL_GZIP_CHECKOUT +ARG PGIS1_PGSQL_GZIP_CHECKOUT_SHA1 + +RUN set -eux \ + && mkdir -p /pgsql-gzip \ + && cd pgsql-gzip \ + && git init \ + && git remote add origin ${PGIS1_PGSQL_GZIP_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PGSQL_GZIP_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PGSQL_GZIP_CHECKOUT_SHA1" ]; then exit 1; fi \ + && git log -1 > /_pgsql_gzip_last_commit.txt \ + && make -j$(nproc) \ + && make install + + +FROM builder as builder-pgxn + +RUN pgxn install --verbose byteamagic +RUN pgxn install --verbose ddlx +RUN pgxn install --verbose dsef +RUN pgxn install --verbose json_accessors +RUN pgxn install --verbose lostgis +RUN pgxn install --verbose permuteseq +RUN pgxn install --verbose pg_curl # https://github.com/RekGRpth/pg_curl +RUN pgxn install --verbose pg_roaringbitmap +RUN pgxn install --verbose pg_rowalesce +RUN pgxn install --verbose pg_uuidv7 +RUN pgxn install --verbose pg_xenophile +RUN pgxn install --verbose pg_xxhash +RUN pgxn install --verbose pgsodium +RUN pgxn install --verbose pgsql_tweaks +# RUN pgxn install --verbose sqlite_fdw + +{{ if env.version | startswith("17") then ( -}} +# pgxman pg_duckdb is not available / not working for PG17 yet +{{ ) else ( -}} +# pg_duckdb +RUN set -eux \ + && curl -sfL https://install.pgx.sh -o /tmp/pgx-install.sh \ + && chmod +x /tmp/pgx-install.sh \ + && /tmp/pgx-install.sh \ + && rm /tmp/pgx-install.sh +RUN pgxman install pg_duckdb +{{ ) end -}} + +#RUN pgxman install hydra_columnar +#RUN pgxman install pgvectorscale +#RUN pgxman install pg_quack + +FROM builder as builder-other + +ARG PGIS1_PG_HINT_PLAN_REPOSITORY +ARG PGIS1_PG_HINT_PLAN_CHECKOUT +ARG PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1 + +# install pg_hint_plan +RUN set -eux \ + && mkdir pg_hint_plan \ + && cd pg_hint_plan \ + && git init \ + && git remote add origin ${PGIS1_PG_HINT_PLAN_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PG_HINT_PLAN_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Verify that the commit hash matches the known good one + && if [ "$(git rev-parse HEAD)" != "$PGIS1_PG_HINT_PLAN_CHECKOUT_SHA1" ]; then exit 1; fi \ + && make -j$(nproc) \ + && make install + +RUN set -eux \ + && git clone --depth 1 https://github.com/NikolayS/postgres_dba.git \ + && cd postgres_dba \ + && rm -rf .git + +RUN set -eux \ + && git clone --depth 1 https://github.com/dr-jts/pg_svg.git \ + && cd pg_svg \ + && rm -rf .git + #install: psql < /pg_svg/pg-svg-lib.sql + +FROM ${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}:{{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }} + +ARG PGIS1_OPTIMIZATION_FLAGS +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_TIMESCALEDB_TELEMETRY + +# Export build environment for child images (enterprise-grade package version locking) +RUN set -eux \ + # Ensure docker-postgis-env.sh exists (create empty if missing) + && touch /usr/local/share/docker-postgis-env.sh \ + # Export bundle-specific build versions for child images + && echo "# Bundle0 Extension Versions" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_OPTIMIZATION_FLAGS='${PGIS1_OPTIMIZATION_FLAGS}'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PG_HINT_PLAN_CHECKOUT='{{ .[env.variant].PG_HINT_PLAN_CHECKOUT }}'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_DUCKDB_CHECKOUT='{{ .[env.variant].DUCKDB_CHECKOUT }}'" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_PGSQL_GZIP_CHECKOUT='{{ .[env.variant].PGSQL_GZIP_CHECKOUT }}'" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + # Source the environment after populating it + && . /usr/local/share/docker-postgis-env.sh + +# Only override opencontainers labels for bundle-specific info +# org.postgis.base.* labels are inherited from base image and should NOT be overridden +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS Bundle - {{ .[env.variant].PG_DOCKER }}-{{ .[env.variant].postgis }}-{{ env.variant }} with MobilityDB, TimescaleDB, DuckDB and 40+ extensions" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="{{ .[env.variant].POSTGIS_VERSION }}-bundle0" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # Bundle-specific additional extensions (base PostGIS extensions inherited from org.postgis.base.extensions) +{{ if env.version | startswith("17") then ( -}} + org.postgis.bundle0.additional.extensions="timescaledb,mobilitydb,pgsql_http,pgsql_gzip,pgrouting,pgvector,h3,pointcloud,pgaudit,byteamagic,ddlx,dsef,json_accessors,lostgis,permuteseq,pg_curl,pg_roaringbitmap,pg_rowalesce,pg_uuidv7,pg_xenophile,pg_xxhash,pgsodium,pgsql_tweaks,asn1oid,extra_window_functions,first_last_agg,hll,hypopg,icu_ext,jsquery,numeral,ogr_fdw,partman,periods,pg_fact_loader,pg_failover_slots,pg_stat_kcache,pg_wait_sampling,pgl_ddl_deploy,pglogical,pgmp,pgpcre,pgq3,pgsphere,pgtap,pldebugger,plpgsql_check,prefix,prioritize,q3c,repack,rum,show_plans,squeeze" \ + org.postgis.bundle0.excluded.pg17="sqlite_fdw,age,decoderbufs" \ +{{ ) else ( -}} + org.postgis.bundle0.additional.extensions="timescaledb,mobilitydb,pgsql_http,pgsql_gzip,pgrouting,pgvector,h3,pointcloud,pgaudit,byteamagic,ddlx,dsef,json_accessors,lostgis,permuteseq,pg_curl,pg_roaringbitmap,pg_rowalesce,pg_uuidv7,pg_xenophile,pg_xxhash,pgsodium,pgsql_tweaks,sqlite_fdw,age,decoderbufs,asn1oid,extra_window_functions,first_last_agg,hll,hypopg,icu_ext,jsquery,numeral,ogr_fdw,partman,periods,pg_fact_loader,pg_failover_slots,pg_stat_kcache,pg_wait_sampling,pgl_ddl_deploy,pglogical,pgmp,pgpcre,pgq3,pgsphere,pgtap,pldebugger,plpgsql_check,prefix,prioritize,q3c,repack,rum,show_plans,squeeze" \ +{{ ) end -}} + org.postgis.bundle0.permanently.excluded="parray_gin,pg_quack" \ + org.postgis.bundle0.optimization.flags="${PGIS1_OPTIMIZATION_FLAGS}" \ + org.postgis.bundle0.timescaledb.telemetry="${PGIS1_TIMESCALEDB_TELEMETRY}" \ + org.postgis.bundle0.duckdb.version="{{ .[env.variant].DUCKDB_CHECKOUT }}" + +# install all utf8 locales; +# helping: https://github.com/docker-library/docs/tree/master/postgres#locale-customization +RUN set -eux \ + && sed -i -e 's/# \(.*\.UTF-8\)/\1/' /etc/locale.gen \ + && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + \ + bzip2 \ + curl \ + jq \ + unzip \ + wget \ + \ + gdal-bin \ + proj-bin \ + sqlite3 \ + \ + pipx \ + python-is-python3 \ + python3 \ + python3-geoalchemy2 \ + python3-pglast \ + python3-pip \ + python3-psycopg2 \ + python3-setuptools \ + python3-sqlalchemy \ + \ + postgis \ + postgresql \ + postgresql-client-common \ + postgresql-common \ + postgresql-contrib \ + postgresql-plpython3-$PG_MAJOR \ + postgresql-postgis \ + postgresql-postgis-scripts \ + \ + pg-activity \ + pgbackrest \ + pgbadger \ + pgtap \ + pgtop \ + pspg \ + vip-manager \ + \ + # add any exceptions for PG17 or PPG16 here +{{ if env.version | startswith("17") then ( -}} + # PostgreSQL 17 specific packages +{{ ) else ( -}} + # PostgreSQL 16 and earlier packages +{{ ) end -}} + \ + postgresql-$PG_MAJOR-age \ + postgresql-$PG_MAJOR-asn1oid \ + postgresql-$PG_MAJOR-auto-failover \ + postgresql-$PG_MAJOR-credcheck \ + postgresql-$PG_MAJOR-cron \ + postgresql-$PG_MAJOR-decoderbufs \ + postgresql-$PG_MAJOR-extra-window-functions \ + postgresql-$PG_MAJOR-first-last-agg \ + postgresql-$PG_MAJOR-h3 \ + postgresql-$PG_MAJOR-hll \ + postgresql-$PG_MAJOR-http \ + postgresql-$PG_MAJOR-hypopg \ + postgresql-$PG_MAJOR-icu-ext \ + postgresql-$PG_MAJOR-jsquery \ + postgresql-$PG_MAJOR-mobilitydb \ + postgresql-$PG_MAJOR-numeral \ + postgresql-$PG_MAJOR-ogr-fdw \ + postgresql-$PG_MAJOR-partman \ + postgresql-$PG_MAJOR-periods \ + postgresql-$PG_MAJOR-pg-fact-loader \ + postgresql-$PG_MAJOR-pg-failover-slots \ + postgresql-$PG_MAJOR-pg-stat-kcache \ + postgresql-$PG_MAJOR-pg-wait-sampling \ + postgresql-$PG_MAJOR-pgaudit \ + postgresql-$PG_MAJOR-pgl-ddl-deploy \ + postgresql-$PG_MAJOR-pglogical \ + postgresql-$PG_MAJOR-pgmp \ + postgresql-$PG_MAJOR-pgpcre \ + postgresql-$PG_MAJOR-pgq3 \ + postgresql-$PG_MAJOR-pgrouting \ + postgresql-$PG_MAJOR-pgrouting-scripts \ + postgresql-$PG_MAJOR-pgsphere \ + postgresql-$PG_MAJOR-pgtap \ + postgresql-$PG_MAJOR-pgvector \ + postgresql-$PG_MAJOR-pldebugger \ + postgresql-$PG_MAJOR-plpgsql-check \ + postgresql-$PG_MAJOR-pointcloud \ + postgresql-$PG_MAJOR-prefix \ + postgresql-$PG_MAJOR-prioritize \ + postgresql-$PG_MAJOR-q3c \ + postgresql-$PG_MAJOR-repack \ + postgresql-$PG_MAJOR-rum \ + postgresql-$PG_MAJOR-show-plans \ + postgresql-$PG_MAJOR-squeeze \ + postgresql-$PG_MAJOR-timescaledb \ + # MeCab based tokenizer for pgdg-pgroonga + groonga-tokenizer-mecab \ + # bytemagic + libmagic1 libmagic-mgc \ + # pgsodium + libsodium23 \ + \ + && rm -Rf /root/.cache/pip \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_DUCKDB_CHECKOUT +ENV PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT} +RUN arch=$(uname -m) \ + && DUCKDB_VERSION=$(echo "$PGIS1_DUCKDB_CHECKOUT" | sed -E 's|^.*/||; s|^tags/||; s|^v||') \ + && echo "DUCKDB_VERSION=${DUCKDB_VERSION}" \ + && echo "PGIS1_DUCKDB_CHECKOUT=${PGIS1_DUCKDB_CHECKOUT}" \ + && case "$arch" in \ + x86_64) \ + duck_binary="duckdb_cli-linux-amd64.zip" ;; \ + aarch64) \ + duck_binary="duckdb_cli-linux-arm64.zip" ;; \ + *) \ + echo "Unsupported architecture: $arch"; exit 1 ;; \ + esac \ + && wget https://github.com/duckdb/duckdb/releases/download/v${DUCKDB_VERSION}/$duck_binary \ + && unzip $duck_binary -d /usr/local/bin \ + && rm $duck_binary \ + && duckdb --version + +# install duckdb extensions +ENV DUCKDB_EXTENSIONS="excel fts httpfs inet postgres_scanner spatial sqlite_scanner tpcds tpch" +RUN for e in ${DUCKDB_EXTENSIONS} ; do \ + echo "Installing $e ..."; \ + if duckdb -c "INSTALL $e;" 2>&1 | tee /tmp/duckdb-install-$e.log; then \ + echo "Successfully installed $e"; \ + echo "LOAD $e;" >> $HOME/.duckdbrc; \ + else \ + echo "Failed to install $e, check /tmp/duckdb-install-$e.log"; \ + fi; \ + done \ + # Add core extensions to .duckdbrc (these are built-in) + && echo "LOAD autocomplete;" >> $HOME/.duckdbrc \ + && echo "LOAD icu;" >> $HOME/.duckdbrc \ + && echo "LOAD json;" >> $HOME/.duckdbrc \ + && echo "LOAD parquet;" >> $HOME/.duckdbrc + +# Install from stages +COPY --from=builder-gzip /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-gzip /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-pgxn /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-pgxn /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /usr/share/postgresql/$PG_MAJOR/extension/ /usr/share/postgresql/$PG_MAJOR/extension/ +COPY --from=builder-other /usr/lib/postgresql/$PG_MAJOR/lib /usr/lib/postgresql/$PG_MAJOR/lib + +COPY --from=builder-other /postgres_dba /postgres_dba +COPY --from=builder-other /pg_svg /pg_svg + +# check any missing dependencies +RUN set -eux \ + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true + +# multiple LLVM existance is not optimal; so we give a warning. +# known problem: duplicated LLVM +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "WARNING: More than one llvm package or none at all found!"; \ + dpkg -l | grep llvm ; \ + fi + +# add MobilityDB requirements +RUN set -eux \ + && cp -v /usr/share/postgresql/postgresql.conf.sample /usr/share/postgresql/postgresql.conf.sample.orig; \ + # add MobilityDB and TimescaleDB requirements + echo "shared_preload_libraries = 'postgis-3,pg_stat_statements,timescaledb'" >> /usr/share/postgresql/postgresql.conf.sample ; \ + # MobilityDB recomendation + echo "max_locks_per_transaction = 128" >> /usr/share/postgresql/postgresql.conf.sample; \ + echo "timescaledb.telemetry_level=off" >> /usr/share/postgresql/postgresql.conf.sample + +# for postgres_dba Use ":dba" to see menu +RUN printf "%s %s %s %s\n" \\set dba \'\\\\i /postgres_dba/start.psql\' >> ~/.psqlrc + +COPY ./initdb-bundle0.sh /docker-entrypoint-initdb.d/11_bundle0.sh diff --git a/templates/Dockerfile.debian.template b/templates/Dockerfile.debian.template new file mode 100644 index 000000000..1f61e9719 --- /dev/null +++ b/templates/Dockerfile.debian.template @@ -0,0 +1,88 @@ +ARG PGIS1_BASE_IMAGE=postgres:{{ .[env.variant].PG_DOCKER }}-{{ env.variant }} +ARG PGIS1_POSTGRES_MAJOR={{ .[env.variant].PG_MAJOR }} +ARG PGIS1_POSTGIS_VERSION={{ .[env.variant].POSTGIS_VERSION }} +ARG PGIS1_POSTGIS_MAJOR={{ .[env.variant].POSTGIS_MAJOR }} + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_POSTGRES_MAJOR +ARG PGIS1_POSTGIS_VERSION +ARG PGIS1_POSTGIS_MAJOR +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} {{ env.variant }}" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="${PGIS1_POSTGIS_VERSION}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS ${PGIS1_POSTGIS_VERSION} spatial database extension with PostgreSQL ${PGIS1_POSTGRES_MAJOR} {{ env.variant }}" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="${PGIS1_POSTGIS_VERSION}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" + +ENV POSTGIS_MAJOR ${PGIS1_POSTGIS_MAJOR} +ENV POSTGIS_VERSION ${PGIS1_POSTGIS_VERSION} + +RUN set -eux \ + # Export Debian package environment for child images + && apt-get update \ + && POSTGIS_PACKAGE_VERSION=$(apt-cache madison postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR | head -1 | awk '{print $3}') \ + && echo "export POSTGIS_PACKAGE_VERSION=${POSTGIS_PACKAGE_VERSION}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PG_MAJOR=${PG_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_MAJOR=${POSTGIS_MAJOR}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export POSTGIS_VERSION=${POSTGIS_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-cache showpkg postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \ + && apt-get install -y --no-install-recommends \ + # ca-certificates: for accessing remote raster files; + # fix: https://github.com/postgis/docker-postgis/issues/307 + ca-certificates \ + \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR=$POSTGIS_VERSION \ + postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \ + postgis \ + && rm -rf /var/lib/apt/lists/* + +# multiple LLVM existance is not allowed. +RUN set -eux \ + && dpkg -l | grep llvm \ + && llvm_count=$(dpkg -l | grep llvm | wc -l) \ + && if [ "$llvm_count" -ne 1 ]; then \ + echo "ERROR: Expected exactly 1 LLVM package, found $llvm_count. This may cause PostGIS compilation issues."; \ + echo "Installed LLVM packages:"; \ + dpkg -l | grep llvm; \ + exit 1; \ + fi \ + # Add installed package versions to environment export + && dpkg -l | grep -E "(libgeos|libproj|libgdal|postgis)" | awk '{gsub(/[:.+-]/, "_", $2); print "export " $2 "=\"" $3 "\""}' >> /usr/local/share/docker-postgis-env.sh \ + && echo "# LLVM validation: passed (exactly 1 LLVM package found)" >> /usr/local/share/docker-postgis-env.sh \ + # Debug: show the generated environment file + && echo "=== Generated docker-postgis-env.sh content ===" \ + && cat /usr/local/share/docker-postgis-env.sh \ + && echo "=== End of docker-postgis-env.sh ===" \ + # Test the generated environment file by sourcing it + && echo "=== Testing docker-postgis-env.sh sourcing ===" \ + && . /usr/local/share/docker-postgis-env.sh \ + && echo "Successfully sourced docker-postgis-env.sh" \ + && echo "POSTGIS_PACKAGE_VERSION: ${POSTGIS_PACKAGE_VERSION}" \ + && echo "PG_MAJOR: ${PG_MAJOR}" \ + && echo "POSTGIS_MAJOR: ${POSTGIS_MAJOR}" \ + && echo "POSTGIS_VERSION: ${POSTGIS_VERSION}" \ + && echo "=== docker-postgis-env.sh test completed ===" + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin diff --git a/templates/Dockerfile.master.template b/templates/Dockerfile.master.template new file mode 100644 index 000000000..dc45062b0 --- /dev/null +++ b/templates/Dockerfile.master.template @@ -0,0 +1,795 @@ +# "Experimental"; solely for testing purposes. Anticipate frequent changes! +# This is a multi-stage Dockerfile, requiring a minimum Docker version of 17.05. + +ARG PGIS1_BASE_IMAGE=postgres:{{ .[env.variant].PG_DOCKER }}-{{ env.variant }} + +# usable for forking the image +ARG PGIS1_SOURCE_REPO="https://github.com/postgis/docker-postgis" +ARG PGIS1_MAINTAINER="PostGIS Project - https://postgis.net - ${PGIS1_SOURCE_REPO}/issues" + +ARG PGIS1_POSTGIS_REPOSITORY=https://github.com/postgis/postgis.git +ARG PGIS1_GEOS_REPOSITORY=https://github.com/libgeos/geos.git +ARG PGIS1_GDAL_REPOSITORY=https://github.com/OSGeo/gdal.git +ARG PGIS1_PROJ_REPOSITORY=https://github.com/OSGeo/PROJ.git +ARG PGIS1_SFCGAL_REPOSITORY=https://gitlab.com/sfcgal/SFCGAL.git +ARG PGIS1_CGAL_REPOSITORY=https://github.com/CGAL/cgal.git + +# Should valid git checkout ( SHA1, tags, branches ) +ARG PGIS1_POSTGIS_CHECKOUT={{ .[env.variant].POSTGIS_CHECKOUT }} +ARG PGIS1_GEOS_CHECKOUT={{ .[env.variant].GEOS_CHECKOUT }} +ARG PGIS1_GDAL_CHECKOUT={{ .[env.variant].GDAL_CHECKOUT }} +ARG PGIS1_PROJ_CHECKOUT={{ .[env.variant].PROJ_CHECKOUT }} +ARG PGIS1_SFCGAL_CHECKOUT={{ .[env.variant].SFCGAL_CHECKOUT }} +ARG PGIS1_CGAL_CHECKOUT={{ .[env.variant].CGAL_CHECKOUT }} + +# Skip SHA1 check if PGIS1_*_CHECKOUT_SHA1 is empty or 'nocheck' +# Otherwise, verify that the commit hash matches +ARG PGIS1_POSTGIS_CHECKOUT_SHA1={{ .[env.variant].POSTGIS_CHECKOUT_SHA1 }} +ARG PGIS1_GEOS_CHECKOUT_SHA1={{ .[env.variant].GEOS_CHECKOUT_SHA1 }} +ARG PGIS1_GDAL_CHECKOUT_SHA1={{ .[env.variant].GDAL_CHECKOUT_SHA1 }} +ARG PGIS1_PROJ_CHECKOUT_SHA1={{ .[env.variant].PROJ_CHECKOUT_SHA1 }} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1={{ .[env.variant].SFCGAL_CHECKOUT_SHA1 }} +ARG PGIS1_CGAL_CHECKOUT_SHA1={{ .[env.variant].CGAL_CHECKOUT_SHA1 }} + +ARG PGIS1_BOOST_VERSION={{ .[env.variant].BOOST_VERSION }} +ARG PGIS1_CMAKE_BUILD_TYPE=Release + +ARG PGIS1_GDAL_BUILD={{ .[env.variant].GDAL_BUILD }} +{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}} +# Full GDAL build ; with arrow, parquet and extra dependencies +{{ ) else ( -}} +# Minimal GDAL build ; no arrow, no parquet, no extra dependencies +{{ ) end -}} + +FROM ${PGIS1_BASE_IMAGE} as builder + +WORKDIR / + +ARG PGIS1_BOOST_VERSION +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ENV PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +# apt-get install +RUN set -eux \ + # Export build environment for child images + && echo "export PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE}" > /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE}" >> /usr/local/share/docker-postgis-env.sh \ + && echo "export PGIS1_GDAL_BUILD={{ .[env.variant].GDAL_BUILD }}" >> /usr/local/share/docker-postgis-env.sh \ + && chmod +x /usr/local/share/docker-postgis-env.sh \ + \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libprotobuf-c1 \ +{{ if env.variant != "bullseye" then ( -}} + libtiff6 \ +{{ ) else ( -}} + libtiff5 \ +{{ ) end -}} + libxml2 \ + sqlite3 \ + # build dependency + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libpq-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + make \ + pkg-config \ + protobuf-c-compiler \ + xsltproc \ + # gdal+ + liblz4-dev \ + liblzma-dev \ + libwebp-dev \ + libzstd-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +ARG PGIS1_CMAKE_BUILD_TYPE +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} + +FROM builder as cgal-sfcgal-builder + +# cgal & sfcgal +ARG PGIS1_SFCGAL_REPOSITORY +ENV PGIS1_SFCGAL_REPOSITORY ${PGIS1_SFCGAL_REPOSITORY} +ARG PGIS1_SFCGAL_CHECKOUT +ENV PGIS1_SFCGAL_CHECKOUT ${PGIS1_SFCGAL_CHECKOUT} +ARG PGIS1_SFCGAL_CHECKOUT_SHA1 + +ARG PGIS1_CGAL_REPOSITORY +ENV PGIS1_CGAL_REPOSITORY ${PGIS1_CGAL_REPOSITORY} +ARG PGIS1_CGAL_CHECKOUT +ENV PGIS1_CGAL_CHECKOUT ${PGIS1_CGAL_CHECKOUT} +ARG PGIS1_CGAL_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir cgal \ + && cd cgal \ + && git init \ + && git remote add origin ${PGIS1_CGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_CGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_CGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_CGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_CGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_CGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping CGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_CGAL_CHECKOUT_SHA1}" ]; then \ + echo "CGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_cgal_last_commit.txt \ + && cd /usr/src \ + && mkdir SFCGAL \ + && cd SFCGAL \ + && git init \ + && git remote add origin ${PGIS1_SFCGAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_SFCGAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_SFCGAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_SFCGAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_SFCGAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping SFCGAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_SFCGAL_CHECKOUT_SHA1}" ]; then \ + echo "SFCGAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_sfcgal_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. \ + -DCGAL_DIR=/usr/src/cgal \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DSFCGAL_BUILD_BENCH=OFF \ + -DSFCGAL_BUILD_EXAMPLES=OFF \ + -DSFCGAL_BUILD_TESTS=OFF \ + -DSFCGAL_WITH_OSG=OFF \ + && make -j$(nproc) \ + && make install \ + # clean + && rm -fr /usr/src/SFCGAL \ + && rm -fr /usr/src/cgal + + +FROM builder as proj-builder + +# proj +ARG PGIS1_PROJ_REPOSITORY +ENV PGIS1_PROJ_REPOSITORY ${PGIS1_PROJ_REPOSITORY} +ARG PGIS1_PROJ_CHECKOUT +ENV PGIS1_PROJ_CHECKOUT ${PGIS1_PROJ_CHECKOUT} +ARG PGIS1_PROJ_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir PROJ \ + && cd PROJ \ + && git init \ + && git remote add origin ${PGIS1_PROJ_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_PROJ_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_PROJ_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_PROJ_CHECKOUT_SHA1 + && if [ -z "${PGIS1_PROJ_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_PROJ_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping PROJ SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_PROJ_CHECKOUT_SHA1}" ]; then \ + echo "PROJ SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_proj_last_commit.txt \ + # check the autotools exist? https://github.com/OSGeo/PROJ/pull/3027 + && if [ -f "autogen.sh" ] ; then \ + set -eux \ + && echo "autotools version: 'autogen.sh' exists! Older version!" \ + && ./autogen.sh \ + && ./configure --disable-static \ + && make -j$(nproc) \ + && make install \ + ; \ + else \ + set -eux \ + && echo "cmake version: 'autogen.sh' does not exists! Newer version!" \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + ; \ + fi \ + \ + && rm -fr /usr/src/PROJ + + +FROM builder as geos-builder + +# geos +ARG PGIS1_GEOS_REPOSITORY +ENV PGIS1_GEOS_REPOSITORY ${PGIS1_GEOS_REPOSITORY} +ARG PGIS1_GEOS_CHECKOUT +ENV PGIS1_GEOS_CHECKOUT ${PGIS1_GEOS_CHECKOUT} +ARG PGIS1_GEOS_CHECKOUT_SHA1 + +RUN set -eux \ + && cd /usr/src \ + && mkdir geos \ + && cd geos \ + && git init \ + && git remote add origin ${PGIS1_GEOS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GEOS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GEOS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GEOS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GEOS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GEOS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GEOS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GEOS_CHECKOUT_SHA1}" ]; then \ + echo "GEOS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_geos_last_commit.txt \ + && mkdir cmake-build \ + && cd cmake-build \ + && cmake .. -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} -DBUILD_TESTING=OFF \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/geos + + +FROM builder as stage0-builder + +COPY --from=cgal-sfcgal-builder /_pgis*.* / +COPY --from=cgal-sfcgal-builder /usr/local /usr/local + +COPY --from=proj-builder /_pgis*.* / +COPY --from=proj-builder /usr/local /usr/local + +COPY --from=geos-builder /_pgis*.* / +COPY --from=geos-builder /usr/local /usr/local +# gdal +ARG PGIS1_GDAL_REPOSITORY +ENV PGIS1_GDAL_REPOSITORY ${PGIS1_GDAL_REPOSITORY} +ARG PGIS1_GDAL_CHECKOUT +ENV PGIS1_GDAL_CHECKOUT ${PGIS1_GDAL_CHECKOUT} +ARG PGIS1_GDAL_CHECKOUT_SHA1 + + +{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}} + +# Install Arrow C++ +# also check the "Build final image" section too, for the final installation +RUN set -eux \ + # add backports \ + && apt-get update \ + && apt install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-{{ env.variant }}.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-{{ env.variant }}.deb \ + && apt-get update \ + # Automatically determine the latest PGIS1 Arrow version and SOVERSION + && apt-cache showpkg libarrow-dev \ + && PGIS1_ARROW_VERSION=$(apt-cache madison libarrow-dev | head -1 | awk '{print $3}') \ + && [ -n "$PGIS1_ARROW_VERSION" ] || { echo "Failed to detect Arrow version"; exit 1; } \ + && apt-cache depends libarrow-dev=${PGIS1_ARROW_VERSION} | tee /_pgis1_libarrow-dev-dependencies.txt \ + && PGIS1_ARROW_SOVERSION=$(grep 'Depends: libarrow' /_pgis1_libarrow-dev-dependencies.txt | grep -oP 'libarrow\K[0-9]+') \ + && echo "Detected PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" \ + && echo "Detected PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + # Backup the version variables - reusing in a later stage + && echo "PGIS1_ARROW_VERSION=$PGIS1_ARROW_VERSION" > /_pgis1_arrow_environment.env \ + && echo "PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" >> /_pgis1_arrow_environment.env \ + # Install Arrow C++ + && apt-get install -y --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + libarrow-dev=${PGIS1_ARROW_VERSION} \ + libparquet-dev=${PGIS1_ARROW_VERSION} \ + libarrow-acero-dev=${PGIS1_ARROW_VERSION} \ + libarrow-dataset-dev=${PGIS1_ARROW_VERSION} \ + \ + libblosc-dev \ + libcfitsio-dev \ + libfreexl-dev \ + libfyba-dev \ + libhdf5-dev \ + libheif-dev \ + libkml-dev \ + libnetcdf-dev \ + libopenjp2-7-dev \ + libpng-dev \ + libqhull-dev \ + libspatialite-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +{{ ) else ( -}} +# +{{ ) end -}} + +## GDAL_build-end + +RUN set -eux \ + && ldconfig \ + && cd /usr/src \ + && mkdir gdal \ + && cd gdal \ + && git init \ + && git remote add origin ${PGIS1_GDAL_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_GDAL_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_GDAL_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_GDAL_CHECKOUT_SHA1 + && if [ -z "${PGIS1_GDAL_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_GDAL_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping GDAL SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_GDAL_CHECKOUT_SHA1}" ]; then \ + echo "GDAL SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_gdal_last_commit.txt \ + \ + # gdal project directory structure - has been changed ! + && if [ -d "gdal" ] ; then \ + echo "Directory 'gdal' dir exists -> older version!" ; \ + cd gdal ; \ + else \ + echo "Directory 'gdal' does not exists! Newer version! " ; \ + fi \ + \ + && if [ -f "./autogen.sh" ]; then \ + # Building with autoconf ( old/deprecated ) + set -eux \ + && ./autogen.sh \ + && ./configure --disable-static \ + ; \ + else \ + # Building with cmake + set -eux \ + && mkdir build \ + && cd build \ + # config based on: https://salsa.debian.org/debian-gis-team/gdal/-/blob/master/debian/rules + && cmake .. \ + -DCMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + -DBUILD_TESTING=OFF \ + -DBUILD_DOCS=OFF \ + \ + -DGDAL_HIDE_INTERNAL_SYMBOLS=ON \ + -DRENAME_INTERNAL_TIFF_SYMBOLS=ON \ + -DGDAL_USE_CURL=ON \ + -DGDAL_USE_DEFLATE=ON \ + -DGDAL_USE_EXPAT=ON \ + -DGDAL_USE_GEOS=ON \ + -DGDAL_USE_JSONC=ON \ + -DGDAL_USE_LIBLZMA=ON \ + -DGDAL_USE_LIBXML2=ON \ + -DGDAL_USE_LZ4=ON \ + -DGDAL_USE_POSTGRESQL=ON \ + -DGDAL_USE_SQLITE3=ON \ + -DGDAL_USE_TIFF=ON \ + -DGDAL_USE_WEBP=ON \ + -DGDAL_USE_ZLIB=ON \ + -DGDAL_USE_ZSTD=ON \ +{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}} + \ + -DGDAL_USE_ARROW=ON \ + -DGDAL_USE_ARROWDATASET=ON \ + -DGDAL_USE_BLOSC=ON \ + -DGDAL_USE_CFITSIO=ON \ + -DGDAL_USE_FREEXL=ON \ + -DGDAL_USE_FYBA=ON \ + -DGDAL_USE_HDF5=ON \ + -DGDAL_USE_HEIF=ON \ + -DGDAL_USE_LERC_INTERNAL=ON \ + -DGDAL_USE_LIBKML=ON \ + -DGDAL_USE_NETCDF=ON \ + -DGDAL_USE_OPENJPEG=ON \ + -DGDAL_USE_PARQUET=ON \ + -DGDAL_USE_PNG=ON \ + -DGDAL_USE_QHULL=ON \ + -DGDAL_USE_SPATIALITE=ON \ +{{ ) else ( -}} +# minimal GDAL build .. +{{ ) end -}} + ; \ + fi \ + \ + && make -j$(nproc) \ + && make install \ + && cd / \ + && rm -fr /usr/src/gdal + +# Minimal command line test. +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + && pcre-config --version + +# ------------------------------------------- +# final stage +# ------------------------------------------- +FROM ${PGIS1_BASE_IMAGE} + +ARG PGIS1_SOURCE_REPO +ARG PGIS1_MAINTAINER +ARG PGIS1_BASE_IMAGE + +LABEL maintainer="${PGIS1_MAINTAINER}" \ + org.opencontainers.image.description="PostGIS - {{ env.version }} spatial database extension with PostgreSQL {{ .[env.variant].PG_MAJOR }} {{ env.variant }}" \ + org.opencontainers.image.source="${PGIS1_SOURCE_REPO}" \ + org.opencontainers.image.version="{{ env.version }}" \ + org.opencontainers.image.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.opencontainers.image.base.name="${PGIS1_BASE_IMAGE}" \ + \ + # child friendly image labels, so some duplacted labels expected + org.postgis.base.maintainer="${PGIS1_MAINTAINER}" \ + org.postgis.base.description="PostGIS - {{ env.version }} spatial database extension with PostgreSQL {{ .[env.variant].PG_MAJOR }} {{ env.variant }}" \ + org.postgis.base.source="${PGIS1_SOURCE_REPO}" \ + org.postgis.base.version="{{ env.version }}" \ + org.postgis.base.created="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \ + org.postgis.base.extensions="postgis,postgis_raster,postgis_sfcgal,postgis_topology,postgis_tiger_geocoder,address_standardizer" \ + org.postgis.base.name="${PGIS1_BASE_IMAGE}" \ + org.postgis.base.repositories="POSTGIS:${PGIS1_POSTGIS_REPOSITORY},GEOS:${PGIS1_GEOS_REPOSITORY},GDAL:${PGIS1_GDAL_REPOSITORY},PROJ:${PGIS1_PROJ_REPOSITORY},SFCGAL:${PGIS1_SFCGAL_REPOSITORY},CGAL:${PGIS1_CGAL_REPOSITORY}" + +ARG PGIS1_CMAKE_BUILD_TYPE +ARG PGIS1_BASE_IMAGE +ARG PGIS1_BOOST_VERSION + +ENV PGIS1_CMAKE_BUILD_TYPE=${PGIS1_CMAKE_BUILD_TYPE} \ + PGIS1_BASE_IMAGE=${PGIS1_BASE_IMAGE} \ + PGIS1_BOOST_VERSION=${PGIS1_BOOST_VERSION} + +RUN set -eux \ + # Update environment export with runtime packages + && apt-get update \ + && BOOST_INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' libboost-atomic${PGIS1_BOOST_VERSION} 2>/dev/null || echo "not-found") \ + && echo "export BOOST_INSTALLED_VERSION=${BOOST_INSTALLED_VERSION}" >> /usr/local/share/docker-postgis-env.sh \ + && apt-get install -y -V --no-install-recommends \ + \ + curl \ + libboost-atomic${PGIS1_BOOST_VERSION} \ + libboost-chrono${PGIS1_BOOST_VERSION} \ + libboost-date-time${PGIS1_BOOST_VERSION} \ + libboost-filesystem${PGIS1_BOOST_VERSION} \ + libboost-program-options${PGIS1_BOOST_VERSION} \ + libboost-serialization${PGIS1_BOOST_VERSION} \ + libboost-system${PGIS1_BOOST_VERSION} \ + libboost-test${PGIS1_BOOST_VERSION} \ + libboost-thread${PGIS1_BOOST_VERSION} \ + libboost-timer${PGIS1_BOOST_VERSION} \ + libcurl3-gnutls \ + libexpat1 \ + libgmp10 \ + libgmpxx4ldbl \ + libjson-c5 \ + libmpfr6 \ + libpcre3 \ + libprotobuf-c1 \ +{{ if env.variant != "bullseye" then ( -}} + libtiff6 \ +{{ ) else ( -}} + libtiff5 \ +{{ ) end -}} + libxml2 \ + sqlite3 \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=stage0-builder /_pgis*.* / +COPY --from=stage0-builder /usr/local /usr/local + +{{ if .[env.variant].GDAL_BUILD != "minimal" then ( -}} +# Install Arrow + Parquet + other GDAL extra dependencies + +RUN set -eux \ + # Install Arrow + Parquet + && apt-get update \ + && apt-get install -y -V ca-certificates wget \ + && wget -q --timeout=30 --tries=3 https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-{{ env.variant }}.deb \ + || { echo "Failed to download Arrow apt source"; exit 1; } \ + && apt-get install -y -V ./apache-arrow-apt-source-latest-{{ env.variant }}.deb \ + && apt-get update \ + # Load the PGIS1_ARROW version variables + && . /_pgis1_arrow_environment.env \ + # Use the PGIS1_ARROW_SOVERSION as needed + && echo "Using PGIS1_ARROW_SOVERSION=$PGIS1_ARROW_SOVERSION" \ + && apt-get install -y -V --no-install-recommends \ + libarrow${PGIS1_ARROW_SOVERSION} \ + libparquet${PGIS1_ARROW_SOVERSION} \ + libarrow-dataset${PGIS1_ARROW_SOVERSION} \ + \ + # Install GDAL extra dependencies + libblosc1 \ + libcrypto++8 \ + libfreexl1 \ + libfyba0 \ + libhdf5-103-1 \ + libheif1 \ + libkmlbase1 \ + libkmldom1 \ + libkmlengine1 \ + libnetcdf19 \ + libopenjp2-7 \ + libpng16-16 \ + libqhull-r8.0 \ + librasterlite2-1 \ + libspatialite7 \ + netcdf-bin \ +{{ if env.variant != "bullseye" then ( -}} + libcfitsio10 \ +{{ ) else ( -}} + libcfitsio9 \ +{{ ) end -}} + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +{{ ) else ( -}} +# minimal GDAL build; so no need extra dependencies +{{ ) end -}} + + +ARG PGIS1_GDAL_CHECKOUT +ARG PGIS1_GDAL_REPOSITORY +ARG PGIS1_GEOS_CHECKOUT +ARG PGIS1_GEOS_REPOSITORY +ARG PGIS1_PROJ_CHECKOUT +ARG PGIS1_PROJ_REPOSITORY +ARG PGIS1_SFCGAL_CHECKOUT +ARG PGIS1_SFCGAL_REPOSITORY +ARG PGIS1_CGAL_REPOSITORY +ARG PGIS1_CGAL_CHECKOUT + +ARG PGIS1_POSTGIS_CHECKOUT +ARG PGIS1_POSTGIS_REPOSITORY +ARG PGIS1_POSTGIS_CHECKOUT_SHA1 + +ENV PGIS1_GDAL_CHECKOUT=${PGIS1_GDAL_CHECKOUT} \ + PGIS1_GDAL_REPOSITORY=${PGIS1_GDAL_REPOSITORY} \ + PGIS1_GEOS_CHECKOUT=${PGIS1_GEOS_CHECKOUT} \ + PGIS1_GEOS_REPOSITORY=${PGIS1_GEOS_REPOSITORY} \ + PGIS1_PROJ_CHECKOUT=${PGIS1_PROJ_CHECKOUT} \ + PGIS1_PROJ_REPOSITORY=${PGIS1_PROJ_REPOSITORY} \ + PGIS1_CGAL_CHECKOUT=${PGIS1_CGAL_CHECKOUT} \ + PGIS1_CGAL_REPOSITORY=${PGIS1_CGAL_REPOSITORY} \ + PGIS1_SFCGAL_CHECKOUT=${PGIS1_SFCGAL_CHECKOUT} \ + PGIS1_SFCGAL_REPOSITORY=${PGIS1_SFCGAL_REPOSITORY} \ + PGIS1_POSTGIS_CHECKOUT=${PGIS1_POSTGIS_CHECKOUT} \ + PGIS1_POSTGIS_REPOSITORY=${PGIS1_POSTGIS_REPOSITORY} + +# Minimal command line test ( fail fast ) +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + \ + # Testing ogr2ogr PostgreSQL driver. + && ogr2ogr --formats | grep -q "PostgreSQL/PostGIS" && exit 0 \ + || echo "ogr2ogr missing PostgreSQL driver" && exit 1 + +# Specify GDAL_CONFIG and LD_LIBRARY_PATH for PostGIS build; +# The arm64 build is very senitive. +ENV GDAL_CONFIG /usr/local/bin/gdal-config +ENV LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH + +# temporary workaround for : nitdb: invalid locale settings; check LANG and LC_* environment variables +# https://github.com/docker-library/postgres/issues/1112#issuecomment-1746076388 +RUN set -eux \ + && echo en_US.UTF-8 UTF-8 >> /etc/locale.gen && locale-gen + +RUN set -eux \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + ca-certificates \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcunit1-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && cd \ + # postgis + && cd /usr/src \ + && mkdir postgis \ + && cd postgis \ + && git init \ + && git remote add origin ${PGIS1_POSTGIS_REPOSITORY} \ + && git fetch --depth 1 origin ${PGIS1_POSTGIS_CHECKOUT} \ + && git checkout FETCH_HEAD \ + # Skip SHA1 check if PGIS1_POSTGIS_CHECKOUT_SHA1 is empty or 'nocheck' + # Otherwise, verify that the commit hash matches PGIS1_POSTGIS_CHECKOUT_SHA1 + && if [ -z "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ] \ + || [ "${PGIS1_POSTGIS_CHECKOUT_SHA1}" = "nocheck" ]; then \ + echo "Skipping POSTGIS SHA1 check"; \ + else \ + if [ "$(git rev-parse HEAD)" != "${PGIS1_POSTGIS_CHECKOUT_SHA1}" ]; then \ + echo "POSTGIS SHA1 problem! Stop!"; \ + exit 1; \ + fi; \ + fi \ + && git log -1 > /_pgis_last_commit.txt \ + && ldconfig \ + && ./autogen.sh \ +# configure options taken from: +# https://anonscm.debian.org/cgit/pkg-grass/postgis.git/tree/debian/rules?h=jessie + && ./configure \ + --enable-lto \ + && make -j$(nproc) \ + && make install \ +# refresh proj data - workarounds: https://trac.osgeo.org/postgis/ticket/5316 + && if command -v projsync >/dev/null 2>&1; then \ + projsync --system-directory --file ch_swisstopo_CHENyx06_ETRS \ + && projsync --system-directory --file us_noaa_eshpgn \ + && projsync --system-directory --file us_noaa_prvi \ + && projsync --system-directory --file us_noaa_wmhpgn ; \ + fi \ +# regress check + && mkdir /tempdb \ + && chown -R postgres:postgres /tempdb \ + && su postgres -c 'pg_ctl -D /tempdb init' \ + && su postgres -c 'pg_ctl -D /tempdb -c -l /tmp/logfile -o '-F' start ' \ + && ldconfig \ + && cd regress \ + && make -j$(nproc) check RUNTESTFLAGS=--extension PGUSER=postgres \ + \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_raster;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch; --needed for postgis_tiger_geocoder "' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;"' \ + && su postgres -c 'psql -c "CREATE EXTENSION IF NOT EXISTS postgis_topology;"' \ + && su postgres -c 'psql -t -c "SELECT version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "SELECT PostGIS_Full_Version();"' >> /_pgis_full_version.txt \ + && su postgres -c 'psql -t -c "\dx"' >> /_pgis_full_version.txt \ + \ + && su postgres -c 'pg_ctl -D /tempdb --mode=immediate stop' \ + && rm -rf /tempdb \ + && rm -rf /tmp/logfile \ + && rm -rf /tmp/pgis_reg \ +# clean + # Add final version information to environment export + && echo "PostGIS build completed at $(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> /usr/local/share/docker-postgis-env.sh \ + && find /_pgis*_commit.txt -type f -exec basename {} \; | while read commit_file; do \ + commit_hash=$(cat "/${commit_file}" | head -1 | awk '{print $2}') \ + && echo "export ${commit_file%.txt}=\"${commit_hash}\"" >> /usr/local/share/docker-postgis-env.sh; \ + done \ + && cd / \ + && rm -rf /usr/src/postgis \ + && apt-get purge -y --autoremove \ + autoconf \ + automake \ + autotools-dev \ + bison \ + build-essential \ + cmake \ + docbook-xml \ + docbook5-xml \ + g++ \ + git \ + libboost-all-dev \ + libcurl4-gnutls-dev \ + libgmp-dev \ + libjson-c-dev \ + libmpfr-dev \ + libpcre3-dev \ + libprotobuf-c-dev \ + libsqlite3-dev \ + libtiff-dev \ + libtool \ + libxml2-dev \ + libxml2-utils \ + make \ + pkg-config \ + postgresql-server-dev-$PG_MAJOR \ + protobuf-c-compiler \ + xsltproc \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN mkdir -p /docker-entrypoint-initdb.d +COPY ./initdb-postgis.sh /docker-entrypoint-initdb.d/10_postgis.sh +COPY ./update-postgis.sh /usr/local/bin + +# last final test +RUN set -eux \ + && ldconfig \ + && cs2cs \ + && ldd $(which gdalinfo) \ + && gdalinfo --version \ + && gdal-config --formats \ + && geos-config --version \ + && ogr2ogr --version \ + && proj \ + && sfcgal-config --version \ + # check any missing dependencies + && ldd /usr/lib/postgresql/$PG_MAJOR/lib/*.so | grep 'not found' && exit 1 || true \ + \ + # Is the "ca-certificates" package installed? (for accessing remote raster files) + # https://github.com/postgis/docker-postgis/issues/307 + && dpkg-query -W -f='${Status}' ca-certificates 2>/dev/null | grep -c "ok installed" \ + \ + # list last commits. + && find /_pgis*_commit.txt -type f -print -exec cat {} \; \ + # list postgresql, postgis version + && cat _pgis_full_version.txt diff --git a/templates/initdb-bundle0.sh b/templates/initdb-bundle0.sh new file mode 100644 index 000000000..5f2c5d116 --- /dev/null +++ b/templates/initdb-bundle0.sh @@ -0,0 +1,9 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -e + +# Perform all actions as $POSTGRES_USER +export PGUSER="$POSTGRES_USER" + +# install pg-svg-lib +"${psql[@]}" /dev/null" EXIT +trap 'docker rm -vf "$cid" > /dev/null' EXIT psql() { - docker run --rm -i \ - --link "$cname":postgis \ - --entrypoint psql \ - -e PGPASSWORD="$POSTGRES_PASSWORD" \ - "$image" \ - --host postgis \ - --username "$POSTGRES_USER" \ - --dbname "$POSTGRES_DB" \ - --quiet --no-align --tuples-only \ - "$@" + docker run --rm -i \ + --link "$cname":postgis \ + --entrypoint psql \ + -e PGPASSWORD="$POSTGRES_PASSWORD" \ + "$image" \ + --host postgis \ + --username "$POSTGRES_USER" \ + --dbname "$POSTGRES_DB" \ + --quiet --no-align --tuples-only \ + "$@" } -tries=10 -while ! echo 'SELECT 1' | psql &> /dev/null; do - (( tries-- )) - if [ $tries -le 0 ]; then - echo >&2 'postgres failed to accept connections in a reasonable amount of time!' - echo 'SELECT 1' | psql # to hopefully get a useful error message - false - fi - sleep 2 +# Set default values for POSTGRES_TEST_TRIES and POSTGRES_TEST_SLEEP if they are not set. +# You can change the default value of POSTGRES_TEST_TRIES and the POSTGRES_TEST_SLEEP in the CI build settings. +# For special cases like Buildx/qemu tests, you may need to set POSTGRES_TEST_TRIES to 42. +: "${POSTGRES_TEST_TRIES:=15}" +: "${POSTGRES_TEST_SLEEP:=2}" +tries="$POSTGRES_TEST_TRIES" +while ! echo 'SELECT 1' | psql &>/dev/null; do + ((tries--)) + if [ $tries -le 0 ]; then + echo >&2 'postgres failed to accept connections in a reasonable amount of time!' + echo 'SELECT 1' | psql # to hopefully get a useful error message + false + fi + sleep "$POSTGRES_TEST_SLEEP" done echo 'SELECT PostGIS_Version()' | psql [ "$(echo 'SELECT ST_X(ST_Point(0,0))' | psql)" = 0 ] - ## test address_standardizer extension echo 'CREATE EXTENSION address_standardizer;' | psql response=$(echo $'SELECT zip FROM parse_address(\'1 Devonshire Place, Boston, MA 02109-1234\') AS a;' | psql) -if [ $response = 02109 ]; then - echo "address_standardizer extension installed and works!" -else - echo "address_standardizer extension test failed, returned response is $response" - exit 1 +if [ "$response" = "02109" ]; then + echo "address_standardizer extension installed and works!" +else + echo "address_standardizer extension test failed, returned response is $response" + exit 1 fi +echo "CREATE EXTENSION IF NOT EXISTS postgis;" | psql +echo "CREATE EXTENSION IF NOT EXISTS postgis_raster;" | psql +echo "CREATE EXTENSION IF NOT EXISTS postgis_sfcgal;" | psql +echo "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;" | psql +echo "CREATE EXTENSION IF NOT EXISTS address_standardizer;" | psql +echo "CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;" | psql +echo "CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;" | psql +echo "CREATE EXTENSION IF NOT EXISTS postgis_topology;" | psql +echo "SELECT version();" | psql +echo "SELECT PostGIS_Full_Version();" | psql +echo "\dx" | psql diff --git a/test/tests/postgis-bundle/run.sh b/test/tests/postgis-bundle/run.sh new file mode 100755 index 000000000..51d715c94 --- /dev/null +++ b/test/tests/postgis-bundle/run.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# shellcheck disable=SC2119,SC2120 +set -eo pipefail + +#for debug: +#set -x + +image="$1" + +export POSTGRES_USER='my cool postgis user' +export POSTGRES_PASSWORD='my cool postgis password' +export POSTGRES_DB='my cool postgis database' + +cname="postgis-container-$RANDOM-$RANDOM" +cid="$(docker run -d -e POSTGRES_USER -e POSTGRES_PASSWORD -e POSTGRES_DB --name "$cname" "$image")" +trap 'docker rm -vf "$cid" > /dev/null' EXIT + +psql() { + docker run --rm -i \ + --link "$cname":postgis \ + --entrypoint psql \ + -e PGPASSWORD="$POSTGRES_PASSWORD" \ + "$image" \ + --host postgis \ + --username "$POSTGRES_USER" \ + --dbname "$POSTGRES_DB" \ + --quiet --no-align --tuples-only \ + "$@" +} + +# Set default values for POSTGRES_TEST_TRIES and POSTGRES_TEST_SLEEP if they are not set. +# You can change the default value of POSTGRES_TEST_TRIES and the POSTGRES_TEST_SLEEP in the CI build settings. +# For special cases like Buildx/qemu tests, you may need to set POSTGRES_TEST_TRIES to 42. +: "${POSTGRES_TEST_TRIES:=30}" +: "${POSTGRES_TEST_SLEEP:=2}" +tries="$POSTGRES_TEST_TRIES" +while ! echo 'SELECT 1' | psql &>/dev/null; do + ((tries--)) + if [ $tries -le 0 ]; then + echo >&2 'postgres failed to accept connections in a reasonable amount of time!' + echo 'SELECT 1' | psql # to hopefully get a useful error message + false + fi + sleep "$POSTGRES_TEST_SLEEP" +done + +# -------- not working ; need more debug ---------- +##"" +##-- create extension if not exists periods cascade; +##-- create extension if not exists pg_cron cascade; +##-- create extension if not exists pg_stat_kcache cascade; +##-- create extension if not exists pg_xenophile cascade; +##-- create extension if not exists pgsodium cascade; +##""" + +## Minimal create extension test +echo " +create extension if not exists age cascade; +create extension if not exists byteamagic cascade; +create extension if not exists credcheck cascade; +create extension if not exists ddlx cascade; +create extension if not exists file_fdw cascade; +create extension if not exists first_last_agg cascade; +create extension if not exists gzip cascade; +create extension if not exists gzip cascade; +create extension if not exists h3 cascade; +create extension if not exists h3_postgis cascade; +create extension if not exists hstore_plpython3u cascade; +create extension if not exists http cascade; +create extension if not exists hypopg cascade; +create extension if not exists icu_ext cascade; +create extension if not exists json_accessors cascade; +create extension if not exists mobilitydb cascade; +create extension if not exists moddatetime cascade; +create extension if not exists numeral cascade; +create extension if not exists ogr_fdw cascade; +create extension if not exists permuteseq cascade; +create extension if not exists pg_buffercache cascade; +create extension if not exists pg_curl cascade; +create extension if not exists pg_fact_loader cascade; +create extension if not exists pg_show_plans cascade; +create extension if not exists pg_uuidv7 cascade; +create extension if not exists pgrouting cascade; +create extension if not exists pgtap cascade; +create extension if not exists plpython3u cascade; +create extension if not exists prioritize cascade; +create extension if not exists q3c cascade; +create extension if not exists vector cascade; +" | psql + +echo " +SELECT h3_get_extension_version(); +SELECT mobilitydb_full_version(); +SELECT pgr_full_version(); +" | psql + +imagetag=$(echo "${1}" | cut -d':' -f2) +mkdir -p ./tmp + +echo " +COPY ( + SELECT + name, default_version, comment + FROM pg_available_extensions ORDER BY 1 +) TO STDOUT WITH CSV HEADER; +" | psql >./tmp/"${imagetag}"__pg_available_extensions.csv diff --git a/tools/_migrate.sh b/tools/_migrate.sh new file mode 100755 index 000000000..2857e15af --- /dev/null +++ b/tools/_migrate.sh @@ -0,0 +1,70 @@ +#!/bin/sh + +# temporary files, only for the migration. +# will be removed... + +debian_move() { + mkdir -p "$1/bullseye" + mkdir -p "$1/bookworm" + + git mv "$1/Dockerfile" "$1/bullseye/Dockerfile" + git mv "$1/initdb-postgis.sh" "$1/bullseye/initdb-postgis.sh" + git mv "$1/update-postgis.sh" "$1/bullseye/update-postgis.sh" + + cp "$1/bullseye/Dockerfile" "$1/bookworm/Dockerfile" + cp "$1/bullseye/initdb-postgis.sh" "$1/bookworm/initdb-postgis.sh" + cp "$1/bullseye/update-postgis.sh" "$1/bookworm/update-postgis.sh" + + git add "$1/bookworm/Dockerfile" + git add "$1/bookworm/initdb-postgis.sh" + git add "$1/bookworm/update-postgis.sh" +} + +bookworm_move() { + mkdir -p "$1/bookworm" + git mv "$1/Dockerfile" "$1/bookworm/Dockerfile" + git mv "$1/initdb-postgis.sh" "$1/bookworm/initdb-postgis.sh" + git mv "$1/update-postgis.sh" "$1/bookworm/update-postgis.sh" +} + +alpine_move() { + git mv "$1/alpine" "$1/alpine3.18" +} + +debian_move 11-3.3 +debian_move 12-3.4 +debian_move 13-3.4 +debian_move 14-3.4 +debian_move 15-3.4 +debian_move 16beta3-3.4 + +bookworm_move 14-master +bookworm_move 15-master +bookworm_move 16beta3-master + +alpine_move 11-3.3 +alpine_move 12-3.4 +alpine_move 13-3.4 +alpine_move 14-3.4 +alpine_move 15-3.4 +alpine_move 16beta3-3.4 + +git mv 16beta3-3.4 16-3.4 +git mv 16beta3-master 16-master + +git mv Dockerfile.template Dockerfile.debian.template + +mkdir -p 12-3.4-bundle +mkdir -p 13-3.4-bundle +mkdir -p 14-3.4-bundle +mkdir -p 15-3.4-bundle + +mkdir -p 12-3.4-bundle/bookworm +mkdir -p 13-3.4-bundle/bookworm +mkdir -p 14-3.4-bundle/bookworm +mkdir -p 15-3.4-bundle/bookworm + +touch 12-3.4-bundle/bookworm/Dockerfile +touch 13-3.4-bundle/bookworm/Dockerfile +touch 14-3.4-bundle/bookworm/Dockerfile +touch 15-3.4-bundle/bookworm/Dockerfile diff --git a/tools/apply-ci.sh b/tools/apply-ci.sh new file mode 100755 index 000000000..cf3ba3902 --- /dev/null +++ b/tools/apply-ci.sh @@ -0,0 +1,93 @@ +#!/bin/bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh + +[ -f ./versions.json ] +input_file="versions.json" + +# cleaning the workfile +rm -f _matrix.yml +rm -f _circleci_arm64.yml + +## Load .env files config. +#set -a +#if [[ "${TEST:-}" == "true" ]]; then +# # shellcheck disable=SC1091 +# source .env.test +#else +# # shellcheck disable=SC1091 +# source .env +#fi +#set +a + +versions=$(jq 'keys[]' "$input_file") + +# the bundle version and the source - should be generated in the same workflow. +# so we need all bundle base list - for removing the matrix. +function generate_versions_bundle_base() { + versions_bundle_base='' + for version in $versions; do + version=$(echo "$version" | tr -d '"') + variants=$(jq ".\"$version\" | keys[]" "$input_file") + for variant in $variants; do + variant=$(echo "$variant" | tr -d '"') + if [[ $(echo "$version" | grep -o '-' | wc -l) -eq 2 ]]; then + echo "bundle detected: ${version}-${variant} ( The version variable contains two '-' ) " + versions_bundle_base+=$(echo "${version}" | cut -d'-' -f1-2)-${variant} + fi + done + done + echo "## versions_bundle_base=$versions_bundle_base" +} +generate_versions_bundle_base + +#TODO: arch based filter for amd64 and arm64 +for version in $versions; do + # Remove quotes around version + version=$(echo "$version" | tr -d '"') + variants=$(jq ".\"$version\" | keys[]" "$input_file") + for variant in $variants; do + + # Remove quotes around variant + variant=$(echo "$variant" | tr -d '"') + arch=$(jq -r ".\"$version\".\"$variant\".arch" "$input_file") + + if [[ $arch == *"amd64"* ]]; then + if [[ $versions_bundle_base =~ ${version}-${variant} ]]; then + echo "# --skip-- - { version: \"$version\", variant: \"$variant\" } --> generated with the related bundle job!" >>_matrix.yml + else + echo " - { version: \"$version\", variant: \"$variant\" }" >>_matrix.yml + fi + fi + + if [[ $arch == *"arm64"* ]]; then + if [[ $versions_bundle_base =~ ${version}-${variant} ]]; then + echo "# --skip-- \"${version}-${variant}\", --> generated with the related bundle job!" >>_circleci_arm64.yml + else + echo " \"${version}-${variant}\"," >>_circleci_arm64.yml + fi + fi + + done +done + +# ------------- Update .github/workflows/main.yml ------------------ +echo "## update .github/workflows/main.yml ##" +awk -v content="$(<_matrix.yml)" ' +$0 ~ "#matrix-include-start" {print; print content; f=1; next} +$0 ~ "#matrix-include-end" {f=0} +!f' .github/workflows/main.yml >.github/workflows/main.tmp && mv .github/workflows/main.tmp .github/workflows/main.yml + +echo "## _matrix.yml ## " +cat _matrix.yml + +# ------------- Update .circleci/config.yml ------------------ +echo "## update .circleci/config.yml ##" +awk -v content="$(<_circleci_arm64.yml)" ' +$0 ~ "#circleci-targets-start" {print; print content; f=1; next} +$0 ~ "#circleci-targets-end" {f=0} +!f' .circleci/config.yml >.circleci/config.tmp && mv .circleci/config.tmp .circleci/config.yml + +echo "## _circleci_arm64.yml ##" +cat _circleci_arm64.yml diff --git a/tools/apply-manifest.sh b/tools/apply-manifest.sh new file mode 100755 index 000000000..fea0181b3 --- /dev/null +++ b/tools/apply-manifest.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh + +[ -f ./versions.json ] +input_file="versions.json" +rm -f ./tools/manifest.sh + +cat <<'EOF' > ./tools/manifest.sh +#!/usr/bin/env bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh +[ -f ./versions.json ] + +# +# Updating the docker manifest for the postgis image. +# This script uses the version.json metadata file as input to create the updated manifest. +# manifest-tool doc : https://github.com/estesp/manifest-tool +# +# NOTE: THIS FILE IS GENERATED VIA "./tools/apply-manifest.sh" +# PLEASE DO NOT EDIT IT DIRECTLY. +# +EOF + +create_manifest() { + local tags="$1" + local arch="$2" + + # Split tags and arch into arrays + IFS=' ' read -ra tag_array <<<"$tags" + IFS=' ' read -ra arch_array <<<"$arch" + + # Check the arch parameter + if [[ ${#arch_array[@]} -lt 1 || ${#arch_array[@]} -gt 2 ]]; then + echo "Error: The arch parameter must have 1 or 2 elements." + return 1 + fi + + local platform_arch="" + for element in "${arch_array[@]}"; do + if [ -z "$platform_arch" ]; then + platform_arch="linux/$element" + else + platform_arch="$platform_arch,linux/$element" + fi + done + + # Create and push manifest for each tag. + # comment: Sometimes some images is missing ( ~ synchronisation issues with CircleCI ) + # .. and we have to continue the script, so we use the || true + for tag in "${tag_array[@]}"; do + echo "" + echo "echo \"manifest: \${dockername}:${tag}\"" + echo "manifest-tool push from-args \\" + echo " --platforms $platform_arch \\" + echo " --template \${dockername}-ARCHVARIANT:${tag} \\" + echo " --target \${dockername}:${tag} || true" + done +} + +versions=$(jq 'keys[]' "$input_file") +for version in $versions; do + # Remove quotes around version + version=$(echo "$version" | tr -d '"') + variants=$(jq ".\"$version\" | keys[]" "$input_file") + for variant in $variants; do + # Remove quotes around variant + variant=$(echo "$variant" | tr -d '"') + tags=$(jq -r ".\"$version\".\"$variant\".tags" "$input_file") + arch=$(jq -r ".\"$version\".\"$variant\".arch" "$input_file") + + ( + echo "" + echo "# ----- ${version}-${variant} -----" + create_manifest "$tags" "$arch" + ) >> ./tools/manifest.sh + + done +done + +echo "Done! a new ./tools/manifest.sh has been created!" +chmod +x ./tools/manifest.sh +head -n 50 <./tools/manifest.sh diff --git a/tools/apply-readme.sh b/tools/apply-readme.sh new file mode 100755 index 000000000..e7c409f23 --- /dev/null +++ b/tools/apply-readme.sh @@ -0,0 +1,99 @@ +#!/bin/bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh + +[ -f ./versions.json ] + +input_file="versions.json" +versions=$(jq 'keys[]' "$input_file") +distinct_variants=$(jq -r 'to_entries[] | .value | keys[]' "$input_file" | sort -u) + +rm -f _dockerlists_*.md +for readme_group in $distinct_variants recent locked bundle0 test; do + echo "init _dockerlists_${readme_group}.md" + echo "| \`$README_IMAGE_NAME:\` tags | Dockerfile | Arch | OS | Postgres | PostGIS |" >>_dockerlists_"${readme_group}".md + echo "| ---- | :-: | :-: | :-: | :-: | :-: |" >>_dockerlists_"${readme_group}".md +done + +for version in $versions; do + # Remove quotes around version + version=$(echo "$version" | tr -d '"') + variants=$(jq ".\"$version\" | keys[]" "$input_file") + for variant in $variants; do + + variant=$(echo "$variant" | tr -d '"') + readme_group=$(jq -r ".\"$version\".\"$variant\".readme_group" "$input_file") + PG_DOCKER=$(jq -r ".\"$version\".\"$variant\".PG_DOCKER" "$input_file") + POSTGIS_VERSION=$(jq -r ".\"$version\".\"$variant\".POSTGIS_VERSION" "$input_file") + postgis=$(jq -r ".\"$version\".\"$variant\".postgis" "$input_file") + arch=$(jq -r ".\"$version\".\"$variant\".arch" "$input_file") + + if [[ "$postgis" == "master" ]]; then + POSTGIS_DOC_VERSION="development: postgis, geos, proj, gdal, cgal, sfcgal" + elif [[ "$postgis" == "recent" || "$readme_group" == "locked" ]]; then + + POSTGIS_TAG=$(jq -r ".\"$version\".\"$variant\".POSTGIS_CHECKOUT" "$input_file") + PROJ_TAG=$(jq -r ".\"$version\".\"$variant\".PROJ_CHECKOUT" "$input_file") + GDAL_TAG=$(jq -r ".\"$version\".\"$variant\".GDAL_CHECKOUT" "$input_file") + GEOS_TAG=$(jq -r ".\"$version\".\"$variant\".GEOS_CHECKOUT" "$input_file") + CGAL_TAG=$(jq -r ".\"$version\".\"$variant\".CGAL_CHECKOUT" "$input_file") + SFCGAL_TAG=$(jq -r ".\"$version\".\"$variant\".SFCGAL_CHECKOUT" "$input_file") + + POSTGIS_DOC_VERSION="postgis=${POSTGIS_TAG}, geos=${GEOS_TAG}, proj=${PROJ_TAG}, gdal=${GDAL_TAG}, cgal=${CGAL_TAG}, sfcgal=${SFCGAL_TAG}" + else + POSTGIS_DOC_VERSION=$(echo "$POSTGIS_VERSION" | awk -F'[+-]' '{print $1}') + fi + + tags=$(jq -r ".\"$version\".\"$variant\".tags" "$input_file") + tagslinks="" + for tag in $tags; do + tagslinks+="[\`${tag}\`](${dockerhublink}${tag}), " + done + # Remove trailing comma and space + tagslinks=$(echo -n "$tagslinks" | sed 's/, *$//') + + echo "| ${tagslinks} | [Dockerfile](${githubrepolink}/${version}/${variant}/Dockerfile) | ${arch} | ${variant} | ${PG_DOCKER} | ${POSTGIS_DOC_VERSION} |" >>_dockerlists_"${readme_group}".md + + done +done + +echo "|-------------------------|" +echo "|- Generated images -|" +echo "|-------------------------|" + +for readme_group in $distinct_variants recent locked bundle0 test; do + echo " " + echo "---- ${readme_group} ----" + cat _dockerlists_"${readme_group}".md +done + +# ------------- Update README.md ------------------ +# Get current date and Replace date in README.md +TODAY=$(date +%Y-%m-%d) +sed -i -r "s/(## Versions) \([0-9]{4}-[0-9]{2}-[0-9]{2}\)/\1 ($TODAY)/g" README.md +# Replace content between the special comments in README.md for each readme_group +for readme_group in $distinct_variants recent locked bundle0 test; do + echo "## ${readme_group} ##" + awk -v readme_group="$readme_group" -v content="$(<_dockerlists_"${readme_group}".md)" ' + $0 ~ "" {print; print content; f=1; next} + $0 ~ "" {f=0} + !f' README.md >tmp.md && mv tmp.md README.md +done + +# Check README.md size; for safe uploading to the docker hub; +# https://github.com/peter-evans/dockerhub-description/issues/69 +README_SIZE_LIMIT=25000 +file_size=$(stat --format=%s "README.md") +echo " " +echo "README.md size is $file_size bytes ( max limit $README_SIZE_LIMIT bytes )" +if [[ $file_size -ge $README_SIZE_LIMIT ]]; then + echo "WARNING: README.md is too large ($file_size bytes). " + echo " Must be less than $README_SIZE_LIMIT bytes!" + echo " The github API automatically truncates README.md files to $README_SIZE_LIMIT bytes." + echo " " +fi + +echo " " +echo "README.md updated " +echo " " diff --git a/tools/apply-templates.sh b/tools/apply-templates.sh new file mode 100755 index 000000000..f8dbcfed9 --- /dev/null +++ b/tools/apply-templates.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh + +# This code derived from: +# - URL: https://github.com/docker-library/postgres/blob/master/apply-templates.sh +# - Copyright: (c) Docker PostgreSQL Authors +# - MIT License, https://github.com/docker-library/postgres/blob/master/LICENSE + +# Check dependencies +[ -f ./versions.json ] + +jqt='.jq-template.awk' +if [ -n "${BASHBREW_SCRIPTS:-}" ]; then + jqt="$BASHBREW_SCRIPTS/jq-template.awk" +elif [ "${BASH_SOURCE[0]}" -nt "$jqt" ]; then + # https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk + wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk' +fi + +jqf='.template-helper-functions.jq' +if [ -n "${BASHBREW_SCRIPTS:-}" ]; then + jqf="$BASHBREW_SCRIPTS/template-helper-functions.jq" +elif [ "${BASH_SOURCE[0]}" -nt "$jqf" ]; then + wget -qO "$jqf" 'https://github.com/docker-library/bashbrew/raw/master/scripts/template-helper-functions.jq' +fi + +if [ "$#" -eq 0 ]; then + versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" + eval "set -- $versions" +fi + +echo "versions = $versions" + +generated_warning() { + cat <<-EOH + # + # NOTE: THIS DOCKERFILE IS GENERATED VIA "./tools/apply-templates.sh" + # source: "$1" + # PLEASE DO NOT EDIT IT DIRECTLY. + # + EOH +} + +for version; do + export version + + bundleType="$(echo "$version" | cut -d '-' -f 3)" + variants="$(jq -r '.[env.version]| keys | map(@sh) | join(" ")' versions.json)" + eval "variants=( $variants )" + + for variant in "${variants[@]}"; do + export variant + + dir="$version/$variant" + echo "processing $dir ..." + + template=./templates/"$(jq -r '.[env.version][env.variant].template' versions.json)" + echo " template=$template" + + initfile=./templates/"$(jq -r '.[env.version][env.variant].initfile' versions.json)" + echo " initfile=$initfile" + + tags="$(jq -r '.[env.version][env.variant].tags' versions.json)" + echo " tags=$tags" + + cp -a "$initfile" "$dir/" + if [ -z "$bundleType" ]; then + cp -a ./templates/update-postgis.sh "$dir/" + fi + + echo "$tags" >"$dir/tags" + + { + generated_warning "$template" + gawk -f "$jqt" "$template" + } >"$dir/Dockerfile" + + done +done + +echo " " +echo " ./tools/apply-template : done" +echo " " diff --git a/tools/cache_helper.sh b/tools/cache_helper.sh new file mode 100755 index 000000000..e4bf4648b --- /dev/null +++ b/tools/cache_helper.sh @@ -0,0 +1,154 @@ +#!/bin/bash +# Cache management functions for API calls +# Reduces GitHub API rate limiting by caching responses + +set -Eeuo pipefail + +CACHE_DIR="_cache" +CACHE_TIMESTAMPS_FILE="${CACHE_DIR}/cache_timestamps.txt" + +# Initialize cache directory +cache_init() { + mkdir -p "$CACHE_DIR" + [[ -f "$CACHE_TIMESTAMPS_FILE" ]] || touch "$CACHE_TIMESTAMPS_FILE" +} + +# Check if cache file is valid (within TTL) +cache_is_valid() { + local cache_file="$1" + local ttl_hours="${2:-6}" + local max_age=$((ttl_hours * 3600)) + + if [[ -f "$cache_file" ]]; then + local file_age=$(( $(date +%s) - $(stat -c %Y "$cache_file") )) + if [[ $file_age -lt $max_age ]]; then + return 0 # Valid + fi + fi + return 1 # Invalid or doesn't exist +} + +# Get data from cache if valid +cache_get() { + local cache_key="$1" + local cache_file="${CACHE_DIR}/${cache_key}.txt" + local ttl_hours="${2:-6}" + + cache_init + + if cache_is_valid "$cache_file" "$ttl_hours"; then + echo "# Cache hit: $cache_key ($(stat -c %y "$cache_file"))" >&2 + cat "$cache_file" + return 0 + else + echo "# Cache miss: $cache_key" >&2 + return 1 + fi +} + +# Store data in cache +cache_store() { + local cache_key="$1" + local data="$2" + local cache_file="${CACHE_DIR}/${cache_key}.txt" + + cache_init + + echo "$data" > "$cache_file" + + # Update timestamp record + grep -v "^${cache_key}=" "$CACHE_TIMESTAMPS_FILE" > "${CACHE_TIMESTAMPS_FILE}.tmp" 2>/dev/null || true + echo "${cache_key}=$(date +%s)" >> "${CACHE_TIMESTAMPS_FILE}.tmp" + mv "${CACHE_TIMESTAMPS_FILE}.tmp" "$CACHE_TIMESTAMPS_FILE" + + echo "# Cached: $cache_key" >&2 +} + +# Clean old cache files +cache_cleanup() { + local days_old="${1:-7}" + + if [[ -d "$CACHE_DIR" ]]; then + echo "# Cleaning cache files older than $days_old days..." >&2 + find "$CACHE_DIR" -name "*.txt" -type f -mtime +"$days_old" -delete 2>/dev/null || true + fi +} + +# Show cache status +cache_status() { + echo "# Cache Directory: $CACHE_DIR" + if [[ -d "$CACHE_DIR" ]]; then + echo "# Cache files:" + find "$CACHE_DIR" -name "*.txt" -type f -exec ls -lah {} \; 2>/dev/null || echo "# No cache files found" + else + echo "# Cache directory doesn't exist" + fi +} + +# Wrapper for curl with cache support +cached_curl() { + local cache_key="$1" + local url="$2" + local ttl_hours="${3:-6}" + shift 3 + local curl_args=("$@") + + # Try cache first + if cache_get "$cache_key" "$ttl_hours"; then + return 0 + fi + + # Cache miss - make API call + echo "# Fetching from API: $url" >&2 + local response + if response=$(curl -s "${curl_args[@]}" "$url"); then + cache_store "$cache_key" "$response" + echo "$response" + return 0 + else + echo "# API call failed for: $url" >&2 + return 1 + fi +} + +# Check GitHub rate limit before making API calls +check_github_rate_limit() { + local min_required="${1:-8}" # Default: need at least 8 requests + + echo "# Checking GitHub rate limit before API calls..." + + # Get rate limit info from headers + local rateLimitHeaders + if ! rateLimitHeaders=$(curl -sI https://api.github.com/users/postgis 2>/dev/null | grep -i x-ratelimit); then + echo "# Failed to check GitHub rate limit - proceeding with caution" + return 0 # Allow to continue if check fails + fi + + local rateLimitRemaining + rateLimitRemaining=$(echo "$rateLimitHeaders" | grep -i 'x-ratelimit-remaining:' | grep -o '[[:digit:]]*' || echo "0") + + echo "# GitHub rate limit remaining: $rateLimitRemaining" + + if [ "${rateLimitRemaining}" -le "${min_required}" ]; then + echo + echo " You do not have enough github requests available to continue!" + echo " Current remaining: $rateLimitRemaining, required: $min_required" + echo + echo " Without logging - the github api is limited to 60 requests per hour" + echo " see: https://developer.github.com/v3/#rate-limiting " + echo " You can check your remaining requests with :" + echo " curl -sI https://api.github.com/users/postgis | grep x-ratelimit " + echo + echo " ------------------------ " + echo "$rateLimitHeaders" + echo + echo " The limit will be reset at :" + echo "$rateLimitHeaders" | grep -i 'x-ratelimit-reset:' | cut -d' ' -f2 | xargs -I {} date -d @{} 2>/dev/null || echo "Unable to parse reset time" + return 1 # Fail - not enough requests + fi + + return 0 # Success - enough requests available +} + +# Export functions for use in other scripts +export -f cache_init cache_is_valid cache_get cache_store cache_cleanup cache_status cached_curl check_github_rate_limit \ No newline at end of file diff --git a/tools/environment_init.sh b/tools/environment_init.sh new file mode 100755 index 000000000..fe6da9ff5 --- /dev/null +++ b/tools/environment_init.sh @@ -0,0 +1,146 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +# Check if IMAGE_VERSION_ID is already set +if [ -n "${IMAGE_VERSION_ID:-}" ]; then + # note: Script already ran, exiting early. + return 0 +fi + +# Load .env files config. +set -a +if [[ "${TEST:-}" == "true" ]]; then + # shellcheck disable=SC1091 + source .env.test + echo "TEST MODE!" +else + # shellcheck disable=SC1091 + source .env +fi +set +a + +if [ -z "$REGISTRY" ] || [ -z "$REPO_NAME" ] || [ -z "$IMAGE_NAME" ]; then + echo "Error: REGISTRY,REPO_NAME and IMAGE_NAME must be set" >&2 + exit 1 +fi + +# Determine IMAGE_ARCH based on the machine architecture +if [[ "$(uname -m)" == "x86_64" ]]; then + IMAGE_ARCH=amd64 +elif [[ "$(uname -m)" == "aarch64" ]]; then + IMAGE_ARCH=arm64 +else + echo "Architecture not supported: $(uname -m)" + exit 1 +fi +export IMAGE_ARCH + +# create README.md image name ( no arch!) +README_IMAGE_NAME="${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}" +export README_IMAGE_NAME + +# Modify IMAGE_NAME if ENABLE_IMAGE_ARCH is set to true +if [[ "${ENABLE_IMAGE_ARCH:-}" == "true" ]]; then + IMAGE_NAME="${IMAGE_NAME}-${IMAGE_ARCH}" +fi +export IMAGE_NAME + +# Override the default values of variables +# by setting the corresponding environment variables, if needed. +if [[ "$REGISTRY" == "docker.io" ]]; then + dockername="${REPO_NAME}/${IMAGE_NAME}" +else + dockername="${REGISTRY}/${REPO_NAME}/${IMAGE_NAME}" + +fi +export dockername + +# Initialize IMAGE_VERSION_ID as an empty string +IMAGE_VERSION_ID="" +# Generate IMAGE_VERSION_ID if ENABLE_IMAGE_VERSION_ID is set to true +if [[ "${ENABLE_IMAGE_VERSION_ID:-}" == "true" ]]; then + # Note: Make sure to keep this synchronized with the corresponding section in Makefile + if git rev-parse --git-dir >/dev/null 2>&1; then + COMMIT_DATE=$(git log -1 --format=%cd --date=format:%Y%m%d) + COMMIT_HASH=$(git log -1 --pretty=format:%h) + else + echo "Warning: Not in a git repository. Using fallback values for IMAGE_VERSION_ID." >&2 + COMMIT_DATE="00000000" + COMMIT_HASH="00000000" + fi + BUILD_WEEK=$(date '+%Yw%V') + IMAGE_VERSION_ID="-ver${COMMIT_DATE}-${COMMIT_HASH}-${BUILD_WEEK}" +fi +export IMAGE_VERSION_ID + +echo " ---- .env file loaded ----" +echo " - REGISTRY : $REGISTRY" +echo " - REPO_NAME : $REPO_NAME" +echo " - IMAGE_NAME : $IMAGE_NAME" +echo " - IMAGE_ARCH : $IMAGE_ARCH" +echo " - dockername : ${dockername}" +echo " - IMAGE_VERSION_ID: ${IMAGE_VERSION_ID}" +echo " " + +# Verify that the required command-line tools (jq, gawk, python3, .. ) are available in the system's PATH. +# Exit with an error message if any of them are missing. +for cmd in docker jq check-jsonschema gawk curl python3 manifest-tool lastversion; do + if ! command -v "$cmd" &>/dev/null; then + echo "Error: $cmd is not installed." + exit 1 + fi +done + +# Ensure that the necessary Python modules (yaml, json) are installed and can be imported. +# Exit with an error message if any of them are missing. +if ! python3 -c 'import yaml, json' &>/dev/null; then + echo "Error: Required python3 modules (yaml or json) are not installed." + echo " Please install them using 'pip3 install yaml json'." + exit 1 +fi + +# Define a function to check for the existence of a Docker image tag. +# Usage: +# check_image_exists "tag" +# +# This function uses `manifest-tool` to inspect the image manifest. It is a more reliable way to check +# for image existence across different platforms and registries without requiring the image to be pulled locally. +# +# The function prints a message indicating whether the image-tag exists and returns an exit code. +# Exit code 0 indicates that the image-tag exists, while 1 indicates non-existence. +function check_image_exists() { + local image_name="${dockername}:$1" + local output + local secure_opt="" + + # Check if dockername contains 'localhost:5000' + if [[ $dockername == *"localhost:5000"* ]]; then + echo "The name contains 'localhost:5000' ; insecure and plain-http mode is enabled !" + secure_opt=(--insecure --plain-http) + else + secure_opt=() + fi + + # Attempt to inspect the image using manifest-tool. Capture the output, including any errors. + output=$(manifest-tool "${secure_opt[@]}" inspect "$image_name" 2>&1 || true) + + echo "" + echo "--[ manifest-tool inspect $image_name ]---" + echo "$output" + echo "--[ manifest-tool inspect $image_name ]---" + echo "" + + # Check the output for a "not found" message, which indicates the image does not exist. + if echo "$output" | grep -q "not found"; then + echo "The Docker image '$image_name' does not exist." + return 1 # Return an exit code of 1 to signify the image does not exist. + elif echo "$output" | grep -q "digest"; then + echo "The Docker image '$image_name' exists." + return 0 + else + echo "unknow error" + return 1 + fi +} + +export -f check_image_exists diff --git a/tools/get_versions_changes.sh b/tools/get_versions_changes.sh new file mode 100755 index 000000000..bd4c75967 --- /dev/null +++ b/tools/get_versions_changes.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -Eeuo pipefail + +# Get changed versions from git diff +# used by auto update CI : .github/workflows/update.yml + +# example outputs: DUCKDB:v0.10.1,MOBILITYDB:v1.1.0 + +git diff versions.json | + grep "^+" | + sed 's/^+//' | + grep -E "_CHECKOUT|_VERSION" | + grep -vE "_SHA1" | + sed 's/_CHECKOUT"//g;s/_VERSION"//g' | + sed 's# "tags/##g' | + sed 's#"##g' | + sed 's# ##g' | + sed 's#,##g' | + sort | uniq | + awk 'BEGIN { ORS=""; print ""; total_length=0; } { word_length=length($0)+1; if (total_length+word_length<=80) { print (NR>1?",":"") $0; total_length+=word_length; } else { exit; } }' diff --git a/tools/install_dive.sh b/tools/install_dive.sh new file mode 100755 index 000000000..b6537a952 --- /dev/null +++ b/tools/install_dive.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -Eeuo pipefail + +# https://github.com/wagoodman/dive/releases/tag/v0.13.1 +version="0.13.1" + +# Determine IMAGE_ARCH based on the machine architecture +if [[ "$(uname -m)" == "x86_64" ]]; then + IMAGE_ARCH=amd64 + checksum="0970549eb4a306f8825a84145a2534153badb4d7dcf3febd1967c706367c3d0e tools/dive_0.13.1_linux_amd64.tar.gz" +elif [[ "$(uname -m)" == "aarch64" ]]; then + IMAGE_ARCH=arm64 + checksum="2fcd2cf20f634ccdb41efac44048b204bfc867c115641f37a7420693ed480a18 tools/dive_0.13.1_linux_arm64.tar.gz" +else + echo "Architecture not supported: $(uname -m)" + exit 1 +fi + +# Download wagoodman/dive tool +rm -f "tools/dive" +rm -f "tools/dive_${version}_linux_${IMAGE_ARCH}.tar.gz" +wget https://github.com/wagoodman/dive/releases/download/v${version}/dive_${version}_linux_${IMAGE_ARCH}.tar.gz -O tools/dive_${version}_linux_${IMAGE_ARCH}.tar.gz +echo "${checksum}" | sha256sum --check +tar -xzf "tools/dive_${version}_linux_${IMAGE_ARCH}.tar.gz" -C "tools/" +chmod +x "tools/dive" +rm -f "tools/dive_${version}_linux_${IMAGE_ARCH}.tar.gz" + +# Check dive version +tools/dive -v diff --git a/tools/install_manifest-tool.sh b/tools/install_manifest-tool.sh new file mode 100755 index 000000000..785c8e34a --- /dev/null +++ b/tools/install_manifest-tool.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -Eeuo pipefail + +# https://github.com/estesp/manifest-tool +version="2.2.0" + +# Determine IMAGE_ARCH based on the machine architecture +if [[ "$(uname -m)" == "x86_64" ]]; then + IMAGE_ARCH=amd64 +elif [[ "$(uname -m)" == "aarch64" ]]; then + IMAGE_ARCH=arm64 +else + echo "Architecture not supported: $(uname -m)" + exit 1 +fi +export IMAGE_ARCH + +# Download manifest-tool +wget https://github.com/estesp/manifest-tool/releases/download/v${version}/binaries-manifest-tool-${version}.tar.gz +mkdir -p manifest-tool +tar -xvzf binaries-manifest-tool-${version}.tar.gz -C manifest-tool +sudo mv manifest-tool/manifest-tool-linux-${IMAGE_ARCH} /usr/local/bin/manifest-tool +rm -f binaries-manifest-tool-${version}.tar.gz +rm -rf ./manifest-tool/manifest-tool-* # remove other archs + +# Check manifest-tool version +manifest-tool -v diff --git a/tools/install_shellcheck.sh b/tools/install_shellcheck.sh new file mode 100755 index 000000000..57dfc5fb3 --- /dev/null +++ b/tools/install_shellcheck.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail + +# https://github.com/koalaman/shellcheck#installing-a-pre-compiled-binary + +scversion="stable" +wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv +cp "shellcheck-${scversion}/shellcheck" /usr/bin/ +shellcheck --version diff --git a/tools/localtest.sh b/tools/localtest.sh new file mode 100755 index 000000000..d3beae313 --- /dev/null +++ b/tools/localtest.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +# Enable TEST mode and use the local registry at localhost:5000 (as specified in the .env.test file). +export TEST=true +# Source environment variables and necessary configurations +source tools/environment_init.sh +[ -f ./versions.json ] + +# Check if the container with name "registry" is already running +# https://docs.docker.com/registry/deploying/ + +docker ps -a + +testregistry="postgistestregistry" +testregistry_cid=$(docker ps -q -f name="$testregistry") +echo "testregistry_cid=$testregistry_cid" + +if [ -z "$testregistry_cid" ]; then + # Not running - start registry + docker pull registry:2 + docker run -d -p 5000:5000 --restart=always --name "$testregistry" registry:2 + # -v /mnt/registry:/var/lib/registry \ +else + # If running, output a message + echo "Container with name: $testregistry is already running" +fi + +# check update code +./update.sh + +check-jsonschema --schemafile versions.schema.json versions.json + +test_tag=17-3.5-bookworm + +# check commands +make -n test-${test_tag} +make -n push-${test_tag} +make -n manifest-${test_tag} + +# run commands +make test-${test_tag} +make push-${test_tag} +make manifest-${test_tag} + +# check images +echo " " +echo " ---- generated images ---- " +make dockerlist + +# check images +echo " " +echo " ---- check images exists ---- " +image_to_check="$test_tag" +if check_image_exists "$image_to_check"; then + echo "Image '$image_to_check' is available." +else + echo "Image '$image_to_check' does not exist." + echo "Unexpected error .. STOP" + exit 1 +fi + +# should not exists .... +if check_image_exists "99-9.9.9"; then + echo "exist - Unexpected error .. STOP" + exit 1 +else + echo "OK: not found check is OK" +fi + +# check registy +echo " --- registry --- " +make lregistryinfo + +echo " " +echo "WARNING: Be carefull and not push the .localtest.sh script generated Dockerfiles," +echo " because contains reference to the test REGISTRY, REPO_NAME and IMAGE_NAME!" +echo " " +echo "done." diff --git a/tools/manifest.sh b/tools/manifest.sh new file mode 100755 index 000000000..940e82998 --- /dev/null +++ b/tools/manifest.sh @@ -0,0 +1,846 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh +[ -f ./versions.json ] + +# +# Updating the docker manifest for the postgis image. +# This script uses the version.json metadata file as input to create the updated manifest. +# manifest-tool doc : https://github.com/estesp/manifest-tool +# +# NOTE: THIS FILE IS GENERATED VIA "./tools/apply-manifest.sh" +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +# ----- 13-3.3-alpine3.21 ----- + +echo "manifest: ${dockername}:13-3.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.3-alpine3.21 \ + --target ${dockername}:13-3.3-alpine3.21 || true + +echo "manifest: ${dockername}:13-3.3.8-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.3.8-alpine3.21 \ + --target ${dockername}:13-3.3.8-alpine3.21 || true + +# ----- 13-3.4-alpine3.21 ----- + +echo "manifest: ${dockername}:13-3.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.4-alpine3.21 \ + --target ${dockername}:13-3.4-alpine3.21 || true + +echo "manifest: ${dockername}:13-3.4.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.4.4-alpine3.21 \ + --target ${dockername}:13-3.4.4-alpine3.21 || true + +# ----- 13-3.4-alpine3.22 ----- + +echo "manifest: ${dockername}:13-3.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.4-alpine3.22 \ + --target ${dockername}:13-3.4-alpine3.22 || true + +echo "manifest: ${dockername}:13-3.4.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.4.4-alpine3.22 \ + --target ${dockername}:13-3.4.4-alpine3.22 || true + +echo "manifest: ${dockername}:13-3.4-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.4-alpine \ + --target ${dockername}:13-3.4-alpine || true + +# ----- 13-3.5-alpine3.21 ----- + +echo "manifest: ${dockername}:13-3.5-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5-alpine3.21 \ + --target ${dockername}:13-3.5-alpine3.21 || true + +echo "manifest: ${dockername}:13-3.5.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5.3-alpine3.21 \ + --target ${dockername}:13-3.5.3-alpine3.21 || true + +# ----- 13-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:13-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5-alpine3.22 \ + --target ${dockername}:13-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:13-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5.3-alpine3.22 \ + --target ${dockername}:13-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:13-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5-alpine \ + --target ${dockername}:13-3.5-alpine || true + +# ----- 13-3.5-bookworm ----- + +echo "manifest: ${dockername}:13-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5-bookworm \ + --target ${dockername}:13-3.5-bookworm || true + +echo "manifest: ${dockername}:13-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5.3-bookworm \ + --target ${dockername}:13-3.5.3-bookworm || true + +echo "manifest: ${dockername}:13-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5 \ + --target ${dockername}:13-3.5 || true + +# ----- 13-3.5-bullseye ----- + +echo "manifest: ${dockername}:13-3.5-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5-bullseye \ + --target ${dockername}:13-3.5-bullseye || true + +echo "manifest: ${dockername}:13-3.5.2-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:13-3.5.2-bullseye \ + --target ${dockername}:13-3.5.2-bullseye || true + +# ----- 14-3.3-alpine3.21 ----- + +echo "manifest: ${dockername}:14-3.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.3-alpine3.21 \ + --target ${dockername}:14-3.3-alpine3.21 || true + +echo "manifest: ${dockername}:14-3.3.8-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.3.8-alpine3.21 \ + --target ${dockername}:14-3.3.8-alpine3.21 || true + +# ----- 14-3.4-alpine3.21 ----- + +echo "manifest: ${dockername}:14-3.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.4-alpine3.21 \ + --target ${dockername}:14-3.4-alpine3.21 || true + +echo "manifest: ${dockername}:14-3.4.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.4.4-alpine3.21 \ + --target ${dockername}:14-3.4.4-alpine3.21 || true + +# ----- 14-3.4-alpine3.22 ----- + +echo "manifest: ${dockername}:14-3.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.4-alpine3.22 \ + --target ${dockername}:14-3.4-alpine3.22 || true + +echo "manifest: ${dockername}:14-3.4.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.4.4-alpine3.22 \ + --target ${dockername}:14-3.4.4-alpine3.22 || true + +echo "manifest: ${dockername}:14-3.4-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.4-alpine \ + --target ${dockername}:14-3.4-alpine || true + +# ----- 14-3.5-alpine3.21 ----- + +echo "manifest: ${dockername}:14-3.5-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5-alpine3.21 \ + --target ${dockername}:14-3.5-alpine3.21 || true + +echo "manifest: ${dockername}:14-3.5.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5.3-alpine3.21 \ + --target ${dockername}:14-3.5.3-alpine3.21 || true + +# ----- 14-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:14-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5-alpine3.22 \ + --target ${dockername}:14-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:14-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5.3-alpine3.22 \ + --target ${dockername}:14-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:14-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5-alpine \ + --target ${dockername}:14-3.5-alpine || true + +# ----- 14-3.5-bookworm ----- + +echo "manifest: ${dockername}:14-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5-bookworm \ + --target ${dockername}:14-3.5-bookworm || true + +echo "manifest: ${dockername}:14-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5.3-bookworm \ + --target ${dockername}:14-3.5.3-bookworm || true + +echo "manifest: ${dockername}:14-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5 \ + --target ${dockername}:14-3.5 || true + +# ----- 14-3.5-bullseye ----- + +echo "manifest: ${dockername}:14-3.5-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5-bullseye \ + --target ${dockername}:14-3.5-bullseye || true + +echo "manifest: ${dockername}:14-3.5.2-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-3.5.2-bullseye \ + --target ${dockername}:14-3.5.2-bullseye || true + +# ----- 14-l3.1.9gcp-bookworm ----- + +echo "manifest: ${dockername}:14-l3.1.9gcp-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-l3.1.9gcp-bookworm \ + --target ${dockername}:14-l3.1.9gcp-bookworm || true + +echo "manifest: ${dockername}:14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm \ + --target ${dockername}:14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm || true + +# ----- 15-3.3-alpine3.21 ----- + +echo "manifest: ${dockername}:15-3.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.3-alpine3.21 \ + --target ${dockername}:15-3.3-alpine3.21 || true + +echo "manifest: ${dockername}:15-3.3.8-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.3.8-alpine3.21 \ + --target ${dockername}:15-3.3.8-alpine3.21 || true + +# ----- 15-3.4-alpine3.21 ----- + +echo "manifest: ${dockername}:15-3.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.4-alpine3.21 \ + --target ${dockername}:15-3.4-alpine3.21 || true + +echo "manifest: ${dockername}:15-3.4.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.4.4-alpine3.21 \ + --target ${dockername}:15-3.4.4-alpine3.21 || true + +# ----- 15-3.4-alpine3.22 ----- + +echo "manifest: ${dockername}:15-3.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.4-alpine3.22 \ + --target ${dockername}:15-3.4-alpine3.22 || true + +echo "manifest: ${dockername}:15-3.4.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.4.4-alpine3.22 \ + --target ${dockername}:15-3.4.4-alpine3.22 || true + +echo "manifest: ${dockername}:15-3.4-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.4-alpine \ + --target ${dockername}:15-3.4-alpine || true + +# ----- 15-3.5-alpine3.21 ----- + +echo "manifest: ${dockername}:15-3.5-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5-alpine3.21 \ + --target ${dockername}:15-3.5-alpine3.21 || true + +echo "manifest: ${dockername}:15-3.5.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5.3-alpine3.21 \ + --target ${dockername}:15-3.5.3-alpine3.21 || true + +# ----- 15-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:15-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5-alpine3.22 \ + --target ${dockername}:15-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:15-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5.3-alpine3.22 \ + --target ${dockername}:15-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:15-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5-alpine \ + --target ${dockername}:15-3.5-alpine || true + +# ----- 15-3.5-bookworm ----- + +echo "manifest: ${dockername}:15-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5-bookworm \ + --target ${dockername}:15-3.5-bookworm || true + +echo "manifest: ${dockername}:15-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5.3-bookworm \ + --target ${dockername}:15-3.5.3-bookworm || true + +echo "manifest: ${dockername}:15-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5 \ + --target ${dockername}:15-3.5 || true + +# ----- 15-3.5-bullseye ----- + +echo "manifest: ${dockername}:15-3.5-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5-bullseye \ + --target ${dockername}:15-3.5-bullseye || true + +echo "manifest: ${dockername}:15-3.5.2-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:15-3.5.2-bullseye \ + --target ${dockername}:15-3.5.2-bullseye || true + +# ----- 16-3.3-alpine3.21 ----- + +echo "manifest: ${dockername}:16-3.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.3-alpine3.21 \ + --target ${dockername}:16-3.3-alpine3.21 || true + +echo "manifest: ${dockername}:16-3.3.8-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.3.8-alpine3.21 \ + --target ${dockername}:16-3.3.8-alpine3.21 || true + +# ----- 16-3.4-alpine3.21 ----- + +echo "manifest: ${dockername}:16-3.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.4-alpine3.21 \ + --target ${dockername}:16-3.4-alpine3.21 || true + +echo "manifest: ${dockername}:16-3.4.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.4.4-alpine3.21 \ + --target ${dockername}:16-3.4.4-alpine3.21 || true + +# ----- 16-3.4-alpine3.22 ----- + +echo "manifest: ${dockername}:16-3.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.4-alpine3.22 \ + --target ${dockername}:16-3.4-alpine3.22 || true + +echo "manifest: ${dockername}:16-3.4.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.4.4-alpine3.22 \ + --target ${dockername}:16-3.4.4-alpine3.22 || true + +echo "manifest: ${dockername}:16-3.4-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.4-alpine \ + --target ${dockername}:16-3.4-alpine || true + +# ----- 16-3.5-alpine3.21 ----- + +echo "manifest: ${dockername}:16-3.5-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-alpine3.21 \ + --target ${dockername}:16-3.5-alpine3.21 || true + +echo "manifest: ${dockername}:16-3.5.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5.3-alpine3.21 \ + --target ${dockername}:16-3.5.3-alpine3.21 || true + +# ----- 16-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:16-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-alpine3.22 \ + --target ${dockername}:16-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:16-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5.3-alpine3.22 \ + --target ${dockername}:16-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:16-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-alpine \ + --target ${dockername}:16-3.5-alpine || true + +# ----- 16-3.5-bookworm ----- + +echo "manifest: ${dockername}:16-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-bookworm \ + --target ${dockername}:16-3.5-bookworm || true + +echo "manifest: ${dockername}:16-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5.3-bookworm \ + --target ${dockername}:16-3.5.3-bookworm || true + +echo "manifest: ${dockername}:16-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5 \ + --target ${dockername}:16-3.5 || true + +# ----- 16-3.5-bullseye ----- + +echo "manifest: ${dockername}:16-3.5-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-bullseye \ + --target ${dockername}:16-3.5-bullseye || true + +echo "manifest: ${dockername}:16-3.5.2-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5.2-bullseye \ + --target ${dockername}:16-3.5.2-bullseye || true + +# ----- 16-3.5-bundle0-bookworm ----- + +echo "manifest: ${dockername}:16-3.5-bundle0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-bundle0-bookworm \ + --target ${dockername}:16-3.5-bundle0-bookworm || true + +echo "manifest: ${dockername}:16-3.5.3-bundle0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5.3-bundle0-bookworm \ + --target ${dockername}:16-3.5.3-bundle0-bookworm || true + +echo "manifest: ${dockername}:16-3.5-bundle0" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-3.5-bundle0 \ + --target ${dockername}:16-3.5-bundle0 || true + +# ----- 16-master-bookworm ----- + +echo "manifest: ${dockername}:16-master-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-master-bookworm \ + --target ${dockername}:16-master-bookworm || true + +echo "manifest: ${dockername}:16-master" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-master \ + --target ${dockername}:16-master || true + +# ----- 16-recent-bookworm ----- + +echo "manifest: ${dockername}:16-recent-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-recent-bookworm \ + --target ${dockername}:16-recent-bookworm || true + +echo "manifest: ${dockername}:16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm \ + --target ${dockername}:16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm || true + +echo "manifest: ${dockername}:16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm \ + --target ${dockername}:16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm || true + +echo "manifest: ${dockername}:16-recent" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:16-recent \ + --target ${dockername}:16-recent || true + +# ----- 17-3.4-alpine3.21 ----- + +echo "manifest: ${dockername}:17-3.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.4-alpine3.21 \ + --target ${dockername}:17-3.4-alpine3.21 || true + +echo "manifest: ${dockername}:17-3.4.4-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.4.4-alpine3.21 \ + --target ${dockername}:17-3.4.4-alpine3.21 || true + +# ----- 17-3.4-alpine3.22 ----- + +echo "manifest: ${dockername}:17-3.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.4-alpine3.22 \ + --target ${dockername}:17-3.4-alpine3.22 || true + +echo "manifest: ${dockername}:17-3.4.4-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.4.4-alpine3.22 \ + --target ${dockername}:17-3.4.4-alpine3.22 || true + +echo "manifest: ${dockername}:17-3.4-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.4-alpine \ + --target ${dockername}:17-3.4-alpine || true + +# ----- 17-3.5-alpine3.21 ----- + +echo "manifest: ${dockername}:17-3.5-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-alpine3.21 \ + --target ${dockername}:17-3.5-alpine3.21 || true + +echo "manifest: ${dockername}:17-3.5.3-alpine3.21" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5.3-alpine3.21 \ + --target ${dockername}:17-3.5.3-alpine3.21 || true + +# ----- 17-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:17-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-alpine3.22 \ + --target ${dockername}:17-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:17-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5.3-alpine3.22 \ + --target ${dockername}:17-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:17-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-alpine \ + --target ${dockername}:17-3.5-alpine || true + +echo "manifest: ${dockername}:alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:alpine \ + --target ${dockername}:alpine || true + +# ----- 17-3.5-bookworm ----- + +echo "manifest: ${dockername}:17-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-bookworm \ + --target ${dockername}:17-3.5-bookworm || true + +echo "manifest: ${dockername}:17-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5.3-bookworm \ + --target ${dockername}:17-3.5.3-bookworm || true + +echo "manifest: ${dockername}:17-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5 \ + --target ${dockername}:17-3.5 || true + +echo "manifest: ${dockername}:latest" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:latest \ + --target ${dockername}:latest || true + +# ----- 17-3.5-bullseye ----- + +echo "manifest: ${dockername}:17-3.5-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-bullseye \ + --target ${dockername}:17-3.5-bullseye || true + +echo "manifest: ${dockername}:17-3.5.2-bullseye" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5.2-bullseye \ + --target ${dockername}:17-3.5.2-bullseye || true + +# ----- 17-3.5-bundle0-bookworm ----- + +echo "manifest: ${dockername}:17-3.5-bundle0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-bundle0-bookworm \ + --target ${dockername}:17-3.5-bundle0-bookworm || true + +echo "manifest: ${dockername}:17-3.5.3-bundle0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5.3-bundle0-bookworm \ + --target ${dockername}:17-3.5.3-bundle0-bookworm || true + +echo "manifest: ${dockername}:17-3.5-bundle0" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.5-bundle0 \ + --target ${dockername}:17-3.5-bundle0 || true + +echo "manifest: ${dockername}:bundle0" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:bundle0 \ + --target ${dockername}:bundle0 || true + +# ----- 17-3.6-alpine3.22 ----- + +echo "manifest: ${dockername}:17-3.6.0alpha1-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.6.0alpha1-alpine3.22 \ + --target ${dockername}:17-3.6.0alpha1-alpine3.22 || true + +echo "manifest: ${dockername}:17-3.6.0alpha1-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-3.6.0alpha1-alpine \ + --target ${dockername}:17-3.6.0alpha1-alpine || true + +# ----- 17-master-bookworm ----- + +echo "manifest: ${dockername}:17-master-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-master-bookworm \ + --target ${dockername}:17-master-bookworm || true + +echo "manifest: ${dockername}:17-master" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-master \ + --target ${dockername}:17-master || true + +# ----- 17-recent-bookworm ----- + +echo "manifest: ${dockername}:17-recent-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-recent-bookworm \ + --target ${dockername}:17-recent-bookworm || true + +echo "manifest: ${dockername}:17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm \ + --target ${dockername}:17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm || true + +echo "manifest: ${dockername}:17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm \ + --target ${dockername}:17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm || true + +echo "manifest: ${dockername}:17-recent" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:17-recent \ + --target ${dockername}:17-recent || true + +echo "manifest: ${dockername}:recent" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:recent \ + --target ${dockername}:recent || true + +# ----- 18-3.5-alpine3.22 ----- + +echo "manifest: ${dockername}:18beta1-3.5-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5-alpine3.22 \ + --target ${dockername}:18beta1-3.5-alpine3.22 || true + +echo "manifest: ${dockername}:18beta1-3.5.3-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5.3-alpine3.22 \ + --target ${dockername}:18beta1-3.5.3-alpine3.22 || true + +echo "manifest: ${dockername}:18beta1-3.5-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5-alpine \ + --target ${dockername}:18beta1-3.5-alpine || true + +# ----- 18-3.5-bookworm ----- + +echo "manifest: ${dockername}:18beta1-3.5-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5-bookworm \ + --target ${dockername}:18beta1-3.5-bookworm || true + +echo "manifest: ${dockername}:18beta1-3.5.3-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5.3-bookworm \ + --target ${dockername}:18beta1-3.5.3-bookworm || true + +echo "manifest: ${dockername}:18beta1-3.5" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.5 \ + --target ${dockername}:18beta1-3.5 || true + +# ----- 18-3.6-alpine3.22 ----- + +echo "manifest: ${dockername}:18beta1-3.6.0alpha1-alpine3.22" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.6.0alpha1-alpine3.22 \ + --target ${dockername}:18beta1-3.6.0alpha1-alpine3.22 || true + +echo "manifest: ${dockername}:18beta1-3.6.0alpha1-alpine" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-3.6.0alpha1-alpine \ + --target ${dockername}:18beta1-3.6.0alpha1-alpine || true + +# ----- 18-master-bookworm ----- + +echo "manifest: ${dockername}:18beta1-master-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-master-bookworm \ + --target ${dockername}:18beta1-master-bookworm || true + +echo "manifest: ${dockername}:18beta1-master" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-master \ + --target ${dockername}:18beta1-master || true + +# ----- 18-recent-bookworm ----- + +echo "manifest: ${dockername}:18beta1-recent-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-recent-bookworm \ + --target ${dockername}:18beta1-recent-bookworm || true + +echo "manifest: ${dockername}:18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm \ + --target ${dockername}:18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm || true + +echo "manifest: ${dockername}:18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm \ + --target ${dockername}:18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm || true + +echo "manifest: ${dockername}:18beta1-recent" +manifest-tool push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template ${dockername}-ARCHVARIANT:18beta1-recent \ + --target ${dockername}:18beta1-recent || true diff --git a/tools/setup_local_environment.sh b/tools/setup_local_environment.sh new file mode 100755 index 000000000..df7fc5285 --- /dev/null +++ b/tools/setup_local_environment.sh @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +echo "==============================================" +echo "Docker PostGIS - Local Development Environment Setup" +echo "==============================================" +echo "" + +# Check if running on Ubuntu/Debian +if ! command -v apt-get &> /dev/null; then + echo "Error: This script is designed for Ubuntu/Debian systems with apt-get package manager." + exit 1 +fi + +# Check if Docker is installed +if ! command -v docker &> /dev/null; then + echo "Error: Docker is not installed." + echo "Please install Docker first from: https://docs.docker.com/engine/install/ubuntu/" + exit 1 +fi + +# Check if running as root (not recommended for development) +if [[ $EUID -eq 0 ]]; then + echo "Warning: Running as root is not recommended for development environment setup." + echo "Consider running this script as a regular user with sudo privileges." + read -p "Continue anyway? (y/N): " -r + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + exit 1 + fi +fi + +echo "Step 1: Updating system packages..." +sudo apt-get update || true + +echo "" +echo "Step 2: Installing system dependencies..." +# Install required system packages (compatible with Ubuntu 20.04-25.04) +sudo apt-get install -y \ + python3 \ + python3-pip \ + python3-venv \ + curl \ + wget \ + jq \ + gawk \ + git \ + make + +echo "" +echo "Step 3: Setting up Python virtual environment..." +# Create virtual environment if it doesn't exist +if [[ ! -d "venv-docker-postgis" ]]; then + python3 -m venv venv-docker-postgis + echo "Created Python virtual environment in ./venv-docker-postgis" +else + echo "Python virtual environment already exists in ./venv-docker-postgis" +fi + +# Activate virtual environment +# shellcheck source=/dev/null +source venv-docker-postgis/bin/activate +echo "Activated Python virtual environment" + +echo "" +echo "Step 4: Installing Python packages..." +# Upgrade pip and install required Python packages +pip3 install --upgrade pip +pip3 install --upgrade lastversion check-jsonschema + +echo "" +echo "Step 5: Installing manifest-tool..." +if ! command -v manifest-tool &> /dev/null; then + ./tools/install_manifest-tool.sh + echo "manifest-tool installed successfully" +else + echo "manifest-tool is already installed" + manifest-tool -v +fi + +echo "" +echo "Step 6: Installing dive tool..." +if [[ ! -f "tools/dive" ]]; then + ./tools/install_dive.sh + echo "dive tool installed successfully" +else + echo "dive tool already exists" + ./tools/dive -v +fi + +echo "" +echo "Step 7: Initializing environment..." +# shellcheck source=/dev/null +source ./tools/environment_init.sh + +echo "" +echo "Step 8: Running version check..." +make check_version + +echo "" +echo "==============================================" +echo "Setup completed successfully!" +echo "==============================================" +echo "" +echo "To use this environment in the future:" +echo " 1. cd $(pwd)" +echo " 2. source venv-docker-postgis/bin/activate" +echo " 3. source ./tools/environment_init.sh" +echo "" +echo "Available commands:" +echo " make build # Build all images" +echo " make test # Test all images" +echo " make lint # Run shellcheck" +echo " ./update.sh # Update all configurations" +echo " ./tools/versions.sh # Check for new versions" +echo "" +echo "For more information, see the Makefile targets:" +echo " make help" +echo "" \ No newline at end of file diff --git a/tools/versions.sh b/tools/versions.sh new file mode 100755 index 000000000..41ca68906 --- /dev/null +++ b/tools/versions.sh @@ -0,0 +1,909 @@ +#!/bin/bash +# shellcheck disable=SC2154 +set -Eeuo pipefail + +# Source environment variables and necessary configurations +source tools/environment_init.sh +source tools/cache_helper.sh +[ -f ./versions.json ] + +# This code derived from: +# - URL: https://github.com/docker-library/postgres/blob/master/versions.sh +# - Copyright: (c) Docker PostgreSQL Authors +# - MIT License, https://github.com/docker-library/postgres/blob/master/LICENSE + +# --debug +# set -xv ; exec 1> >(tee "./update.log") 2>&1 + +# ---------- Setups --------- +api_preference="github" +#api_preference="osgeo" -- not working yet + +alpine_variants=" alpine3.21 alpine3.22 " +debian_variants=" bullseye bookworm " + +debian_latest="bookworm" +alpine_latest="alpine3.22" +postgis_latest="3.5" +postgres_latest="17" +postgis_versions="3.0 3.1 3.2 3.3 3.4 3.5 3.6" +postgres_versions="13 14 15 16 17 18" + +# MASTER_BRANCH_MODE='flexible'=if you want to use the latest version of the dependencies - automatically +# if not set, it will use the locked version, and the checkout hash will be used +MASTER_BRANCH_MODE="flexible" + +POSTGIS_BRANCH="master" +GEOS_BRANCH="main" +GDAL_BRANCH="master" +PROJ_BRANCH="master" +SFCGAL_BRANCH="master" +CGAL_BRANCH="master" + +# locked: extra locking versions for dependencies +CGAL_CHECKOUT_LOCK="" +SFCGAL_CHECKOUT_LOCK="" +GEOS_CHECKOUT_LOCK="" +PROJ_CHECKOUT_LOCK="" +GDAL_CHECKOUT_LOCK="" + +declare -A postgisDebPkgNameVersionSuffixes=( + [3.0]='3' + [3.1]='3' + [3.2]='3' + [3.3]='3' + [3.4]='3' + [3.5]='3' + [3.6]='3' +) + +declare -A boostVersion=( + ["bullseye"]="1.74.0" + ["bookworm"]="1.74.0" # 1.81.0 is not yet optimal. The current bookworm packages mixed use of 1.74.0 and 1.81.0 + ["alpine3.21"]="1.82.0" + ["alpine3.22"]="1.82.0" +) + +# function get_tag_hash() { +# hash_value=$(get_tag_hash "https://github.com/postgis/postgis.git" "3.4.0") +# echo $hash_value +function get_tag_hash() { + local repo="$1" + local version="$2" + + # remove tag/ prefix if exists. + version=${version#tags/} + + # Cache git ls-remote calls (6 hour TTL) + local cache_key + cache_key="git_tag_hash_${repo//[^a-zA-Z0-9]/_}_$version" + if tagResponse=$(cache_get "$cache_key" 6); then + echo "$tagResponse" + else + tagResponse=$(git ls-remote --sort="v:refname" "$repo" refs/tags/"$version"* | + grep -E 'refs/tags/'"$version"'(\^\{\})?$' | + tail -n1 | + awk '{print $1}') + cache_store "$cache_key" "$tagResponse" + echo "$tagResponse" + fi +} + +# extracts a version number and limits it to up to two segments (digits separated by dots). +function extract_version_up_to_two_digits() { + local input_version=$1 + if [[ $input_version =~ ^([0-9]+(\.[0-9]+)?) ]]; then + echo "${BASH_REMATCH[1]}" + else + echo "" + fi +} + +# Convert YAML input to pretty-printed JSON format. +function yaml2json_pretty { + python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read()), indent=2, sort_keys=False))' +} + +# Correct version sorting +function version_reverse_sort() { + # This function sorts version numbers in reverse order, + # ensuring that versions without pre-release tags (e.g., "3.4.0") + # are ranked higher than those with pre-release tags (e.g., "3.4.0rc4"). + # It adds a ".9991" suffix to versions without pre-release tags, + # sorts them with `sort -Vr`, and then removes the ".9991" suffix. + sed -r "s/([0-9]+\.[0-9]+\.[0-9]+$)/\1\.9991/" | sort -Vr | sed s/\.9991$// +} + +# fetch available postgres docker versions from the docker hub +function fetch_postgres_docker_versions() { + + echo " " + echo "Fetching available PostgreSQL Docker image versions from Docker Hub. ( https://registry.hub.docker.com )" + + local PAGE_SIZE=100 + local page=1 + postgres_all_docker_versions="" + while true; do + local response + # Try cache first, then API call + if ! response=$(cached_curl "dockerhub_postgres_page_${page}" "https://registry.hub.docker.com/v2/repositories/library/postgres/tags?page=${page}&page_size=${PAGE_SIZE}" 6); then + echo "Failed to fetch from registry.hub.docker.com" + return 1 + fi + + # Extract tag names from the JSON response + local tags + tags=$(echo "$response" | grep -Po '"name":\s*"\K[^"]+' || true) + local count + count=$(echo "$tags" | sed '/^$/d' | wc -l) + if ((count == 0)); then + break + fi + if ((page > 40)); then + echo "(docker api) Too many pages: ${page} - exiting; unexpected and something is wrong!" + exit 1 + fi + postgres_all_docker_versions+=$'\n'"$tags" + ((page++)) + done +} + +fetch_postgres_docker_versions || { + echo "Error fetching Docker postgres versions! Maybe network or server error!" + exit 1 +} + +# Postgres versions , keep only 1* versions; +postgres_all_docker_versions=$(echo "$postgres_all_docker_versions" | grep '^1' | cut -d'-' -f1 | sort -u | version_reverse_sort) +postgres_all_docker_versions_string=$(echo "$postgres_all_docker_versions" | tr '\n' ' ') +echo "postgres_all_docker_versions_string = ${postgres_all_docker_versions_string}" +echo " " + +declare -A postgresLastTags=() +declare -A postgresLastMainTags=() +for variant in ${postgres_versions}; do + postgresLastTags[$variant]=$(echo "$postgres_all_docker_versions" | grep "^${variant}" | version_reverse_sort | head -n 1 || true) + postgresLastMainTags[$variant]=$(echo "${postgresLastTags[$variant]}" | cut -d'.' -f1) + echo "postgresLastTags[$variant] = ${postgresLastTags[$variant]}" + echo "postgresLastMainTags[$variant] = ${postgresLastMainTags[$variant]}" +done +echo " " + + +packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/' + +# Check if we need to fetch git branch HEADs (check cache first) +need_git_calls=false +for git_check in "git_branch_cgal_5.6.x" "git_branch_sfcgal_master" "git_branch_proj_master" "git_branch_gdal_master" "git_branch_geos_main" "git_branch_postgis_master"; do + if ! cache_get "$git_check" 2 >/dev/null; then + need_git_calls=true + break + fi +done + +# Check GitHub rate limit before git ls-remote calls (if needed) +if [ "$need_git_calls" = true ]; then + if ! check_github_rate_limit 10; then # Need ~6 requests for git ls-remote calls + exit 1 + fi +fi + +# Cache git branch HEAD hashes (2 hour TTL) +if ! cgal5XGitHash=$(cache_get "git_branch_cgal_5.6.x" 2); then + cgal5XGitHash="$(git ls-remote https://github.com/CGAL/cgal.git heads/5.6.x-branch | awk '{ print $1}')" + cache_store "git_branch_cgal_5.6.x" "$cgal5XGitHash" +fi + +if ! sfcgalGitHash=$(cache_get "git_branch_sfcgal_master" 2); then + sfcgalGitHash="$(git ls-remote https://gitlab.com/sfcgal/SFCGAL.git heads/master | awk '{ print $1}')" + cache_store "git_branch_sfcgal_master" "$sfcgalGitHash" +fi + +if ! projGitHash=$(cache_get "git_branch_proj_master" 2); then + projGitHash="$(git ls-remote https://github.com/OSGeo/PROJ.git heads/master | awk '{ print $1}')" + cache_store "git_branch_proj_master" "$projGitHash" +fi + +if ! gdalGitHash=$(cache_get "git_branch_gdal_master" 2); then + gdalGitHash="$(git ls-remote https://github.com/OSGeo/gdal.git refs/heads/master | grep '\srefs/heads/master' | awk '{ print $1}')" + cache_store "git_branch_gdal_master" "$gdalGitHash" +fi + +if ! geosGitHash=$(cache_get "git_branch_geos_main" 2); then + geosGitHash="$(git ls-remote https://github.com/libgeos/geos.git heads/main | awk '{ print $1}')" + cache_store "git_branch_geos_main" "$geosGitHash" +fi + +if ! postgisGitHash=$(cache_get "git_branch_postgis_master" 2); then + postgisGitHash="$(git ls-remote https://github.com/postgis/postgis.git heads/master | awk '{ print $1}')" + cache_store "git_branch_postgis_master" "$postgisGitHash" +fi + +# Function to get the latest version tag and its SHA1 hash (with caching) +get_latest_version_and_hash() { + # Argument 1: Repository URL + local repo_url="$1" + # Argument 2: Repository identifier + local repo_id="$2" + # development version .. witj --pre + local repo_development="${3:-}" + # Argumnet 3: tag filter - optional + local repo_only="${4:-}" + # Argumnet 4: checkout lock + local checkout_lock="${5:-}" + + # remove tag/ prefix if exists. + checkout_lock=${checkout_lock#tags/} + + # Save original repo_only for cache key + local original_repo_only="$repo_only" + + # Create cache key based on all parameters + local cache_key="lastversion_${repo_id}_${repo_development}_${original_repo_only}_${checkout_lock}" + cache_key=${cache_key//[^a-zA-Z0-9]/_} + + echo "[+] Checking lastversion : $repo_id - $repo_url" + + # Try cache first (6 hour TTL) + if cachedResult=$(cache_get "$cache_key" 6); then + echo " Using cached result for $repo_id" + # Parse cached result: version|sha1 + local cached_version + local cached_sha1 + cached_version=$(echo "$cachedResult" | cut -d'|' -f1) + cached_sha1=$(echo "$cachedResult" | cut -d'|' -f2) + + # Set the variables as the original function would (after repo_only processing) + if [[ "$repo_only" == "norepo" ]]; then + repo_only="" + fi + local var_name="lastversion_${repo_id}${repo_only}" + eval "${var_name}=${cached_version}" + eval "${var_name}_sha1=${cached_sha1}" + + echo " lastversion_${repo_id}${repo_only} = ${cached_version}" + echo " lastversion_${repo_id}${repo_only}_sha1 = ${cached_sha1}" + echo " " + return 0 + fi + + # Cache miss - fetch from API + # Fetch the latest version tag using the lastversion command + + if [[ "${repo_development}" == "pre-releases" ]]; then + repo_development="--pre" + else + repo_development="" + fi + + if [[ "${repo_only}" == "norepo" ]]; then + repo_only="" + fi + + if [ -z "$checkout_lock" ]; then + if [ -z "$repo_only" ]; then + eval "lastversion_${repo_id}=$(lastversion ${repo_development} --format tag "${repo_url}")" + else + eval "lastversion_${repo_id}${repo_only}=$(lastversion ${repo_development} --format tag --only "${repo_only}" "${repo_url}")" + fi + else + echo " !Locked to ${checkout_lock}" + if [ -z "$repo_only" ]; then + eval "lastversion_${repo_id}=${checkout_lock}" + else + eval "lastversion_${repo_id}${repo_only}=${checkout_lock}" + fi + fi + + # Intermediary step to resolve the variable name + local var_name="lastversion_${repo_id}${repo_only}" + local last_version=${!var_name} + + # Fetch the SHA1 hash of the tag using the get_tag_hash function + eval "lastversion_${repo_id}${repo_only}_sha1=$(get_tag_hash "${repo_url}" "${last_version}")" + + #creating new variables for using later .. + echo " lastversion_${repo_id}${repo_only} = ${last_version}" + + local sha1_var_name="lastversion_${repo_id}${repo_only}_sha1" + local sha1_value=${!sha1_var_name} + echo " lastversion_${repo_id}${repo_only}_sha1 = ${sha1_value}" + echo " " + + # Store result in cache: version|sha1 + cache_store "$cache_key" "${last_version}|${sha1_value}" + + if [ -z "$last_version" ]; then + echo "[-] Error: could not get the latest version tag! Stopping!" + exit 1 + fi + + if [ -z "$sha1_value" ]; then + echo "[-] Error: could not get the SHA1 hash for the latest version tag! Stopping!" + exit 1 + fi +} + +# Function to get version and hash with optional failure for missing releases +get_latest_version_and_hash_optional() { + local repo_url="$1" + local repo_id="$2" + local repo_development="${3:-}" + local repo_only="${4:-}" + local checkout_lock="${5:-}" + + echo "[+] Checking lastversion (optional): $repo_id - $repo_url" + + # Try to get the version, but don't exit on failure + if [ -z "$repo_only" ]; then + local version_result + version_result=$(lastversion "${repo_development}" --format tag "${repo_url}" 2>/dev/null || echo "") + eval "lastversion_${repo_id}=${version_result}" + else + local version_result + version_result=$(lastversion "${repo_development}" --format tag --only "${repo_only}" "${repo_url}" 2>/dev/null || echo "") + eval "lastversion_${repo_id}${repo_only}=${version_result}" + fi + + local var_name="lastversion_${repo_id}${repo_only}" + local last_version=${!var_name} + + if [ -n "$last_version" ]; then + # Only get SHA1 if we have a version + eval "lastversion_${repo_id}${repo_only}_sha1=$(get_tag_hash "${repo_url}" "${last_version}" 2>/dev/null || echo "")" + local sha1_var_name="lastversion_${repo_id}${repo_only}_sha1" + local sha1_value=${!sha1_var_name} + echo " lastversion_${repo_id}${repo_only} = ${last_version}" + echo " lastversion_${repo_id}${repo_only}_sha1 = ${sha1_value}" + else + # Set empty values for missing releases + eval "lastversion_${repo_id}${repo_only}=" + eval "lastversion_${repo_id}${repo_only}_sha1=" + echo " lastversion_${repo_id}${repo_only} = (not found - optional)" + echo " lastversion_${repo_id}${repo_only}_sha1 = (not found - optional)" + fi + echo " " +} + +# Check GitHub rate limit before making multiple lastversion calls +if ! check_github_rate_limit 10; then # Reduced from 25 - most calls are now cached + exit 1 +fi + +get_latest_version_and_hash "https://github.com/pramsey/pgsql-http" "pgsql_http" releases norepo "" +get_latest_version_and_hash "https://github.com/pramsey/pgsql-gzip" "pgsql_gzip" releases norepo "" +get_latest_version_and_hash "https://github.com/duckdb/duckdb" "duckdb" releases norepo "" + +get_latest_version_and_hash "https://github.com/postgis/postgis" "postgis" releases norepo "" +get_latest_version_and_hash "https://github.com/CGAL/cgal" "cgal" releases norepo "${CGAL_CHECKOUT_LOCK}" +get_latest_version_and_hash "https://github.com/libgeos/geos" "geos" releases norepo "${GEOS_CHECKOUT_LOCK}" +get_latest_version_and_hash "https://github.com/OSGeo/gdal" "gdal" releases norepo "${GDAL_CHECKOUT_LOCK}" +get_latest_version_and_hash "https://github.com/OSGeo/PROJ" "proj" releases norepo "${PROJ_CHECKOUT_LOCK}" +get_latest_version_and_hash "https://gitlab.com/sfcgal/SFCGAL" "sfcgal" releases norepo "${SFCGAL_CHECKOUT_LOCK}" + +get_latest_version_and_hash_optional "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL18 "" +get_latest_version_and_hash_optional "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL20 "" +get_latest_version_and_hash_optional "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL19 "" +get_latest_version_and_hash_optional "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL17 "" +get_latest_version_and_hash "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL17 "" +get_latest_version_and_hash "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL16 "" +get_latest_version_and_hash "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL15 "" +get_latest_version_and_hash "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL14 "" +get_latest_version_and_hash "https://github.com/ossc-db/pg_hint_plan" "pg_hint_plan" releases REL13 "" + +#------------------------------------------- + +function fetch_postgis_versions() { + # get all postgis versions from github + local REPO="postgis/postgis" + local PER_PAGE=100 # You can ask for up to 100 results per page + local page=1 + postgis_all_v3_versions="" + + while true; do + local response + if [ "$api_preference" == "github" ]; then + # Try cache first, then API call + if ! response=$(cached_curl "github_postgis_tags_page_${page}" "https://api.github.com/repos/$REPO/tags?per_page=$PER_PAGE&page=$page" 6); then + echo "Failed to fetch postgis_versions from api.github.com/repos/$REPO/tags" + return 1 + fi + elif [ "$api_preference" == "osgeo" ]; then + response=$(curl --silent "https://git.osgeo.org/gitea/api/v1/repos/${REPO}/tags?page=$page&limit=$PER_PAGE") || { + echo "Failed to fetch postgis_versions from git.osgeo.org/gitea/api/v1/repos/${REPO}/tags" + return 1 + } + fi + + # Check for rate limit exceeded error - related to api.github.com + if echo "$response" | grep -q "API rate limit exceeded"; then + echo "Error: API rate limit exceeded!" + echo "$response" + exit 1 + fi + + # Extract tag names from the JSON response + local tags + tags=$(echo "$response" | grep -Po '"name":\s*"\K[^"]+' || true) + local count + count=$(echo "$tags" | sed '/^$/d' | wc -l) + + if ((count == 0)); then + break + fi + + if ((page > 12)); then + echo "Too many pages: ${page} - exiting; unexpected and something is wrong!" + exit 1 + fi + + postgis_all_v3_versions+=" $tags" + + ((page++)) + done +} + +# Check GitHub rate limit before fetching PostGIS versions +if [ "$api_preference" == "github" ]; then + if ! check_github_rate_limit 8; then # Reduced from 15 - PostGIS pages are cached + exit 1 + fi +fi + +fetch_postgis_versions || { + echo "Error fetching postgis versions! Maybe network or server error!" + exit 1 +} + +# Keep 3.* versions only +postgis_all_v3_versions=$(echo "$postgis_all_v3_versions" | sed '/^$/d' | grep '^3\.' | version_reverse_sort) +postgis_all_v3_versions_array_string=$(echo "$postgis_all_v3_versions" | tr '\n' ' ') +echo "postgis_all_v3_versions_array_string = ${postgis_all_v3_versions_array_string}" +echo " " + +declare -A postgisLastTags=() +declare -A postgisLastDockerTags=() +declare -A postgisSrcSha256=() +declare -A postgisSrcSha1=() +for variant in ${postgis_versions}; do + _postgisMinor=$(echo "$variant" | cut -d. -f2) + + # check the latest released 3.x version (so not alpha/beta/rc) + postgisLastTags[$variant]=$(echo "$postgis_all_v3_versions" | grep "^3\.${_postgisMinor}\." | grep -v '[a-zA-Z]' | version_reverse_sort | head -n 1 || true) + # Check if the result is empty + if [[ -z "${postgisLastTags[$variant]}" ]]; then + # If empty, run the command again without excluding pre-releases (alpha/beta/rc) + postgisLastTags[$variant]=$(echo "$postgis_all_v3_versions" | grep "^3\.${_postgisMinor}\." | version_reverse_sort | head -n 1 || true) + fi + + if [[ ${postgisLastTags[$variant]} =~ [a-zA-Z] ]]; then + postgisLastDockerTags[$variant]=${postgisLastTags[$variant]} + else + postgisLastDockerTags[$variant]=$(echo "${postgisLastTags[$variant]}" | cut -d'.' -f1,2) + fi + echo "postgisLastDockerTags[$variant] = ${postgisLastDockerTags[$variant]}" + echo "postgisLastTags[$variant] = ${postgisLastTags[$variant]}" + + if [ "${postgisLastTags[$variant]}" == "" ]; then + postgisSrcSha256[$variant]="" + postgisSrcSha1[$variant]="" + else + if [ "$api_preference" == "github" ]; then + # Cache PostGIS SHA256 hash (cache the computed hash, not the binary file) + cache_key="postgis_sha256_${postgisLastTags[$variant]}" + if cached_sha256=$(cache_get "$cache_key" 168); then # 7 days TTL for SHA256 hashes + postgisSrcSha256[$variant]="$cached_sha256" + echo "# PostGIS SHA256 cache hit: ${postgisLastTags[$variant]} = $cached_sha256" + else + echo "# Computing PostGIS SHA256 for ${postgisLastTags[$variant]}..." + postgisSrcSha256[$variant]="$(curl -sSL "https://github.com/postgis/postgis/archive/${postgisLastTags[$variant]}.tar.gz" | sha256sum | awk '{ print $1 }')" + cache_store "$cache_key" "${postgisSrcSha256[$variant]}" + echo "# PostGIS SHA256 computed and cached: ${postgisLastTags[$variant]} = ${postgisSrcSha256[$variant]}" + fi + postgisSrcSha1[$variant]=$(get_tag_hash https://github.com/postgis/postgis.git "${postgisLastTags[$variant]}") + elif [ "$api_preference" == "osgeo" ]; then + postgisSrcSha256[$variant]="$(curl -sSL "https://git.osgeo.org/gitea/postgis/postgis/archive/${postgisLastTags[$variant]}.tar.gz" | sha256sum | awk '{ print $1 }')" + fi + fi + echo "postgisSrcSha256[$variant]=${postgisSrcSha256[$variant]}" + echo "postgisSrcSha1[$variant]=${postgisSrcSha1[$variant]}" +done + +#cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" +versions=("$@") +if [ ${#versions[@]} -eq 0 ]; then + versions=() + for variant in $alpine_variants $debian_variants; do + for path in */"${variant}"/Dockerfile; do + if [[ -f $path ]]; then + versions+=("$path") + fi + done + done + mapfile -t versions < <(printf '%s\n' "${versions[@]}" | cut -d'/' -f1 | sort -u -V) +fi + +echo " " +echo "versions= ${versions[*]}" + +declare -A suitePackageList=() +declare -A suiteArches=() +declare -A fullVersion=() +declare -A debianPostgisMajMin=() +declare -A postgisMajMin=() +declare -A postgisPackageName=() +declare -A postgisFullVersion=() +declare -A postgisMajor=() +declare -A postgisDocSrc=() + +rm -f _versions.yml + +for version in "${versions[@]}"; do + IFS=- read -r postgresVersion postgisVersion bundleType <<<"$version" + + echo " " + echo "---- generate metadata for $version ----" + echo "postgresVersion=$postgresVersion" + echo "postgisVersion=$postgisVersion" + echo "bundleType=$bundleType" + if [ -z "$bundleType" ]; then + echo " ---> bundleType is empty" + else + echo " ---> bundleType is $bundleType" + fi + echo " " + + # if the first letter of "postgisVersion" is "l" then + # the version is locked and we use the definition from locked.yml + if [[ "${postgisVersion:0:1}" == "l" ]]; then + echo " ---> locked ; definition from locked.yml !" + continue + fi + + if [[ "master" == "$postgisVersion" || "recent" == "$postgisVersion" ]]; then + srcVersion="" + srcSha256="" + srcSha1="" + else + if [[ -v "postgisLastTags[${postgisVersion}]" ]]; then + echo ":: postgisLastTags[${postgisVersion}] exists in the array." + srcVersion="${postgisLastTags[${postgisVersion}]}" + srcSha256="${postgisSrcSha256[${postgisVersion}]}" + srcSha1="${postgisSrcSha1[${postgisVersion}]}" + elif [[ " $postgis_all_v3_versions_array_string " == *" $postgisVersion "* ]]; then + echo "!!!! ${postgisVersion} exists in postgis_all_v3_versions_array_string." + srcVersion=${postgisVersion} + srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/${postgisVersion}.tar.gz" | sha256sum | awk '{ print $1 }')" + srcSha1=$(git ls-remote https://github.com/postgis/postgis.git refs/tags/"${postgisVersion}" | awk '{print $1}') + #srcSha256="$(curl -sSL "https://git.osgeo.org/gitea/postgis/postgis/archive/${postgisVersion}.tar.gz" | sha256sum | awk '{ print $1 }')" + else + echo "Unknown $postgisVersion version, please check the postgis_all_v3_versions array!" + exit 1 + fi + fi + echo srcVersion="$srcVersion" + echo srcSha256="$srcSha256" + echo srcSha1="$srcSha1" + + # Check current status of postgis debian packages + for suite in $debian_variants; do + if [ -z "${suitePackageList["$suite"]:+isset}" ]; then + suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)" + fi + if [ -z "${suiteArches["$suite"]:+isset}" ]; then + suiteArches["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/Release" | awk -F ':[[:space:]]+' '$1 == "Architectures" { gsub(/[[:space:]]+/, "|", $2); print $2 }')" + echo "suiteArches[$suite] = ${suiteArches[$suite]}" + fi + + postgresVersionMain="$(echo "$postgresVersion" | awk -F 'alpha|beta|rc' '{print $1}')" + versionList="$( + echo "${suitePackageList["$suite"]}" + curl -fsSL "${packagesBase}/${suite}-pgdg/${postgresVersionMain}/binary-amd64/Packages.bz2" | bunzip2 + )" + fullVersion["$suite"]="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersionMain"'" { print $2; exit }' || true)" + echo "fullVersion[$suite] = ${fullVersion[$suite]}" + + debianPostgisMajMin["$suite"]="" + if [ "master" == "$postgisVersion" ]; then + debianPostgisMajMin["$suite"]="" + postgisPackageName["$suite"]="" + postgisFullVersion["$suite"]="$postgisVersion" + postgisMajor["$suite"]="" + postgisDocSrc["$suite"]="development: postgis, geos, proj, gdal" + elif [ "recent" == "$postgisVersion" ]; then + #TODO + debianPostgisMajMin["$suite"]="" + postgisPackageName["$suite"]="" + postgisFullVersion["$suite"]="$postgisVersion" + postgisMajor["$suite"]="" + postgisDocSrc["$suite"]="... recent ... " + else + postgisMajMin["$suite"]="$(echo "${postgisVersion}" | cut -d. -f1).$(echo "${postgisVersion}" | cut -d. -f2)" + echo "postgisMajMin[$suite]= ${postgisMajMin[${suite}]}" + + postgisPackageName["$suite"]="postgresql-${postgresVersionMain}-postgis-${postgisDebPkgNameVersionSuffixes[${postgisMajMin[${suite}]}]}" + postgisFullVersion["$suite"]="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"${postgisPackageName[${suite}]}"'" { print $2; exit }' || true)" + echo "postgisPackageName[$suite]= ${postgisPackageName[$suite]}" + echo "postgisFullVersion[$suite]= ${postgisFullVersion[$suite]}" + + debianPostgisMajMin["$suite"]="$(echo "${postgisFullVersion["$suite"]}" | cut -d. -f1).$(echo "${postgisFullVersion["$suite"]}" | cut -d. -f2)" + + if [ "${debianPostgisMajMin[${suite}]}" == "${postgisMajMin[${suite}]}" ]; then + echo "debian[$suite] : postgis version is OK !" + postgisMajor["$suite"]="${postgisDebPkgNameVersionSuffixes[${postgisMajMin[${suite}]}]}" + postgisDocSrc["$suite"]="${postgisFullVersion[${suite}]%%+*}" + else + echo "debian[$suite] : postgis is not updated, different ! " + postgisFullVersion["$suite"]="" + postgisMajor["$suite"]="" + postgisDocSrc["$suite"]="" + fi + fi + done + + printf "'%s':\n" "$version" >>_versions.yml + #generate debian versions + for variant in $debian_variants; do + if [ -d "$version/$variant" ] && [[ "${postgisDocSrc[$variant]}" == "" ]]; then + ( + echo " " + echo "$version/$variant - debian[$variant] : postgis is not updated/exists - skip and clean the directory! " + # remove all files in the directory ! + rm -rf "${version:?}/${variant:?}/*" + ) + elif [ -d "$version/$variant" ]; then + ( + echo " " + echo "---- $version/$variant --- " + + if [[ "master" == "$postgisVersion" ]]; then + postgisDockerTag="master" + elif [[ "recent" == "$postgisVersion" ]]; then + postgisDockerTag="recent" + else + postgisDockerTag="${postgisLastDockerTags[$postgisVersion]}" + fi + + bundleTypeTags="" + mainTags="${postgresLastMainTags[$postgresVersion]}-${postgisDockerTag}" + if [ -n "$bundleType" ]; then + readme_group="$bundleType" + bundleTypeTags="-${bundleType}" + elif [[ ${postgresLastMainTags[$postgresVersion]} =~ ^[0-9]+$ ]] && [[ "$postgisVersion" == "recent" ]]; then + readme_group="recent" + elif [[ ${mainTags} =~ [a-zA-Z] ]]; then + readme_group="test" + else + readme_group=$variant + fi + + tags="${mainTags}${bundleTypeTags}-${variant}" + if [[ "recent" == "$postgisVersion" ]]; then + lastversion_postgis_tag=${lastversion_postgis#tags/} + lastversion_postgis_tag=${lastversion_postgis_tag#v} + lastversion_proj_tag=${lastversion_proj#tags/} + lastversion_proj_tag=${lastversion_proj_tag#v} + lastversion_geos_tag=${lastversion_geos#tags/} + lastversion_geos_tag=${lastversion_geos_tag#v} + lastversion_gdal_tag=${lastversion_gdal#tags/} + lastversion_gdal_tag=${lastversion_gdal_tag#v} + lastversion_cgal_tag=${lastversion_cgal#tags/} + lastversion_cgal_tag=${lastversion_cgal_tag#v} + lastversion_sfcgal_tag=${lastversion_sfcgal#tags/} + lastversion_sfcgal_tag=${lastversion_sfcgal_tag#v} + + tags+=" ${mainTags}-postgis${lastversion_postgis_tag}-geos${lastversion_geos_tag}-proj${lastversion_proj_tag}-gdal${lastversion_gdal_tag}-cgal${lastversion_cgal_tag}-sfcgal${lastversion_sfcgal_tag}-${variant}" + + lastversion_postgis_tag2d=$(extract_version_up_to_two_digits "$lastversion_postgis_tag") + lastversion_proj_tag2d=$(extract_version_up_to_two_digits "$lastversion_proj_tag") + lastversion_geos_tag2d=$(extract_version_up_to_two_digits "$lastversion_geos_tag") + lastversion_gdal_tag2d=$(extract_version_up_to_two_digits "$lastversion_gdal_tag") + lastversion_cgal_tag2d=$(extract_version_up_to_two_digits "$lastversion_cgal_tag") + lastversion_sfcgal_tag2d=$(extract_version_up_to_two_digits "$lastversion_sfcgal_tag") + + tags+=" ${mainTags}-postgis${lastversion_postgis_tag2d}-geos${lastversion_geos_tag2d}-proj${lastversion_proj_tag2d}-gdal${lastversion_gdal_tag2d}-cgal${lastversion_cgal_tag2d}-sfcgal${lastversion_sfcgal_tag2d}-${variant}" + fi + + if [[ "master" != "$postgisVersion" && "recent" != "$postgisVersion" && "${postgisDocSrc[$variant]}" != "${postgisDockerTag}" ]]; then + tags+=" ${postgresLastMainTags[$postgresVersion]}-${postgisDocSrc[$variant]}${bundleTypeTags}-${variant}" + fi + if [[ "$variant" == "$debian_latest" ]]; then + tags+=" ${postgresLastMainTags[$postgresVersion]}-${postgisDockerTag}${bundleTypeTags}" + if [[ "${postgis_latest}" == "${postgisDockerTag}" && "${postgres_latest}" == "${postgresLastMainTags[$postgresVersion]}" ]]; then + if [ -n "$bundleType" ]; then + tags+=" $bundleType" + else + tags+=" latest" + fi + elif [[ "recent" == "${postgisDockerTag}" && "${postgres_latest}" == "${postgresLastMainTags[$postgresVersion]}" ]]; then + tags+=" recent" + fi + fi + + { + printf " '%s':\n" "$variant" + printf " tags: '%s'\n" "$tags" + printf " postgis: '%s'\n" "${postgisDockerTag}" + printf " readme_group: '%s'\n" "$readme_group" + printf " PG_MAJOR: '%s'\n" "$postgresVersion" + printf " PG_DOCKER: '%s'\n" "${postgresLastMainTags[$postgresVersion]}" + } >>_versions.yml + + if [[ "master" == "$postgisVersion" ]]; then + { + printf " arch: '%s'\n" "amd64 arm64" + printf " template: '%s'\n" "Dockerfile.master.template" + printf " initfile: '%s'\n" "initdb-postgis.sh" + + if [[ "$MASTER_BRANCH_MODE" == "flexible" ]]; then + printf " POSTGIS_CHECKOUT: '%s'\n" "$POSTGIS_BRANCH" + printf " POSTGIS_CHECKOUT_SHA1: 'nocheck'\n" + printf " CGAL_CHECKOUT: '%s'\n" "$CGAL_BRANCH" + printf " CGAL_CHECKOUT_SHA1: 'nocheck'\n" + printf " SFCGAL_CHECKOUT: '%s'\n" "$SFCGAL_BRANCH" + printf " SFCGAL_CHECKOUT_SHA1: 'nocheck'\n" + printf " PROJ_CHECKOUT: '%s'\n" "$PROJ_BRANCH" + printf " PROJ_CHECKOUT_SHA1: 'nocheck'\n" + printf " GDAL_BUILD: '%s'\n" "with_extra" + printf " GDAL_CHECKOUT: '%s'\n" "$GDAL_BRANCH" + printf " GDAL_CHECKOUT_SHA1: 'nocheck'\n" + printf " GEOS_CHECKOUT: '%s'\n" "$GEOS_BRANCH" + printf " GEOS_CHECKOUT_SHA1: 'nocheck'\n" + else + printf " POSTGIS_CHECKOUT: '%s'\n" "$postgisGitHash" + printf " POSTGIS_CHECKOUT_SHA1: '%s'\n" "$postgisGitHash" + printf " CGAL_CHECKOUT: '%s'\n" "$cgal5XGitHash" + printf " CGAL_CHECKOUT_SHA1: '%s'\n" "$cgal5XGitHash" + printf " SFCGAL_CHECKOUT: '%s'\n" "$sfcgalGitHash" + printf " SFCGAL_CHECKOUT_SHA1: '%s'\n" "$sfcgalGitHash" + printf " PROJ_CHECKOUT: '%s'\n" "$projGitHash" + printf " PROJ_CHECKOUT_SHA1: '%s'\n" "$projGitHash" + printf " GDAL_BUILD: '%s'\n" "with_extra" + printf " GDAL_CHECKOUT: '%s'\n" "$gdalGitHash" + printf " GDAL_CHECKOUT_SHA1: '%s'\n" "$gdalGitHash" + printf " GEOS_CHECKOUT: '%s'\n" "$geosGitHash" + printf " GEOS_CHECKOUT_SHA1: '%s'\n" "$geosGitHash" + fi + + printf " BOOST_VERSION: '%s'\n" "${boostVersion[$variant]}" + } >>_versions.yml + + elif [[ "recent" == "$postgisVersion" ]]; then + { + printf " arch: '%s'\n" "amd64 arm64" + printf " template: '%s'\n" "Dockerfile.master.template" + printf " initfile: '%s'\n" "initdb-postgis.sh" + + printf " POSTGIS_CHECKOUT: 'tags/%s'\n" "$lastversion_postgis" + printf " POSTGIS_CHECKOUT_SHA1: '%s'\n" "$lastversion_postgis_sha1" + printf " PROJ_CHECKOUT: 'tags/%s'\n" "$lastversion_proj" + printf " PROJ_CHECKOUT_SHA1: '%s'\n" "$lastversion_proj_sha1" + printf " GDAL_BUILD: '%s'\n" "with_extra" + printf " GDAL_CHECKOUT: 'tags/%s'\n" "$lastversion_gdal" + printf " GDAL_CHECKOUT_SHA1: '%s'\n" "$lastversion_gdal_sha1" + printf " GEOS_CHECKOUT: 'tags/%s'\n" "$lastversion_geos" + printf " GEOS_CHECKOUT_SHA1: '%s'\n" "$lastversion_geos_sha1" + printf " SFCGAL_CHECKOUT: 'tags/%s'\n" "$lastversion_sfcgal" + printf " SFCGAL_CHECKOUT_SHA1: '%s'\n" "$lastversion_sfcgal_sha1" + printf " CGAL_CHECKOUT: 'tags/%s'\n" "$lastversion_cgal" + printf " CGAL_CHECKOUT_SHA1: '%s'\n" "$lastversion_cgal_sha1" + + printf " BOOST_VERSION: '%s'\n" "${boostVersion[$variant]}" + } >>_versions.yml + + else + { + if [[ "$variant" == "$debian_latest" ]]; then + # generating amd64 and arm64 only for latest debian + printf " arch: '%s'\n" "amd64 arm64" + else + printf " arch: '%s'\n" "amd64 arm64" + fi + + if [ -z "$bundleType" ]; then + printf " template: '%s'\n" "Dockerfile.debian.template" + printf " initfile: '%s'\n" "initdb-postgis.sh" + else + printf " template: '%s'\n" "Dockerfile.${bundleType}.template" + printf " initfile: '%s'\n" "initdb-${bundleType}.sh" + + printf " PGSQL_HTTP_CHECKOUT: 'tags/%s'\n" "$lastversion_pgsql_http" + printf " PGSQL_HTTP_CHECKOUT_SHA1: '%s'\n" "$lastversion_pgsql_http_sha1" + + printf " PGSQL_GZIP_CHECKOUT: 'tags/%s'\n" "$lastversion_pgsql_gzip" + printf " PGSQL_GZIP_CHECKOUT_SHA1: '%s'\n" "$lastversion_pgsql_gzip_sha1" + + printf " DUCKDB_CHECKOUT: 'tags/%s'\n" "$lastversion_duckdb" + printf " DUCKDB_CHECKOUT_SHA1: '%s'\n" "$lastversion_duckdb_sha1" + + lastversion_pg_hint_plan="lastversion_pg_hint_planREL${postgresVersion}" + lastversion_pg_hint_plan_sha1="lastversion_pg_hint_planREL${postgresVersion}_sha1" + # Only add pg_hint_plan if version exists (for beta PostgreSQL versions) + if [ -n "${!lastversion_pg_hint_plan}" ]; then + printf " PG_HINT_PLAN_CHECKOUT: 'tags/%s'\n" "${!lastversion_pg_hint_plan}" + printf " PG_HINT_PLAN_CHECKOUT_SHA1: '%s'\n" "${!lastversion_pg_hint_plan_sha1}" + fi + + fi + + printf " POSTGIS_MAJOR: '%s'\n" "${postgisMajor[$variant]}" + printf " POSTGIS_VERSION: '%s'\n" "${postgisFullVersion[$variant]}" + } >>_versions.yml + fi + ) + fi + done + + # generate alpine versions + for variant in $alpine_variants; do + if [ -d "$version/$variant" ] && [[ "master" == "$postgisVersion" ]]; then + ( + echo " " + echo "$version/$variant - debian[$variant] : master is allowed only for $debian_latest ; Skip and clean the directory! " + # remove all files in the directory ! + rm -rf "${version:?}/${variant:?}/*" + ) + elif [ -d "$version/$variant" ]; then + ( + if [[ "master" == "$postgisVersion" || "$postgisVersion" == "recent" ]]; then + echo "Alpine - $postgisVersion is not supported! STOP!" + exit 1 + fi + + postgisDockerTag="${postgisLastDockerTags[$postgisVersion]}" + + echo "postgresVersion=${postgresVersion}" + mainTags="${postgresLastMainTags[$postgresVersion]}-${postgisLastDockerTags[$postgisVersion]}" + if [[ ${mainTags} =~ [a-zA-Z] ]]; then + readme_group="test" + else + readme_group=$variant + fi + tags="${mainTags}-${variant}" + + if [[ "master" != "$postgisVersion" && "$postgisVersion" != "recent" && "$srcVersion" != "${postgisLastDockerTags[$postgisVersion]}" ]]; then + tags+=" ${postgresLastMainTags[$postgresVersion]}-${srcVersion}-${variant}" + fi + if [[ "$variant" == "$alpine_latest" ]]; then + tags+=" ${postgresLastMainTags[$postgresVersion]}-${postgisLastDockerTags[$postgisVersion]}-alpine" + if [[ "${postgis_latest}" == "${postgisLastDockerTags[$postgisVersion]}" && "${postgres_latest}" == "${postgresLastMainTags[$postgresVersion]}" ]]; then + tags+=" alpine" + fi + fi + + { + printf " '%s':\n" "$variant" + printf " tags: '%s'\n" "$tags" + printf " readme_group: '%s'\n" "$readme_group" + printf " postgis: '%s'\n" "${postgisDockerTag}" + printf " arch: '%s'\n" "amd64 arm64" + printf " template: '%s'\n" "Dockerfile.alpine.template" + printf " initfile: '%s'\n" "initdb-postgis.sh" + printf " PG_MAJOR: '%s'\n" "$postgresVersion" + printf " PG_DOCKER: '%s'\n" "${postgresLastMainTags[$postgresVersion]}" + printf " POSTGIS_VERSION: '%s'\n" "$srcVersion" + printf " POSTGIS_SHA256: '%s'\n" "$srcSha256" + printf " POSTGIS_CHECKOUT: 'tags/%s'\n" "$srcVersion" + printf " POSTGIS_CHECKOUT_SHA1: '%s'\n" "$srcSha1" + } >>_versions.yml + + ) + fi + done +done + +# add locked configurations to _versions.yml file +cat locked.yml >>_versions.yml + +# convert yaml to json +yaml2json_pretty <./_versions.yml >./_versions.json + +# Remove any keys with null values from the JSON file. +# This is necessary when there are no variants for a specific version, resulting in a null key. +# Example: When the Debian PostGIS version is updated, and the this repo is not yet updated. +jq 'del(.[] | select(. == null))' ./_versions.json >./versions.json + +rm -f _versions.yml +rm -f _versions.json + +cat versions.json diff --git a/update.sh b/update.sh index d7f8f48ee..38c4a7e06 100755 --- a/update.sh +++ b/update.sh @@ -1,199 +1,29 @@ -#!/bin/bash -# Derived from https://github.com/docker-library/postgres/blob/master/update.sh +#!/usr/bin/env bash set -Eeuo pipefail +# Source environment variables and necessary configurations +source tools/environment_init.sh +[ -f ./versions.json ] -cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" +# This code derived from: +# - URL: https://github.com/docker-library/postgres/blob/master/versions.sh +# - Copyright: (c) Docker PostgreSQL Authors +# - MIT License, https://github.com/docker-library/postgres/blob/master/LICENSE -versions=( "$@" ) -if [ ${#versions[@]} -eq 0 ]; then - versions=( */Dockerfile ) -fi -versions=( "${versions[@]%/Dockerfile}" ) +cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" -for optimized in debian alpine test; do - rm -f _dockerlists_${optimized}.md - echo " " > _dockerlists_${optimized}.md - echo "| DockerHub image | Dockerfile | OS | Postgres | PostGIS |" >> _dockerlists_${optimized}.md - echo "| --------------- | ---------- | -- | -------- | ------- |" >> _dockerlists_${optimized}.md -done - -autogenerated='NOTE: THIS DOCKERFILE IS GENERATED VIA "make update"! PLEASE DO NOT EDIT IT DIRECTLY.' - -dockerhublink="https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&name=" -githubrepolink="https://github.com/postgis/docker-postgis/blob/master" - -# sort version numbers with highest last (so it goes first in .travis.yml) -IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -V) ); unset IFS - -defaultAlpinenSuite='3.18' -defaultDebianSuite='bullseye-slim' -declare -A debianSuite=( - # https://github.com/docker-library/postgres/issues/582 - [11]='bullseye-slim' - [12]='bullseye-slim' - [13]='bullseye-slim' - [14]='bullseye-slim' - [15]='bullseye-slim' - [16]='bullseye-slim' -) - -defaultPostgisDebPkgNameVersionSuffix='3' -declare -A postgisDebPkgNameVersionSuffixes=( - [3.0]='3' - [3.1]='3' - [3.2]='3' - [3.3]='3' - [3.4]='3' -) - -packagesBase='http://apt.postgresql.org/pub/repos/apt/dists/' - -cgal5XGitHash="$(git ls-remote https://github.com/CGAL/cgal.git heads/5.6.x-branch | awk '{ print $1}')" -sfcgalGitHash="$(git ls-remote https://gitlab.com/Oslandia/SFCGAL.git heads/master | awk '{ print $1}')" -projGitHash="$(git ls-remote https://github.com/OSGeo/PROJ.git heads/master | awk '{ print $1}')" -gdalGitHash="$(git ls-remote https://github.com/OSGeo/gdal.git refs/heads/master | grep '\srefs/heads/master' | awk '{ print $1}')" -geosGitHash="$(git ls-remote https://github.com/libgeos/geos.git heads/main | awk '{ print $1}')" -postgisGitHash="$(git ls-remote https://github.com/postgis/postgis.git heads/master | awk '{ print $1}')" - -declare -A suitePackageList=() suiteArches=() -for version in "${versions[@]}"; do - IFS=- read postgresVersion postgisVersion <<< "$version" - - echo " " - echo "---- generate Dockerfile for $version ----" - echo "postgresVersion=$postgresVersion" - echo "postgisVersion=$postgisVersion" - - if [ "2.5" == "$postgisVersion" ]; then - # posgis 2.5 only in the stretch ; no bullseye version - tag='stretch-slim' - else - tag="${debianSuite[$postgresVersion]:-$defaultDebianSuite}" - fi - suite="${tag%%-slim}" - - if [ -z "${suitePackageList["$suite"]:+isset}" ]; then - suitePackageList["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/main/binary-amd64/Packages.bz2" | bunzip2)" - fi - if [ -z "${suiteArches["$suite"]:+isset}" ]; then - suiteArches["$suite"]="$(curl -fsSL "${packagesBase}/${suite}-pgdg/Release" | awk -F ':[[:space:]]+' '$1 == "Architectures" { gsub(/[[:space:]]+/, "|", $2); print $2 }')" - fi - - postgresVersionMain="$(echo "$postgresVersion" | awk -F 'alpha|beta|rc' '{print $1}')" - versionList="$(echo "${suitePackageList["$suite"]}"; curl -fsSL "${packagesBase}/${suite}-pgdg/${postgresVersionMain}/binary-amd64/Packages.bz2" | bunzip2)" - fullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "postgresql-'"$postgresVersionMain"'" { print $2; exit }' || true)" - - if [ "$suite" = "bullseye" ]; then - boostVersion="1.74.0" - else - echo "Unknown debian version; stop" - exit 1 - fi - - - optimized="" - if [[ "$version" =~ "alpha" || "$version" =~ "beta" || "$version" =~ "rc" || "$version" =~ "master" ]]; - then - optimized="test" - else - optimized="debian" - fi - echo "optimized=$optimized" - - debianPostgisMajMin="" - if [ "master" == "$postgisVersion" ]; then - postgisPackageName="" - postgisFullVersion="$postgisVersion" - postgisMajor="" - postgisDocSrc="development: postgis, geos, proj, gdal" - else - postgisMajMin="$( echo "${postgisVersion}" | cut -d. -f1 ).$( echo "${postgisVersion}" | cut -d. -f2 )" - echo "postgisMajMin=${postgisMajMin}" - - postgisPackageName="postgresql-${postgresVersionMain}-postgis-${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}" - postgisFullVersion="$(echo "$versionList" | awk -F ': ' '$1 == "Package" { pkg = $2 } $1 == "Version" && pkg == "'"$postgisPackageName"'" { print $2; exit }' || true)" - echo "postgisPackageName=${postgisPackageName}" - echo "postgisFullVersion=${postgisFullVersion}" - - debianPostgisMajMin="$( echo "${postgisFullVersion}" | cut -d. -f1 ).$( echo "${postgisFullVersion}" | cut -d. -f2 )" - - if [ "$debianPostgisMajMin" == "$postgisMajMin" ]; then - echo "debian postgis version is OK " - postgisMajor="${postgisDebPkgNameVersionSuffixes[${postgisMajMin}]}" - postgisDocSrc="${postgisFullVersion%%+*}" - else - echo "debian postgis is not updated, different .. " - postgisFullVersion="" - postgisMajor="" - postgisDocSrc="" - fi - fi - - if [ -z "$postgisFullVersion" ] - then - echo "SKIP debian version"; - # debain version not found; - echo " # placeholder Dockerfile" > "$version/Dockerfile" - echo " # Debian version of postgis $postgisFullVersion is not detected!">> "$version/Dockerfile" - echo " # This is an autogenerated message of ./update.sh " >> "$version/Dockerfile" - rm -f "$version/*.sh" - rm -f "$version/*.md" - # use the default for the alpine version - postgisFullVersion=$postgisVersion - postgisDocSrc=$postgisVersion - else - ( - set -x - cp -p initdb-postgis.sh update-postgis.sh "$version/" - if [ "master" == "$postgisVersion" ]; then - cat Dockerfile.master.template > "$version/Dockerfile" - else - cat Dockerfile.template > "$version/Dockerfile" - fi - sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'$postgresVersion'/g; s/%%POSTGIS_MAJOR%%/'$postgisMajor'/g; s/%%POSTGIS_VERSION%%/'$postgisFullVersion'/g; s/%%POSTGIS_GIT_HASH%%/'$postgisGitHash'/g; s/%%CGAL5X_GIT_HASH%%/'$cgal5XGitHash'/g; s/%%SFCGAL_GIT_HASH%%/'$sfcgalGitHash'/g; s/%%PROJ_GIT_HASH%%/'$projGitHash'/g; s/%%GDAL_GIT_HASH%%/'$gdalGitHash'/g; s/%%GEOS_GIT_HASH%%/'$geosGitHash'/g; s/%%BOOST_VERSION%%/'"$boostVersion"'/g; s/%%DEBIAN_VERSION%%/'"$suite"'/g;' "$version/Dockerfile" - - echo "| [postgis/postgis:${version}](${dockerhublink}${version}) | [Dockerfile](${githubrepolink}/${version}/Dockerfile) | debian:${suite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md - ) - fi +echo " " - if [ "master" == "$postgisVersion" ]; then - srcVersion="" - srcSha256="" - else - srcVersion="${postgisFullVersion%%+*}" - srcSha256="$(curl -sSL "https://github.com/postgis/postgis/archive/$srcVersion.tar.gz" | sha256sum | awk '{ print $1 }')" - fi - for variant in alpine; do - if [ ! -d "$version/$variant" ]; then - continue - fi - ( - set -x - if [ "$optimized" != "test" ]; then - optimized="alpine" - fi - cp -p Dockerfile.alpine.template initdb-postgis.sh update-postgis.sh "$version/$variant/" - mv "$version/$variant/Dockerfile.alpine.template" "$version/$variant/Dockerfile" - sed -i 's/%%TXT_AUTOGENERATED%%/'"$autogenerated"'/g; s/%%PG_MAJOR%%/'"$postgresVersion"'/g; s/%%POSTGIS_VERSION%%/'"$srcVersion"'/g; s/%%POSTGIS_SHA256%%/'"$srcSha256"'/g' "$version/$variant/Dockerfile" +# Generate versions.json metadata file +./tools/versions.sh "$@" - echo "| [postgis/postgis:${version}-${variant}](${dockerhublink}${version}-${variant}) | [Dockerfile](${githubrepolink}/${version}/${variant}/Dockerfile) | alpine:${defaultAlpinenSuite} | ${postgresVersion} | ${postgisDocSrc} |" >> _dockerlists_${optimized}.md - ) - done -done +# apply version.json - generate Dockerfiles +./tools/apply-templates.sh "$@" -echo "|-------------------------|" -echo "|- Generated images -|" -echo "|-------------------------|" +# apply version.json - generate .github/workflows/main.yml and .circleci/config.yml +./tools/apply-ci.sh "$@" -for optimized in debian alpine test; do - echo " " - echo "---- ${optimized} ----" - cat _dockerlists_${optimized}.md -done +# apply version.json - generate manifest.sh +./tools/apply-manifest.sh "$@" -echo " " -echo "Postprocessing todo:" -echo "- add the new versions to README.md ( manually )" -ls -la _dockerlists_*.md -echo " " -echo " - done - " +# apply version.json - generate README.md +./tools/apply-readme.sh "$@" diff --git a/versions.json b/versions.json new file mode 100644 index 000000000..40af5447b --- /dev/null +++ b/versions.json @@ -0,0 +1,773 @@ +{ + "13-3.3": { + "alpine3.21": { + "tags": "13-3.3-alpine3.21 13-3.3.8-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.3", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "POSTGIS_VERSION": "3.3.8", + "POSTGIS_SHA256": "162d6eb3379eac80e4cd1068a6f36bc7fd1d9a32a68beca4386e7da88770ca70", + "POSTGIS_CHECKOUT": "tags/3.3.8", + "POSTGIS_CHECKOUT_SHA1": "cfb70d6229096d2474d79d097768dd19ef04a840" + } + }, + "13-3.4": { + "alpine3.21": { + "tags": "13-3.4-alpine3.21 13-3.4.4-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + }, + "alpine3.22": { + "tags": "13-3.4-alpine3.22 13-3.4.4-alpine3.22 13-3.4-alpine", + "readme_group": "alpine3.22", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + } + }, + "13-3.5": { + "bullseye": { + "tags": "13-3.5-bullseye 13-3.5.2-bullseye", + "postgis": "3.5", + "readme_group": "bullseye", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.2+dfsg-1.pgdg110+1" + }, + "bookworm": { + "tags": "13-3.5-bookworm 13-3.5.3-bookworm 13-3.5", + "postgis": "3.5", + "readme_group": "bookworm", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.21": { + "tags": "13-3.5-alpine3.21 13-3.5.3-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + }, + "alpine3.22": { + "tags": "13-3.5-alpine3.22 13-3.5.3-alpine3.22 13-3.5-alpine", + "readme_group": "alpine3.22", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "13", + "PG_DOCKER": "13", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "14-3.3": { + "alpine3.21": { + "tags": "14-3.3-alpine3.21 14-3.3.8-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.3", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "POSTGIS_VERSION": "3.3.8", + "POSTGIS_SHA256": "162d6eb3379eac80e4cd1068a6f36bc7fd1d9a32a68beca4386e7da88770ca70", + "POSTGIS_CHECKOUT": "tags/3.3.8", + "POSTGIS_CHECKOUT_SHA1": "cfb70d6229096d2474d79d097768dd19ef04a840" + } + }, + "14-3.4": { + "alpine3.21": { + "tags": "14-3.4-alpine3.21 14-3.4.4-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + }, + "alpine3.22": { + "tags": "14-3.4-alpine3.22 14-3.4.4-alpine3.22 14-3.4-alpine", + "readme_group": "alpine3.22", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + } + }, + "14-3.5": { + "bullseye": { + "tags": "14-3.5-bullseye 14-3.5.2-bullseye", + "postgis": "3.5", + "readme_group": "bullseye", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.2+dfsg-1.pgdg110+1" + }, + "bookworm": { + "tags": "14-3.5-bookworm 14-3.5.3-bookworm 14-3.5", + "postgis": "3.5", + "readme_group": "bookworm", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.21": { + "tags": "14-3.5-alpine3.21 14-3.5.3-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + }, + "alpine3.22": { + "tags": "14-3.5-alpine3.22 14-3.5.3-alpine3.22 14-3.5-alpine", + "readme_group": "alpine3.22", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "15-3.3": { + "alpine3.21": { + "tags": "15-3.3-alpine3.21 15-3.3.8-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.3", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "POSTGIS_VERSION": "3.3.8", + "POSTGIS_SHA256": "162d6eb3379eac80e4cd1068a6f36bc7fd1d9a32a68beca4386e7da88770ca70", + "POSTGIS_CHECKOUT": "tags/3.3.8", + "POSTGIS_CHECKOUT_SHA1": "cfb70d6229096d2474d79d097768dd19ef04a840" + } + }, + "15-3.4": { + "alpine3.21": { + "tags": "15-3.4-alpine3.21 15-3.4.4-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + }, + "alpine3.22": { + "tags": "15-3.4-alpine3.22 15-3.4.4-alpine3.22 15-3.4-alpine", + "readme_group": "alpine3.22", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + } + }, + "15-3.5": { + "bullseye": { + "tags": "15-3.5-bullseye 15-3.5.2-bullseye", + "postgis": "3.5", + "readme_group": "bullseye", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.2+dfsg-1.pgdg110+1" + }, + "bookworm": { + "tags": "15-3.5-bookworm 15-3.5.3-bookworm 15-3.5", + "postgis": "3.5", + "readme_group": "bookworm", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.21": { + "tags": "15-3.5-alpine3.21 15-3.5.3-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + }, + "alpine3.22": { + "tags": "15-3.5-alpine3.22 15-3.5.3-alpine3.22 15-3.5-alpine", + "readme_group": "alpine3.22", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "15", + "PG_DOCKER": "15", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "16-3.3": { + "alpine3.21": { + "tags": "16-3.3-alpine3.21 16-3.3.8-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.3", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "POSTGIS_VERSION": "3.3.8", + "POSTGIS_SHA256": "162d6eb3379eac80e4cd1068a6f36bc7fd1d9a32a68beca4386e7da88770ca70", + "POSTGIS_CHECKOUT": "tags/3.3.8", + "POSTGIS_CHECKOUT_SHA1": "cfb70d6229096d2474d79d097768dd19ef04a840" + } + }, + "16-3.4": { + "alpine3.21": { + "tags": "16-3.4-alpine3.21 16-3.4.4-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + }, + "alpine3.22": { + "tags": "16-3.4-alpine3.22 16-3.4.4-alpine3.22 16-3.4-alpine", + "readme_group": "alpine3.22", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + } + }, + "16-3.5": { + "bullseye": { + "tags": "16-3.5-bullseye 16-3.5.2-bullseye", + "postgis": "3.5", + "readme_group": "bullseye", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.2+dfsg-1.pgdg110+1" + }, + "bookworm": { + "tags": "16-3.5-bookworm 16-3.5.3-bookworm 16-3.5", + "postgis": "3.5", + "readme_group": "bookworm", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.21": { + "tags": "16-3.5-alpine3.21 16-3.5.3-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + }, + "alpine3.22": { + "tags": "16-3.5-alpine3.22 16-3.5.3-alpine3.22 16-3.5-alpine", + "readme_group": "alpine3.22", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "16-3.5-bundle0": { + "bookworm": { + "tags": "16-3.5-bundle0-bookworm 16-3.5.3-bundle0-bookworm 16-3.5-bundle0", + "postgis": "3.5", + "readme_group": "bundle0", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "arch": "amd64 arm64", + "template": "Dockerfile.bundle0.template", + "initfile": "initdb-bundle0.sh", + "PGSQL_HTTP_CHECKOUT": "tags/v1.6.3", + "PGSQL_HTTP_CHECKOUT_SHA1": "865e72b328050bc8d1bf8bd2f982edb7a4eb4e26", + "PGSQL_GZIP_CHECKOUT": "tags/v1.0.0", + "PGSQL_GZIP_CHECKOUT_SHA1": "7c26e8b0056631ec0bb7c8fdd9bf2a24076e4a49", + "DUCKDB_CHECKOUT": "tags/v1.3.1", + "DUCKDB_CHECKOUT_SHA1": "2063dda3e6bd955c364ce8e61939c6248a907be6", + "PG_HINT_PLAN_CHECKOUT": "tags/REL16_1_6_1", + "PG_HINT_PLAN_CHECKOUT_SHA1": "54b4b0358a6c96dc80b2b836bba50937415753b6", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + } + }, + "16-master": { + "bookworm": { + "tags": "16-master-bookworm 16-master", + "postgis": "master", + "readme_group": "test", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "master", + "POSTGIS_CHECKOUT_SHA1": "nocheck", + "CGAL_CHECKOUT": "master", + "CGAL_CHECKOUT_SHA1": "nocheck", + "SFCGAL_CHECKOUT": "master", + "SFCGAL_CHECKOUT_SHA1": "nocheck", + "PROJ_CHECKOUT": "master", + "PROJ_CHECKOUT_SHA1": "nocheck", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "master", + "GDAL_CHECKOUT_SHA1": "nocheck", + "GEOS_CHECKOUT": "main", + "GEOS_CHECKOUT_SHA1": "nocheck", + "BOOST_VERSION": "1.74.0" + } + }, + "16-recent": { + "bookworm": { + "tags": "16-recent-bookworm 16-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 16-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 16-recent", + "postgis": "recent", + "readme_group": "recent", + "PG_MAJOR": "16", + "PG_DOCKER": "16", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91", + "PROJ_CHECKOUT": "tags/9.6.2", + "PROJ_CHECKOUT_SHA1": "7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "tags/v3.11.0", + "GDAL_CHECKOUT_SHA1": "447eb5238bb6ef2837e68bf2ec742c64007b680b", + "GEOS_CHECKOUT": "tags/3.13.1", + "GEOS_CHECKOUT_SHA1": "431568d6e311e0bbfb057b4ec3d44d0d3ba3335f", + "SFCGAL_CHECKOUT": "tags/v2.1.0", + "SFCGAL_CHECKOUT_SHA1": "60573cfb6b3fc01eceda563d275a226317ba01db", + "CGAL_CHECKOUT": "tags/v6.0.1", + "CGAL_CHECKOUT_SHA1": "50cfbde3b84dbeae8338268db2d78fe4fcb522de", + "BOOST_VERSION": "1.74.0" + } + }, + "17-3.4": { + "alpine3.21": { + "tags": "17-3.4-alpine3.21 17-3.4.4-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + }, + "alpine3.22": { + "tags": "17-3.4-alpine3.22 17-3.4.4-alpine3.22 17-3.4-alpine", + "readme_group": "alpine3.22", + "postgis": "3.4", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "POSTGIS_VERSION": "3.4.4", + "POSTGIS_SHA256": "e4a95ee95e675c70c21f1a96438a4cbd2c54d4e3ddd0d4ee2850c00624211f42", + "POSTGIS_CHECKOUT": "tags/3.4.4", + "POSTGIS_CHECKOUT_SHA1": "e5ae0d451ef9ad3abc5c1c4ef43f9c149c05fd9d" + } + }, + "17-3.5": { + "bullseye": { + "tags": "17-3.5-bullseye 17-3.5.2-bullseye", + "postgis": "3.5", + "readme_group": "bullseye", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.2+dfsg-1.pgdg110+1" + }, + "bookworm": { + "tags": "17-3.5-bookworm 17-3.5.3-bookworm 17-3.5 latest", + "postgis": "3.5", + "readme_group": "bookworm", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.21": { + "tags": "17-3.5-alpine3.21 17-3.5.3-alpine3.21", + "readme_group": "alpine3.21", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + }, + "alpine3.22": { + "tags": "17-3.5-alpine3.22 17-3.5.3-alpine3.22 17-3.5-alpine alpine", + "readme_group": "alpine3.22", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "17-3.5-bundle0": { + "bookworm": { + "tags": "17-3.5-bundle0-bookworm 17-3.5.3-bundle0-bookworm 17-3.5-bundle0 bundle0", + "postgis": "3.5", + "readme_group": "bundle0", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "arch": "amd64 arm64", + "template": "Dockerfile.bundle0.template", + "initfile": "initdb-bundle0.sh", + "PGSQL_HTTP_CHECKOUT": "tags/v1.6.3", + "PGSQL_HTTP_CHECKOUT_SHA1": "865e72b328050bc8d1bf8bd2f982edb7a4eb4e26", + "PGSQL_GZIP_CHECKOUT": "tags/v1.0.0", + "PGSQL_GZIP_CHECKOUT_SHA1": "7c26e8b0056631ec0bb7c8fdd9bf2a24076e4a49", + "DUCKDB_CHECKOUT": "tags/v1.3.1", + "DUCKDB_CHECKOUT_SHA1": "2063dda3e6bd955c364ce8e61939c6248a907be6", + "PG_HINT_PLAN_CHECKOUT": "tags/REL17_1_7_0", + "PG_HINT_PLAN_CHECKOUT_SHA1": "85e07af6ca4675a26fa2281370c37371b883b2a9", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + } + }, + "17-3.6": { + "alpine3.22": { + "tags": "17-3.6.0alpha1-alpine3.22 17-3.6.0alpha1-alpine", + "readme_group": "test", + "postgis": "3.6.0alpha1", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "POSTGIS_VERSION": "3.6.0alpha1", + "POSTGIS_SHA256": "9f1981716001afff2e4ec75e4107cb64e8d3d9d26ad2abf573444038db0830eb", + "POSTGIS_CHECKOUT": "tags/3.6.0alpha1", + "POSTGIS_CHECKOUT_SHA1": "b32829d707ef65515df1224361b9f2d5889db348" + } + }, + "17-master": { + "bookworm": { + "tags": "17-master-bookworm 17-master", + "postgis": "master", + "readme_group": "test", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "master", + "POSTGIS_CHECKOUT_SHA1": "nocheck", + "CGAL_CHECKOUT": "master", + "CGAL_CHECKOUT_SHA1": "nocheck", + "SFCGAL_CHECKOUT": "master", + "SFCGAL_CHECKOUT_SHA1": "nocheck", + "PROJ_CHECKOUT": "master", + "PROJ_CHECKOUT_SHA1": "nocheck", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "master", + "GDAL_CHECKOUT_SHA1": "nocheck", + "GEOS_CHECKOUT": "main", + "GEOS_CHECKOUT_SHA1": "nocheck", + "BOOST_VERSION": "1.74.0" + } + }, + "17-recent": { + "bookworm": { + "tags": "17-recent-bookworm 17-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 17-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 17-recent recent", + "postgis": "recent", + "readme_group": "recent", + "PG_MAJOR": "17", + "PG_DOCKER": "17", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91", + "PROJ_CHECKOUT": "tags/9.6.2", + "PROJ_CHECKOUT_SHA1": "7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "tags/v3.11.0", + "GDAL_CHECKOUT_SHA1": "447eb5238bb6ef2837e68bf2ec742c64007b680b", + "GEOS_CHECKOUT": "tags/3.13.1", + "GEOS_CHECKOUT_SHA1": "431568d6e311e0bbfb057b4ec3d44d0d3ba3335f", + "SFCGAL_CHECKOUT": "tags/v2.1.0", + "SFCGAL_CHECKOUT_SHA1": "60573cfb6b3fc01eceda563d275a226317ba01db", + "CGAL_CHECKOUT": "tags/v6.0.1", + "CGAL_CHECKOUT_SHA1": "50cfbde3b84dbeae8338268db2d78fe4fcb522de", + "BOOST_VERSION": "1.74.0" + } + }, + "18-3.5": { + "bookworm": { + "tags": "18beta1-3.5-bookworm 18beta1-3.5.3-bookworm 18beta1-3.5", + "postgis": "3.5", + "readme_group": "test", + "PG_MAJOR": "18", + "PG_DOCKER": "18beta1", + "arch": "amd64 arm64", + "template": "Dockerfile.debian.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_MAJOR": "3", + "POSTGIS_VERSION": "3.5.3+dfsg-1~exp1.pgdg120+1" + }, + "alpine3.22": { + "tags": "18beta1-3.5-alpine3.22 18beta1-3.5.3-alpine3.22 18beta1-3.5-alpine", + "readme_group": "test", + "postgis": "3.5", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "18", + "PG_DOCKER": "18beta1", + "POSTGIS_VERSION": "3.5.3", + "POSTGIS_SHA256": "44222ed2b8f742ffc1ceb429b09ebb484c7880f9ba27bf7b6b197346cdd25437", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91" + } + }, + "18-3.6": { + "alpine3.22": { + "tags": "18beta1-3.6.0alpha1-alpine3.22 18beta1-3.6.0alpha1-alpine", + "readme_group": "test", + "postgis": "3.6.0alpha1", + "arch": "amd64 arm64", + "template": "Dockerfile.alpine.template", + "initfile": "initdb-postgis.sh", + "PG_MAJOR": "18", + "PG_DOCKER": "18beta1", + "POSTGIS_VERSION": "3.6.0alpha1", + "POSTGIS_SHA256": "9f1981716001afff2e4ec75e4107cb64e8d3d9d26ad2abf573444038db0830eb", + "POSTGIS_CHECKOUT": "tags/3.6.0alpha1", + "POSTGIS_CHECKOUT_SHA1": "b32829d707ef65515df1224361b9f2d5889db348" + } + }, + "18-master": { + "bookworm": { + "tags": "18beta1-master-bookworm 18beta1-master", + "postgis": "master", + "readme_group": "test", + "PG_MAJOR": "18", + "PG_DOCKER": "18beta1", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "master", + "POSTGIS_CHECKOUT_SHA1": "nocheck", + "CGAL_CHECKOUT": "master", + "CGAL_CHECKOUT_SHA1": "nocheck", + "SFCGAL_CHECKOUT": "master", + "SFCGAL_CHECKOUT_SHA1": "nocheck", + "PROJ_CHECKOUT": "master", + "PROJ_CHECKOUT_SHA1": "nocheck", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "master", + "GDAL_CHECKOUT_SHA1": "nocheck", + "GEOS_CHECKOUT": "main", + "GEOS_CHECKOUT_SHA1": "nocheck", + "BOOST_VERSION": "1.74.0" + } + }, + "18-recent": { + "bookworm": { + "tags": "18beta1-recent-bookworm 18beta1-recent-postgis3.5.3-geos3.13.1-proj9.6.2-gdal3.11.0-cgal6.0.1-sfcgal2.1.0-bookworm 18beta1-recent-postgis3.5-geos3.13-proj9.6-gdal3.11-cgal6.0-sfcgal2.1-bookworm 18beta1-recent", + "postgis": "recent", + "readme_group": "test", + "PG_MAJOR": "18", + "PG_DOCKER": "18beta1", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "tags/3.5.3", + "POSTGIS_CHECKOUT_SHA1": "aab5f55897aa2e8eb5f17c3996b61268c5f1ec91", + "PROJ_CHECKOUT": "tags/9.6.2", + "PROJ_CHECKOUT_SHA1": "7c3d4a1fa9c1d5a3941b5eaee7c8d149f5936f54", + "GDAL_BUILD": "with_extra", + "GDAL_CHECKOUT": "tags/v3.11.0", + "GDAL_CHECKOUT_SHA1": "447eb5238bb6ef2837e68bf2ec742c64007b680b", + "GEOS_CHECKOUT": "tags/3.13.1", + "GEOS_CHECKOUT_SHA1": "431568d6e311e0bbfb057b4ec3d44d0d3ba3335f", + "SFCGAL_CHECKOUT": "tags/v2.1.0", + "SFCGAL_CHECKOUT_SHA1": "60573cfb6b3fc01eceda563d275a226317ba01db", + "CGAL_CHECKOUT": "tags/v6.0.1", + "CGAL_CHECKOUT_SHA1": "50cfbde3b84dbeae8338268db2d78fe4fcb522de", + "BOOST_VERSION": "1.74.0" + } + }, + "14-l3.1.9gcp": { + "bookworm": { + "_comment": "source: ./locked.yml", + "tags": "14-l3.1.9gcp-bookworm 14-l3.1.9gcp-postgis3.1.9-geos3.6.6-proj6.3.1-bookworm", + "postgis": "l3.1.9gcp", + "readme_group": "locked", + "PG_MAJOR": "14", + "PG_DOCKER": "14", + "arch": "amd64 arm64", + "template": "Dockerfile.master.template", + "initfile": "initdb-postgis.sh", + "POSTGIS_CHECKOUT": "tags/3.1.9", + "POSTGIS_CHECKOUT_SHA1": "95a641b1747721d7004c5f0133b918d034035319", + "PROJ_CHECKOUT": "tags/6.3.1", + "PROJ_CHECKOUT_SHA1": "0e993d9744ecaa2f146bf62c43aecc61809a43ef", + "GDAL_BUILD": "minimal", + "GDAL_CHECKOUT": "tags/v3.6.4", + "GDAL_CHECKOUT_SHA1": "7ca88116f5a46d429251361634eb24629f315076", + "GEOS_CHECKOUT": "tags/3.6.6", + "GEOS_CHECKOUT_SHA1": "36ea3034fb8719a639a7e7727e54ec8ab2e8a196", + "SFCGAL_CHECKOUT": "tags/v1.5.1", + "SFCGAL_CHECKOUT_SHA1": "61f3b08ade49493b56c6bafa98c7c1f84addbc10", + "CGAL_CHECKOUT": "tags/v5.6", + "CGAL_CHECKOUT_SHA1": "de4fa0d7d57b5a997012f2804161386ff4bc0d0f", + "BOOST_VERSION": "1.74.0" + } + } +} diff --git a/versions.schema.json b/versions.schema.json new file mode 100644 index 000000000..1c0743810 --- /dev/null +++ b/versions.schema.json @@ -0,0 +1,98 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "definitions": { + "git_checkout_ref": { + "type": "string", + "pattern": "^(master|main|develop|tags/(((v|V)?[0-9]+(\\.[0-9]+)*([-_]?[a-zA-Z0-9]+)*)|((REL|rel)_?[0-9]+(_[0-9]+)*(_[a-zA-Z0-9]+)*)))$" + }, + "sha1_value": { + "type": "string", + "pattern": "^(nocheck|[0-9a-f]{40})$" + }, + "pg_version": { + "type": "string", + "pattern": "^[0-9]{2}(beta[0-9]+|rc[0-9]+)?$" + }, + "gdal_build_type": { + "type": "string", + "enum": ["with_extra", "minimal"] + }, + "shell_script": { + "type": "string", + "pattern": "^[a-zA-Z0-9][a-zA-Z0-9_-]*\\.sh$" + }, + "docker_tags": { + "type": "string", + "pattern": "^(([0-9]{2}(beta[0-9]+|rc[0-9]+)?-[a-zA-Z0-9.-]+(alpha[0-9]+|beta[0-9]+|rc[0-9]+)?|recent|latest|alpine|bundle0)\\s*)+$" + }, + "readme_group_type": { + "type": "string", + "pattern": "^(alpine[0-9.]+|bullseye|bookworm|bundle0|locked|recent|test)$" + }, + "distribution": { + "type": "object", + "required": [ + "tags", + "postgis", + "arch", + "template", + "initfile", + "PG_MAJOR", + "PG_DOCKER", + "readme_group" + ], + "properties": { + "tags": {"$ref": "#/definitions/docker_tags"}, + "postgis": {"type": "string"}, + "readme_group": {"$ref": "#/definitions/readme_group_type"}, + "arch": {"type": "string", "pattern": "^(amd64|arm64|amd64 arm64)$"}, + "template": { + "type": "string", + "enum": [ + "Dockerfile.alpine.template", + "Dockerfile.debian.template", + "Dockerfile.master.template", + "Dockerfile.bundle0.template" + ] + }, + "initfile": {"$ref": "#/definitions/shell_script"}, + "PG_MAJOR": {"$ref": "#/definitions/pg_version"}, + "PG_DOCKER": {"$ref": "#/definitions/pg_version"}, + "GDAL_BUILD": {"$ref": "#/definitions/gdal_build_type"}, + "POSTGIS_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "PROJ_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "GDAL_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "GEOS_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "SFCGAL_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "CGAL_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "PGSQL_HTTP_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "PGSQL_GZIP_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "PG_HINT_PLAN_CHECKOUT": {"$ref": "#/definitions/git_checkout_ref"}, + "POSTGIS_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "PROJ_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "GDAL_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "GEOS_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "SFCGAL_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "CGAL_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "PGSQL_HTTP_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "PGSQL_GZIP_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"}, + "PG_HINT_PLAN_CHECKOUT_SHA1": {"$ref": "#/definitions/sha1_value"} + }, + "patternProperties": { + ".*_CHECKOUT_SHA1$": {"$ref": "#/definitions/sha1_value"} + } + } + }, + "patternProperties": { + "^[0-9]+-[0-9.]+(?:-[a-zA-Z0-9]+)?$": { + "type": "object", + "patternProperties": { + "^(alpine[0-9.]+|bullseye|bookworm)$": { + "$ref": "#/definitions/distribution" + } + }, + "additionalProperties": false + } + } +} \ No newline at end of file