From 07c3d13c815786426f4cd518312ccba74aaf5481 Mon Sep 17 00:00:00 2001 From: Gaspard Wierzbinski Date: Fri, 18 Oct 2024 14:21:18 +0200 Subject: [PATCH] fix: :bug: Overhaul Dockerfile --- Dockerfile | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index ac372ee..f7e4147 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,39 @@ FROM postgres:17-alpine AS env-build -RUN apk add --no-cache build-base postgresql-dev git +# Install build dependencies in Alpine +RUN apk add --no-cache \ + build-base \ + postgresql-dev \ + libpq \ + linux-headers \ + git +# Set working directory and copy files WORKDIR /srv -# Copy contents of https://github.com/fboulnois/pg_uuidv7.git into srv -RUN git clone https://github.com/fboulnois/pg_uuidv7.git . -COPY pg_buildext . +RUN git clone https://github.com/fboulnois/pg_uuidv7.git /srv -# build extension for all supported versions -RUN /bin/sh pg_buildext build-17 17 +# Create directories for each PostgreSQL version to avoid copy errors +RUN for v in `seq 13 17`; do \ + mkdir -p /usr/lib/postgresql/$v/lib; \ + done -# create tarball and checksums -RUN cp sql/pg_uuidv7--1.6.sql . && TARGETS=$(find * -name pg_uuidv7.so) \ - && tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control \ - && sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control > SHA256SUMS +# Build extension for all supported versions +RUN for v in `seq 13 17`; do \ + echo "Building for PostgreSQL version $v"; \ + make USE_PGXS=1; \ + cp pg_uuidv7.so /usr/lib/postgresql/$v/lib/; \ + done + +# Create tarball and checksums +RUN cp sql/pg_uuidv7--1.6.sql . && \ + TARGETS=$(find * -name pg_uuidv7.so) && \ + tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control && \ + sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control > SHA256SUMS FROM postgres:17-alpine AS env-deploy -# copy tarball and checksums -COPY --from=0 /srv/pg_uuidv7.tar.gz /srv/SHA256SUMS /srv/ - -# add extension to postgres -COPY --from=0 /srv/${PG_MAJOR}/pg_uuidv7.so /usr/local/lib/postgresql/pg_uuidv7 +# Add extension to postgres +COPY --from=0 /srv/pg_uuidv7.so /usr/local/lib/postgresql/pg_uuidv7 COPY --from=0 /srv/pg_uuidv7.control /usr/local/share/postgresql/extension COPY --from=0 /srv/pg_uuidv7--1.6.sql /usr/local/share/postgresql/extension