Files
postgres-ts-vectors/Dockerfile
Maxime Killinger cb58167e53
Some checks failed
🚀 Docker Build and Push / build-and-push (15) (push) Successful in 7m47s
🚀 Docker Build and Push / build-and-push (16) (push) Successful in 5m42s
🚀 Docker Build and Push / build-and-push (18) (push) Has been cancelled
🚀 Docker Build and Push / build-and-push (17) (push) Has been cancelled
feat: PostgreSQL image with TimescaleDB, VectorChord, pgvector
- Multi-stage Dockerfile for optimized image size (676MB vs 2GB)
- Support for PostgreSQL 15, 16, 17, 18
- TimescaleDB 2.24.0, VectorChord 1.0.0, pgvector 0.8.1
- Auto-creation of extensions on first startup
- CI/CD with tests for all versions
- OCI labels and healthcheck included
2025-12-19 11:57:54 +01:00

57 lines
2.3 KiB
Docker

# syntax=docker/dockerfile:1
ARG PG_VERSION=18
# =============================================================================
# Builder stage - Compile TimescaleDB
# =============================================================================
FROM tensorchord/vchord-postgres:pg${PG_VERSION}-v1.0.0 AS builder
USER root
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
cmake \
libssl-dev \
libkrb5-dev \
postgresql-server-dev-$PG_MAJOR \
&& rm -rf /var/lib/apt/lists/*
# Build TimescaleDB from source (stable release)
ARG TIMESCALEDB_VERSION=2.24.0
WORKDIR /build/timescaledb
RUN git clone --branch ${TIMESCALEDB_VERSION} --depth 1 https://github.com/timescale/timescaledb.git . \
&& ./bootstrap -DREGRESS_CHECKS=OFF -DWARNINGS_AS_ERRORS=OFF \
&& cd build && make -j$(nproc) && make install DESTDIR=/tmp/timescaledb
# =============================================================================
# Final stage - Clean runtime image
# =============================================================================
FROM tensorchord/vchord-postgres:pg${PG_VERSION}-v1.0.0 AS final
# OCI Labels
LABEL org.opencontainers.image.title="TimescaleDB + VectorChord + pgvector"
LABEL org.opencontainers.image.description="PostgreSQL with TimescaleDB, VectorChord, and pgvector extensions pre-installed"
LABEL org.opencontainers.image.source="https://gitea.killinger.fr/maxime.killinger/postgres-ts-vectors"
LABEL org.opencontainers.image.vendor="Maxime Killinger"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.base.name="tensorchord/vchord-postgres:pg${PG_VERSION}-v1.0.0"
# Copy TimescaleDB from builder
COPY --from=builder /tmp/timescaledb/usr/lib/postgresql/ /usr/lib/postgresql/
COPY --from=builder /tmp/timescaledb/usr/share/postgresql/ /usr/share/postgresql/
# Add init script for auto-extension creation
COPY init-extensions.sh /docker-entrypoint-initdb.d/
RUN chmod +x /docker-entrypoint-initdb.d/init-extensions.sh
# Healthcheck
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
CMD pg_isready -U postgres || exit 1
USER postgres
# Preload required libraries
CMD ["postgres", "-c", "shared_preload_libraries=timescaledb,vchord"]