fix: 🐛 Overhaul Dockerfile

This commit is contained in:
Gaspard Wierzbinski 2024-10-18 14:21:18 +02:00 committed by GitHub
parent 9608950c60
commit 07c3d13c81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,27 +1,39 @@
FROM postgres:17-alpine AS env-build 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 WORKDIR /srv
# Copy contents of https://github.com/fboulnois/pg_uuidv7.git into srv RUN git clone https://github.com/fboulnois/pg_uuidv7.git /srv
RUN git clone https://github.com/fboulnois/pg_uuidv7.git .
COPY pg_buildext .
# build extension for all supported versions # Create directories for each PostgreSQL version to avoid copy errors
RUN /bin/sh pg_buildext build-17 17 RUN for v in `seq 13 17`; do \
mkdir -p /usr/lib/postgresql/$v/lib; \
done
# create tarball and checksums # Build extension for all supported versions
RUN cp sql/pg_uuidv7--1.6.sql . && TARGETS=$(find * -name pg_uuidv7.so) \ RUN for v in `seq 13 17`; do \
&& tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control \ echo "Building for PostgreSQL version $v"; \
&& sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control > SHA256SUMS 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 FROM postgres:17-alpine AS env-deploy
# copy tarball and checksums # Add extension to postgres
COPY --from=0 /srv/pg_uuidv7.tar.gz /srv/SHA256SUMS /srv/ COPY --from=0 /srv/pg_uuidv7.so /usr/local/lib/postgresql/pg_uuidv7
# add extension to postgres
COPY --from=0 /srv/${PG_MAJOR}/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.control /usr/local/share/postgresql/extension
COPY --from=0 /srv/pg_uuidv7--1.6.sql /usr/local/share/postgresql/extension COPY --from=0 /srv/pg_uuidv7--1.6.sql /usr/local/share/postgresql/extension