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 "
1413LABEL 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
2318RUN 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
4335RUN 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
5042RUN 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
6251RUN 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
7763COPY docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
7864
79- # Default PostgreSQL port
80- EXPOSE 5432
65+ EXPOSE 5432
0 commit comments