1+ # Build stage - extract extension files from .deb package
2+ FROM ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie AS builder
3+
4+ ARG PG_MAJOR=18
5+ ARG EXT_VERSION=2.0.0
6+
7+ USER 0
8+
9+ RUN set -eux; \
10+ ARCH=$(dpkg --print-architecture); \
11+ mkdir -p /extension-build && \
12+ apt-get update && \
13+ apt-get install -y --no-install-recommends wget ca-certificates && \
14+ cd /tmp && \
15+ DOWNLOAD_URL="https://github.com/pmpetit/pglinter/releases/download/${EXT_VERSION}/postgresql_pglinter_${PG_MAJOR}_${EXT_VERSION}_${ARCH}.deb" && \
16+ echo "Downloading pglinter from: $DOWNLOAD_URL" && \
17+ wget -O pglinter.deb "$DOWNLOAD_URL" && \
18+ dpkg-deb -x pglinter.deb /tmp/extracted && \
19+ echo "Contents of extracted package:" && \
20+ find /tmp/extracted -type f && \
21+ # Create CloudNative-PG compliant directory structure
22+ mkdir -p /extension-build/lib /extension-build/share/extension && \
23+ # Copy shared libraries (.so files)
24+ if [ -d /tmp/extracted/usr/lib/postgresql/${PG_MAJOR}/lib ]; then \
25+ echo "Copying libraries from /usr/lib/postgresql/${PG_MAJOR}/lib/" ; \
26+ find /tmp/extracted/usr/lib/postgresql/${PG_MAJOR}/lib/ -name "*.so" -exec cp {} /extension-build/lib/ \; ; \
27+ fi && \
28+ # Copy extension control and SQL files
29+ if [ -d /tmp/extracted/usr/share/postgresql/${PG_MAJOR}/extension ]; then \
30+ echo "Copying extension files from /usr/share/postgresql/${PG_MAJOR}/extension/" ; \
31+ cp /tmp/extracted/usr/share/postgresql/${PG_MAJOR}/extension/* /extension-build/share/extension/ ; \
32+ fi && \
33+ echo "Final extension structure:" && \
34+ find /extension-build -type f
35+
36+ FROM scratch
37+ ARG PG_MAJOR=18
38+
39+ # Final image - scratch base following CloudNative-PG specifications
40+ # Licenses
41+ COPY copyright /licenses/postgresql-${PG_MAJOR}-pglinter/
42+
43+ COPY --from=builder /extension-build/lib/ /lib/
44+ COPY --from=builder /extension-build/share/ /share/
45+
46+ # Share
47+ COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/pglinter* /share/extension/
48+
49+ USER 65532:65532
0 commit comments