pg_orrery/Dockerfile
Ryan Malloy 07bc4e47c6 Add Docker packaging for pg_orbit extension
Three-stage Dockerfile: Ubuntu 22.04 builder (glibc-matched to
TimescaleDB-HA), scratch artifact image (~748KB), and standalone
postgres:17 image. All 6 regression suites run during build.
Makefile gains docker-build, docker-push, and docker-test targets.
2026-02-16 00:16:16 -07:00

64 lines
2.5 KiB
Docker

ARG PG_MAJOR=17
# ── Stage 1: Compile against PostgreSQL on Ubuntu 22.04 ─────
# Ubuntu Jammy matches TimescaleDB-HA's glibc (2.35).
# Building on Debian Bookworm (glibc 2.36) risks symbol version
# mismatches when the .so loads in TimescaleDB's runtime.
FROM ubuntu:22.04 AS builder
ARG PG_MAJOR
ARG DEBIAN_FRONTEND=noninteractive
# PGDG apt repository (same source TimescaleDB-HA uses)
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl gnupg lsb-release && \
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor -o /usr/share/keyrings/postgresql.gpg && \
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] \
http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list && \
apt-get update && apt-get install -y --no-install-recommends \
postgresql-${PG_MAJOR} \
postgresql-server-dev-${PG_MAJOR} \
gcc g++ make && \
rm -rf /var/lib/apt/lists/*
# Copy source tree (submodule content included as regular files)
WORKDIR /build/pg_orbit
COPY . .
ENV PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR}/bin/pg_config
# Build extension
RUN make PG_CONFIG=${PG_CONFIG}
# Install to system location (needed for installcheck)
RUN make PG_CONFIG=${PG_CONFIG} install
# Run all 6 regression test suites against a throwaway cluster
RUN su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/initdb -D /tmp/pgtest" && \
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /tmp/pgtest -l /tmp/pgtest.log start" && \
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/createuser -s root" && \
make PG_CONFIG=${PG_CONFIG} installcheck && \
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /tmp/pgtest stop"
# Capture artifacts under /pg_orbit prefix for the next stage
RUN make PG_CONFIG=${PG_CONFIG} DESTDIR=/pg_orbit install
# ── Stage 2: Minimal artifact (COPY --from target) ──────────
# ~525 KB total: .so + .control + .sql + init script.
# Downstream images (TimescaleDB-HA, vanilla PG) pull from here.
FROM scratch AS artifact
COPY --from=builder /pg_orbit/ /
COPY docker/020_install_pg_orbit.sh /docker-entrypoint-initdb.d/
# ── Stage 3: Standalone dev/test image ───────────────────────
# Ready-to-run PostgreSQL with pg_orbit pre-installed.
# For development, CI, and standalone experiments.
FROM postgres:${PG_MAJOR}-bookworm AS standalone
COPY --from=artifact / /