DBIO-PostgreSQL-EV
view release on metacpan or search on metacpan
maint/docker/Dockerfile.test view on Meta::CPAN
# dbio-async-test
#
# Run a single file (proves the env wiring works end-to-end):
# docker run --rm -e DBIO_TEST_PG_DSN=... dbio-async-test -lv t/21-deploy-async-live.t
#
# The image is the CLIENT only. PostgreSQL itself stays wherever the caller
# wants it: docker run of postgres:17, k8s (maint/k8s/pg-pod.yaml), a system
# install, or a managed service. The image's job is to make EV::Pg resolve
# cleanly under PERL_DL_NONLAZY=1.
# ---------------------------------------------------------------------------
# Stage 1 â extract libpq from postgres:17-bookworm
# ---------------------------------------------------------------------------
FROM postgres:17-bookworm AS libpq-source
# The postgres:* images ship only the runtime libpq.so; the C headers and
# the pkg-config stub are NOT included. Install libpq-dev here so EV::Pg's
# XS build can find libpq-fe.h when Stage 2 cpanm's it.
#
# Note on version: the PGDG bookworm repo currently ships libpq 18.x even
# under the postgres:17 image. libpq's ABI is stable across major versions
# (every PG release ships libpq.so.5 with the same SO-version), so libpq.so.5
# from this image satisfies EV::Pg >= 0.07's symbol requirements
# (PQconnectionUsedGSSAPI, PGRES_TUPLES_CHUNK) cleanly.
RUN apt-get update \
&& apt-get install -y --no-install-recommends libpq-dev pkg-config \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /libpq-out/usr/lib /libpq-out/usr/include /libpq-out/usr/lib/pkgconfig /libpq-out/usr/bin \
&& cp -a /usr/lib/x86_64-linux-gnu/libpq.so* /libpq-out/usr/lib/ \
&& cp -a /usr/include/postgresql /libpq-out/usr/include/ \
&& cp -a /usr/lib/x86_64-linux-gnu/pkgconfig/libpq.pc /libpq-out/usr/lib/pkgconfig/ \
&& cp -a /usr/lib/postgresql/*/bin/pg_config /libpq-out/usr/bin/
# ---------------------------------------------------------------------------
# Stage 2 â slim Debian + the libpq 17 we just lifted + Perl + EV::Pg
# ---------------------------------------------------------------------------
FROM debian:bookworm-slim
# Install the libpq 17 we pulled from postgres:17-bookworm. /usr/local/lib
# comes ahead of /usr/lib/x86_64-linux-gnu on the loader path, so even if
# bookworm ever ships libpq 16 in the future, ours wins.
#
# /usr/local/{include,lib} are the canonical prefixes for hand-installed
# libraries, but several Perl XS modules (DBD::Pg in particular) hard-code
# the system paths /usr/include/postgresql and /usr/lib/x86_64-linux-gnu
# in their Configure scripts and refuse to look anywhere else. We symlink
# our copies into those locations so the hard-coded paths find libpq 17.
COPY --from=libpq-source /libpq-out/usr/lib/ /usr/local/lib/
COPY --from=libpq-source /libpq-out/usr/include/ /usr/local/include/
COPY --from=libpq-source /libpq-out/usr/lib/pkgconfig/ /usr/local/lib/pkgconfig/
COPY --from=libpq-source /libpq-out/usr/bin/ /usr/local/bin/
RUN ldconfig \
&& ln -s /usr/local/include/postgresql /usr/include/postgresql \
&& for f in /usr/local/lib/libpq.so*; do \
ln -sf "$f" "/usr/lib/x86_64-linux-gnu/$(basename "$f")"; \
done
# Perl + cpanm + the XS build chain + libldap (a runtime dep of libpq 17;
# EV::Pg's XS module dynamically links it for the LDAP authentication path,
# so it must be present even though our tests never authenticate via LDAP).
# ssl-dev is needed by several of the CPAN deps (Net::SSLeay, IO::Socket::SSL,
# etc.).
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
perl \
cpanminus \
build-essential \
pkg-config \
libssl-dev \
libldap-2.5-0 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Tell pkg-config and the EV::Pg build where to find libpq 17.
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
WORKDIR /src
# Copy cpanfile + the rest of the source in one shot so cpanm --installdeps
# can resolve the distribution's runtime + test deps from the same tree.
COPY cpanfile dist.ini ./
COPY lib/ ./lib/
COPY t/ ./t/
COPY demo/ ./demo/
COPY maint/ ./maint/
# Distribution deps. We do NOT use `cpanm --installdeps /src` here on
# purpose: cpanfile pins EV::Pg < 0.03 (the verified line on libpq 15) but
# we deliberately install EV::Pg@0.07 to match the libpq we shipped in
# this image. --installdeps would see the mismatch and try to downgrade.
# Instead we install each dep explicitly at the version we want, and rely
# on cpanm's transitive resolution to pull EV, Future, Moo, SQL::Abstract,
# Test::More, Test::Exception via the dependencies below. See README for
# the cpanfile TODO.
#
# Order matters: install DBIO::PostgreSQL FIRST so its own test deps
# (which include DBD::Pg) never enter cpanm's resolution path for /src.
# Distribution deps. We do NOT use `cpanm --installdeps /src` here on
# purpose: cpanfile pins EV::Pg < 0.03 (the verified line on libpq 15) but
# we deliberately install EV::Pg@0.07 to match the libpq we shipped in
# this image. --installdeps would see the mismatch and try to downgrade.
# Instead we install each dep explicitly at the version we want, and rely
# on cpanm's transitive resolution to pull EV, Future, Moo, SQL::Abstract,
# Test::More, Test::Exception via the dependencies below. See README for
# the cpanfile TODO.
#
# Order matters: install DBIO::PostgreSQL FIRST so its own test deps
# (which include DBD::Pg) never enter cpanm's resolution path for /src.
#
# The wide dep list mirrors DBIO's transitive requirements. Listing them
# explicitly is verbose but makes the image self-contained and survives
# cpanfile changes -- new dependencies added to dbio-postgresql-ev
# are caught by the test run itself (missing-module errors are obvious),
# rather than silently breaking the image build.
RUN cpanm --notest DBIO::PostgreSQL \
&& cpanm --notest EV::Pg@0.07 \
&& cpanm --notest \
Test::More Test::Exception Test::Deep Test::FailWarnings Test::Fatal \
Test::LeakTrace Test::Memory::Cycle Test::MockObject Test::Needs \
Test::NoWarnings Test::Output Test::Requires Test::SubCalls \
Test::Warn \
( run in 1.511 second using v1.01-cache-2.11-cpan-6aa56a78535 )