File tree Expand file tree Collapse file tree 8 files changed +88
-13
lines changed
Expand file tree Collapse file tree 8 files changed +88
-13
lines changed Original file line number Diff line number Diff line change 3030 filters : |
3131 pgvector:
3232 - 'pgvector/**'
33+ postgis:
34+ - 'postgis/**'
3335
3436 # Compute a matrix containing the list of all extensions that have been modified
3537 - name : Compute matrix
5456 matrix : ${{ fromJSON(needs.change-triage.outputs.matrix) }}
5557 uses : ./.github/workflows/bake_targets.yml
5658 with :
57- environment : ${{ (github.ref == 'refs/heads/main') && 'production' || 'testing'}}
5859 extension_name : ${{ matrix.name }}
5960 secrets :
6061 SNYK_TOKEN : ${{ secrets.SNYK_TOKEN }}
Original file line number Diff line number Diff line change @@ -3,11 +3,6 @@ name: Build, test and publish a target extension
33on :
44 workflow_call :
55 inputs :
6- environment :
7- description : " Target environment for the image build (e.g. testing, production)."
8- required : true
9- type : string
10- default : " testing"
116 extension_name :
127 description : " The PostgreSQL extension to build (directory name)"
138 required : true
@@ -187,9 +182,7 @@ jobs:
187182
188183 copytoproduction :
189184 name : Copy images to production
190- if : |
191- github.ref == 'refs/heads/main' &&
192- ( github.event.inputs.environment == 'production' || github.event_name == 'schedule' )
185+ if : ${{ github.ref == 'refs/heads/main' }}
193186 runs-on : ubuntu-24.04
194187 needs :
195188 - testbuild
Original file line number Diff line number Diff line change 4747 steps :
4848 - name : Checkout repository
4949 uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
50- with :
51- persist-credentials : false
5250
5351 - name : Fetch latest extension versions
5452 id : fetch_versions
@@ -61,11 +59,17 @@ jobs:
6159 readarray -t POSTGRES_MAJORS < <(sed -n '/variable "pgVersions"/,/]/ { s/^[[:space:]]*"\([^"]*\)".*/\1/p }' docker-bake.hcl)
6260 # Get the extension name
6361 EXT_NAME=$(jq -r '.metadata.name' "$EXTENSION_NAME/metadata.json")
62+ # Get the extension major version
63+ EXT_MAJOR=$(jq -r '.metadata.major_version' "$EXTENSION_NAME/metadata.json")
6464
6565 for DISTRO in "${DISTROS[@]}"; do
6666 for MAJOR in "${POSTGRES_MAJORS[@]}"; do
67+ PKG="postgresql-${MAJOR}-${EXT_NAME}"
68+ if [[ -n "$EXT_MAJOR" ]] && [[ "$EXT_MAJOR" != "null" ]]; then
69+ PKG="postgresql-${MAJOR}-${EXT_NAME}-${EXT_MAJOR}"
70+ fi
6771 VERSION=$(curl -s "https://apt.postgresql.org/pub/repos/apt/dists/$DISTRO-pgdg/main/binary-amd64/Packages" \
68- | awk -v pkg="postgresql-${MAJOR}-${EXT_NAME }" '
72+ | awk -v pkg="${PKG }" '
6973 $1 == "Package:" && $2 == pkg {show=1; next}
7074 show && $1 == "Version:" {print $2; show=0}
7175 ' \
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ in CloudNativePG.
2121## Supported Extensions
2222
2323- [ pgvector] ( pgvector ) - Open-source vector similarity search for PostgreSQL
24+ - [ pgvector] ( postgis ) - Open-source geospatial database extension for PostgreSQL
2425
2526---
2627
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ variable "pgVersions" {
2828 ]
2929}
3030
31- fullname = ( environment == " testing" ) ? " ${ registry } /${ metadata . name } -testing" : " ${ registry } /${ metadata . name } "
31+ fullname = ( environment == " testing" ) ? " ${ registry } /${ metadata . image_name } -testing" : " ${ registry } /${ metadata . image_name } "
3232now = timestamp ()
3333authors = " The CloudNativePG Contributors"
3434url = " https://github.com/cloudnative-pg/postgres-extensions-containers"
@@ -56,6 +56,7 @@ target "default" {
5656 args = {
5757 PG_MAJOR = " ${ pgVersion } "
5858 EXT_VERSION = " ${ getExtensionPackage (distro, pgVersion)} "
59+ EXT_MAJOR = " ${ metadata . major_version } "
5960 BASE = " ${ getBaseImage (distro, pgVersion)} "
6061 }
6162
Original file line number Diff line number Diff line change 1+ ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
2+ FROM $BASE AS builder
3+
4+ ARG PG_MAJOR
5+ ARG EXT_VERSION
6+ ARG EXT_MAJOR
7+
8+ USER 0
9+
10+ RUN set -eux && \
11+ # Initial system libraries
12+ ldconfig -p | awk '{print $NF}' | grep '^/' | sort | uniq > /tmp/base-image-libs.out && \
13+ # Install PostGIS
14+ apt-get update && \
15+ apt-get install -y --no-install-recommends "postgresql-${PG_MAJOR}-postgis-${EXT_MAJOR}=${EXT_VERSION}"
16+
17+ # Gather PostGIS system libraries and their licenses
18+ RUN mkdir -p /system /licenses && \
19+ # Get libraries
20+ ldd /usr/lib/postgresql/${PG_MAJOR}/lib/address_standardizer*.so \
21+ /usr/lib/postgresql/${PG_MAJOR}/lib/postgis*.so \
22+ | awk '{print $3}' | grep '^/' | sort | uniq > /tmp/all-deps.out && \
23+ comm -13 /tmp/base-image-libs.out /tmp/all-deps.out > /tmp/libraries.out && \
24+ for lib in $(cat /tmp/libraries.out); do cp -a "${lib%.so*}.so" * /system; done && \
25+ # Get licenses
26+ for lib in $(find /system -maxdepth 1 -type f -name '*.so*' ); do \
27+ pkg=$(dpkg -S "$(basename " $lib")" | awk -F: '/:/{print $1; exit}' ); \
28+ [ -z "$pkg" ] && continue; \
29+ mkdir -p "/licenses/$pkg" && cp -a "/usr/share/doc/$pkg/copyright" "/licenses/$pkg/copyright" ; \
30+ done
31+
32+
33+ FROM scratch
34+ ARG PG_MAJOR
35+ ARG EXT_MAJOR
36+
37+ # Licenses
38+ COPY --from=builder /licenses /licenses/
39+ COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-postgis-${EXT_MAJOR}/copyright /licenses/postgresql-${PG_MAJOR}-postgis-${EXT_MAJOR}/
40+
41+ # Libraries
42+ COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/address_standardizer* /usr/lib/postgresql/${PG_MAJOR}/lib/postgis* /lib/
43+ COPY --from=builder /usr/lib/postgresql/18/lib/bitcode/ /lib/bitcode/
44+
45+ # Share
46+ COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/address_standardizer* /usr/share/postgresql/${PG_MAJOR}/extension/postgis* /share/extension/
47+ COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/contrib/postgis* /share/contrib/
48+
49+ # System libs
50+ COPY --from=builder /system /system/
51+
52+ USER 65532:65532
Original file line number Diff line number Diff line change 1+ # PostGIS
2+
3+ TODO
Original file line number Diff line number Diff line change 1+ {
2+ "metadata" : {
3+ "name" : " postgis" ,
4+ "image_name" : " postgis-extension" ,
5+ "sql_name" : " postgis" ,
6+ "shared_preload_libraries" : [],
7+ "extension_control_path" : [],
8+ "dynamic_library_path" : [],
9+ "ld_library_path" : [" /system" ],
10+ "major_version" : " 3" ,
11+ "versions" : {
12+ "bookworm" : {
13+ "18" : " 3.6.0+dfsg-3.pgdg12+1"
14+ },
15+ "trixie" : {
16+ "18" : " 3.6.0+dfsg-3.pgdg13+1"
17+ }
18+ }
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments