Skip to content

Commit 9cf86d7

Browse files
committed
feat: use fully pinned versions for all components
Tags now use the format postgres-17.9-postgis-3-pgvector-0.8.2 with exact patch versions for reproducible builds.
1 parent 8defc30 commit 9cf86d7

File tree

3 files changed

+62
-70
lines changed

3 files changed

+62
-70
lines changed

.github/workflows/publish.yml

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,38 @@ name: Publish
22

33
on:
44
push:
5-
tags: ["v*.*.*"] # Trigger on version tags like v1.0.0
6-
workflow_dispatch: # Allows manual triggering
5+
tags: ["v*.*.*"]
6+
workflow_dispatch:
77

88
env:
99
REGISTRY: ghcr.io
10-
# IMAGE_NAME is constructed as owner/repository_name by default in metadata-action
11-
# Example: ghcr.io/yourusername/yourrepositoryname
1210

1311
jobs:
1412
build-and-push:
1513
runs-on: ubuntu-latest
1614
permissions:
1715
contents: read
18-
packages: write # Required to publish to GHCR
16+
packages: write
1917

2018
strategy:
2119
matrix:
2220
include:
23-
- pg_major_version: 17
24-
postgis_major_version: 3
25-
pgvector_tag: v0.8.0
26-
latest_tag_suffix: true
27-
- pg_major_version: 16
28-
postgis_major_version: 3
29-
pgvector_tag: v0.8.0
30-
latest_tag_suffix: false
31-
- pg_major_version: 15
32-
postgis_major_version: 3
33-
pgvector_tag: v0.8.0
34-
latest_tag_suffix: false
35-
- pg_major_version: 14
36-
postgis_major_version: 3
37-
pgvector_tag: v0.8.0
38-
latest_tag_suffix: false
21+
- pg_version: "17.9"
22+
postgis_version: "3"
23+
pgvector_version: "0.8.2"
24+
latest: true
25+
- pg_version: "16.13"
26+
postgis_version: "3"
27+
pgvector_version: "0.8.2"
28+
latest: false
29+
- pg_version: "15.17"
30+
postgis_version: "3"
31+
pgvector_version: "0.8.2"
32+
latest: false
33+
- pg_version: "14.22"
34+
postgis_version: "3"
35+
pgvector_version: "0.8.2"
36+
latest: false
3937

4038
steps:
4139
- name: Checkout repository
@@ -57,8 +55,8 @@ jobs:
5755
with:
5856
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.repository.name }}
5957
tags: |
60-
type=raw,value=pg${{ matrix.pg_major_version }}-postgis${{ matrix.postgis_major_version }}-pgvector${{ matrix.pgvector_tag }}
61-
type=raw,value=latest,enable=${{ matrix.latest_tag_suffix }}
58+
type=raw,value=postgres-${{ matrix.pg_version }}-postgis-${{ matrix.postgis_version }}-pgvector-${{ matrix.pgvector_version }}
59+
type=raw,value=latest,enable=${{ matrix.latest }}
6260
type=ref,event=tag
6361
6462
- name: Build and push Docker image
@@ -69,8 +67,8 @@ jobs:
6967
tags: ${{ steps.meta.outputs.tags }}
7068
labels: ${{ steps.meta.outputs.labels }}
7169
build-args: |
72-
PG_MAJOR_VERSION=${{ matrix.pg_major_version }}
73-
POSTGIS_MAJOR_VERSION=${{ matrix.postgis_major_version }}
74-
PGVECTOR_TAG=${{ matrix.pgvector_tag }}
70+
PG_VERSION=${{ matrix.pg_version }}
71+
POSTGIS_VERSION=${{ matrix.postgis_version }}
72+
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
7573
cache-from: type=gha
7674
cache-to: type=gha,mode=max

.github/workflows/test.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,19 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
# Renaming for clarity in matrix, maps to Dockerfile ARGs
16-
pg_version_matrix: [16, 15] # Corresponds to PG_MAJOR_VERSION
17-
pgvector_tag_matrix: [v0.8.0, v0.7.2] # Corresponds to PGVECTOR_TAG
18-
# POSTGIS_MAJOR_VERSION is set to 3 directly in build-args below
15+
include:
16+
- pg_version: "17.9"
17+
postgis_version: "3"
18+
pgvector_version: "0.8.2"
19+
- pg_version: "16.13"
20+
postgis_version: "3"
21+
pgvector_version: "0.8.2"
22+
- pg_version: "15.17"
23+
postgis_version: "3"
24+
pgvector_version: "0.8.2"
25+
- pg_version: "14.22"
26+
postgis_version: "3"
27+
pgvector_version: "0.8.2"
1928

2029
steps:
2130
- uses: actions/checkout@v6
@@ -28,27 +37,27 @@ jobs:
2837
uses: docker/build-push-action@v7
2938
with:
3039
context: .
31-
load: true # Load image into local Docker daemon for testing
32-
tags: postgres-postgis-pgvector:test-${{ matrix.pg_version_matrix }}-pgvector${{ matrix.pgvector_tag_matrix }}
40+
load: true
41+
tags: postgres-test:pg${{ matrix.pg_version }}
3342
build-args: |
34-
PG_MAJOR_VERSION=${{ matrix.pg_version_matrix }}
35-
POSTGIS_MAJOR_VERSION=3
36-
PGVECTOR_TAG=${{ matrix.pgvector_tag_matrix }}
43+
PG_VERSION=${{ matrix.pg_version }}
44+
POSTGIS_VERSION=${{ matrix.postgis_version }}
45+
PGVECTOR_VERSION=${{ matrix.pgvector_version }}
3746
3847
- name: Start PostgreSQL container and test extensions
3948
run: |
40-
IMAGE_TAG="postgres-postgis-pgvector:test-${{ matrix.pg_version_matrix }}-pgvector${{ matrix.pgvector_tag_matrix }}"
49+
IMAGE_TAG="postgres-test:pg${{ matrix.pg_version }}"
4150
echo "Testing image: $IMAGE_TAG"
4251
4352
docker run -d --name test-db \
4453
-e POSTGRES_PASSWORD=test \
4554
-e POSTGRES_USER=test \
4655
-e POSTGRES_DB=test \
4756
$IMAGE_TAG \
48-
postgres -c shared_preload_libraries=vector # Ensure pgvector is preloaded
57+
postgres -c shared_preload_libraries=vector
4958
5059
echo "Waiting for PostgreSQL to start..."
51-
sleep 15 # Allow time for PostgreSQL to initialize
60+
sleep 15
5261
5362
echo "PostgreSQL logs:"
5463
docker logs test-db
@@ -63,7 +72,7 @@ jobs:
6372
docker exec test-db psql -U test -d test -c "CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3)); INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'); SELECT COUNT(*) FROM items;"
6473
6574
- name: Stop and remove container
66-
if: always() # Ensure cleanup even if previous steps fail
75+
if: always()
6776
run: |
6877
docker stop test-db || true
6978
docker rm test-db || true

Dockerfile

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,65 @@
11
# Default versions - can be overridden at build time using --build-arg
2-
ARG PG_MAJOR_VERSION=16
3-
ARG POSTGIS_MAJOR_VERSION=3
4-
ARG PGVECTOR_TAG=v0.8.0
2+
ARG PG_VERSION=17.9
3+
ARG POSTGIS_VERSION=3
4+
ARG PGVECTOR_VERSION=0.8.2
55

6-
FROM postgres:${PG_MAJOR_VERSION}
6+
FROM postgres:${PG_VERSION}
77

88
# Re-declare ARGs after FROM to make them available in this build stage
9-
ARG PG_MAJOR_VERSION
10-
ARG POSTGIS_MAJOR_VERSION
11-
ARG PGVECTOR_TAG
9+
ARG POSTGIS_VERSION
10+
ARG PGVECTOR_VERSION
1211

