Skip to content

Commit f845c7a

Browse files
committed
feat: pin versions and detect PostGIS version for image tags
Publish workflow now builds the image, detects the installed PostGIS version via dpkg, and tags as postgres-17.9-postgis-3.5.2-pgvector-0.8.2.
1 parent bc6a678 commit f845c7a

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

.github/workflows/publish.yml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ jobs:
1919
matrix:
2020
include:
2121
- pg_version: "17.9"
22-
postgis_version: "3"
2322
pgvector_version: "0.8.2"
2423
latest: true
2524
- pg_version: "16.13"
26-
postgis_version: "3"
2725
pgvector_version: "0.8.2"
2826
latest: false
2927
- pg_version: "15.17"
30-
postgis_version: "3"
3128
pgvector_version: "0.8.2"
3229
latest: false
3330
- pg_version: "14.22"
34-
postgis_version: "3"
3531
pgvector_version: "0.8.2"
3632
latest: false
3733

@@ -49,26 +45,34 @@ jobs:
4945
- name: Set up Docker Buildx
5046
uses: docker/setup-buildx-action@v4
5147

52-
- name: Extract metadata (tags, labels) for Docker
53-
id: meta
54-
uses: docker/metadata-action@v6
55-
with:
56-
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.repository.name }}
57-
tags: |
58-
type=raw,value=postgres-${{ matrix.pg_version }}-postgis-${{ matrix.postgis_version }}-pgvector-${{ matrix.pgvector_version }}
59-
type=raw,value=latest,enable=${{ matrix.latest }}
60-
type=ref,event=tag
61-
62-
- name: Build and push Docker image
48+
- name: Build Docker image
6349
uses: docker/build-push-action@v7
6450
with:
6551
context: .
66-
push: true
67-
tags: ${{ steps.meta.outputs.tags }}
68-
labels: ${{ steps.meta.outputs.labels }}
52+
load: true
53+
tags: local-build:${{ matrix.pg_version }}
6954
build-args: |
7055
PG_VERSION=${{ matrix.pg_version }}
71-
POSTGIS_VERSION=${{ matrix.postgis_version }}
7256
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
73-
cache-from: type=gha
74-
cache-to: type=gha,mode=max
57+
58+
- name: Detect PostGIS version
59+
id: postgis
60+
run: |
61+
PG_MAJOR=$(echo "${{ matrix.pg_version }}" | cut -d. -f1)
62+
POSTGIS_VERSION=$(docker run --rm local-build:${{ matrix.pg_version }} \
63+
dpkg-query -W -f='${Version}' "postgresql-${PG_MAJOR}-postgis-3" | cut -d+ -f1)
64+
echo "version=${POSTGIS_VERSION}" >> "$GITHUB_OUTPUT"
65+
echo "Detected PostGIS version: ${POSTGIS_VERSION}"
66+
67+
- name: Tag and push Docker image
68+
run: |
69+
IMAGE="${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.repository.name }}"
70+
TAG="postgres-${{ matrix.pg_version }}-postgis-${{ steps.postgis.outputs.version }}-pgvector-${{ matrix.pgvector_version }}"
71+
docker tag local-build:${{ matrix.pg_version }} "${IMAGE}:${TAG}"
72+
docker push "${IMAGE}:${TAG}"
73+
echo "Pushed ${IMAGE}:${TAG}"
74+
if [ "${{ matrix.latest }}" = "true" ]; then
75+
docker tag local-build:${{ matrix.pg_version }} "${IMAGE}:latest"
76+
docker push "${IMAGE}:latest"
77+
echo "Pushed ${IMAGE}:latest"
78+
fi

.github/workflows/test.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,12 @@ jobs:
1414
matrix:
1515
include:
1616
- pg_version: "17.9"
17-
postgis_version: "3"
1817
pgvector_version: "0.8.2"
1918
- pg_version: "16.13"
20-
postgis_version: "3"
2119
pgvector_version: "0.8.2"
2220
- pg_version: "15.17"
23-
postgis_version: "3"
2421
pgvector_version: "0.8.2"
2522
- pg_version: "14.22"
26-
postgis_version: "3"
2723
pgvector_version: "0.8.2"
2824

2925
steps:
@@ -33,15 +29,13 @@ jobs:
3329
uses: docker/setup-buildx-action@v4
3430

3531
- name: Build Docker image
36-
id: build
3732
uses: docker/build-push-action@v7
3833
with:
3934
context: .
4035
load: true
4136
tags: postgres-test:pg${{ matrix.pg_version }}
4237
build-args: |
4338
PG_VERSION=${{ matrix.pg_version }}
44-
POSTGIS_VERSION=${{ matrix.postgis_version }}
4539
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
4640
4741
- name: Start PostgreSQL container and test extensions

Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# Default versions - can be overridden at build time using --build-arg
22
ARG PG_VERSION=17.9
3-
ARG POSTGIS_VERSION=3
43
ARG PGVECTOR_VERSION=0.8.2
54

65
FROM postgres:${PG_VERSION}
76

87
# Re-declare ARGs after FROM to make them available in this build stage
9-
ARG POSTGIS_VERSION
108
ARG PGVECTOR_VERSION
119

1210
LABEL maintainer="TypeORM"
@@ -35,10 +33,10 @@ RUN apt-get update \
3533
RUN apt-get update \
3634
&& apt-get install -y --no-install-recommends \
3735
postgis \
38-
"postgresql-${PG_MAJOR}-postgis-${POSTGIS_VERSION}" \
39-
"postgresql-${PG_MAJOR}-postgis-${POSTGIS_VERSION}-scripts"
36+
"postgresql-${PG_MAJOR}-postgis-3" \
37+
"postgresql-${PG_MAJOR}-postgis-3-scripts"
4038

41-
# Build and install pgvector
39+
# Build and install pgvector from source to pin exact version
4240
RUN apt-get update \
4341
&& apt-get install -y --no-install-recommends git make gcc "postgresql-server-dev-${PG_MAJOR}" \
4442
&& mkdir -p /usr/src/pgvector \

0 commit comments

Comments
 (0)