13-
LABEL maintainer="Naor Peled me@naor.dev"
12+
LABEL maintainer="TypeORM"
1413
LABEL description="PostgreSQL with PostGIS and pgvector extensions for TypeORM"
15-
LABEL org.opencontainers.image.source="https://github.com/naorpeled/typeorm-postgres-docker"
16-
17-
# Set ENV vars from ARGs for runtime inspection and use within the container
18-
ENV PG_MAJOR_VERSION=${PG_MAJOR_VERSION} \
19-
POSTGIS_MAJOR_VERSION=${POSTGIS_MAJOR_VERSION} \
20-
PGVECTOR_TAG=${PGVECTOR_TAG}
14+
LABEL org.opencontainers.image.source="https://github.com/typeorm/postgres-test-images"
2115

2216
# Install base dependencies, setup PGDG repository, and install build tools
17+
# Note: PG_MAJOR is provided by the official postgres base image
2318
RUN apt-get update \
2419
&& apt-get install -y --no-install-recommends \
2520
lsb-release \
2621
gnupg \
2722
ca-certificates \
2823
wget \
29-
# Add PostgreSQL official repository using signed-by (apt-key is removed in newer Debian)
3024
&& wget --quiet -O /usr/share/keyrings/postgresql-archive-keyring.gpg https://www.postgresql.org/media/keys/ACCC4CF8.asc \
3125
&& sh -c 'echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
32-
# Update package lists again after adding the new repository
3326
&& apt-get update \
34-
# Install build tools and PostgreSQL development packages from PGDG
3527
&& apt-get install -y --no-install-recommends \
3628
build-essential \
3729
git \
3830
make \
3931
gcc \
40-
"postgresql-server-dev-${PG_MAJOR_VERSION}"
32+
"postgresql-server-dev-${PG_MAJOR}"
4133

4234
# Install PostGIS
4335
RUN apt-get update \
4436
&& apt-get install -y --no-install-recommends \
4537
postgis \
46-
"postgresql-${PG_MAJOR_VERSION}-postgis-${POSTGIS_MAJOR_VERSION}" \
47-
"postgresql-${PG_MAJOR_VERSION}-postgis-${POSTGIS_MAJOR_VERSION}-scripts"
38+
"postgresql-${PG_MAJOR}-postgis-${POSTGIS_VERSION}" \
39+
"postgresql-${PG_MAJOR}-postgis-${POSTGIS_VERSION}-scripts"
4840

4941
# Build and install pgvector
5042
RUN apt-get update \
51-
# Ensure build tools are available for this layer if they were aggressively purged before,
52-
# or if previous RUN commands didn't include them and they are needed.
53-
# For pgvector, we need git, make, gcc, and postgresql-server-dev.
54-
&& apt-get install -y --no-install-recommends git make gcc "postgresql-server-dev-${PG_MAJOR_VERSION}" \
43+
&& apt-get install -y --no-install-recommends git make gcc "postgresql-server-dev-${PG_MAJOR}" \
5544
&& mkdir -p /usr/src/pgvector \
56-
&& git clone --branch "${PGVECTOR_TAG}" https://github.com/pgvector/pgvector.git /usr/src/pgvector \
45+
&& git clone --branch "v${PGVECTOR_VERSION}" https://github.com/pgvector/pgvector.git /usr/src/pgvector \
5746
&& cd /usr/src/pgvector \
5847
&& make \
5948
&& make install
6049

6150
# Cleanup build dependencies
6251
RUN apt-get purge -y --auto-remove \
6352
build-essential \
64-
# git make gcc "postgresql-server-dev-${PG_MAJOR_VERSION}" were re-installed for pgvector, purge them too
6553
git \
6654
make \
6755
gcc \
68-
"postgresql-server-dev-${PG_MAJOR_VERSION}" \
56+
"postgresql-server-dev-${PG_MAJOR}" \
6957
wget \
70-
# gnupg might be needed if other repositories are added later, but for now, we can remove it
71-
# if it was only for the postgresql repo key. lsb-release and ca-certificates are generally kept.
7258
&& apt-get clean \
7359
&& rm -rf /var/lib/apt/lists/* \
7460
&& rm -rf /usr/src/pgvector
7561

7662
# Copy initialization scripts
7763
COPY docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
7864

79-
# Default PostgreSQL port
80-
EXPOSE 5432
65+
EXPOSE 5432

0 commit comments

Comments
 (0)