|
1 | 1 | FROM postgres:17-alpine AS env-build
|
2 | 2 |
|
3 |
| -RUN apk add --no-cache build-base postgresql-dev git |
4 |
| - |
| 3 | +# Install build dependencies in Alpine |
| 4 | +RUN apk add --no-cache \ |
| 5 | + build-base \ |
| 6 | + postgresql-dev \ |
| 7 | + libpq \ |
| 8 | + linux-headers \ |
| 9 | + git |
| 10 | + |
| 11 | +# Set working directory and copy files |
5 | 12 | WORKDIR /srv
|
6 |
| -# Copy contents of https://github.com/fboulnois/pg_uuidv7.git into srv |
7 |
| -RUN git clone https://github.com/fboulnois/pg_uuidv7.git . |
8 |
| -COPY pg_buildext . |
9 |
| - |
10 |
| -# build extension for all supported versions |
11 |
| -RUN /bin/sh pg_buildext build-17 17 |
12 |
| - |
13 |
| -# create tarball and checksums |
14 |
| -RUN cp sql/pg_uuidv7--1.6.sql . && TARGETS=$(find * -name pg_uuidv7.so) \ |
15 |
| - && tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control \ |
16 |
| - && sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control > SHA256SUMS |
| 13 | +RUN git clone https://github.com/fboulnois/pg_uuidv7.git /srv |
| 14 | + |
| 15 | +# Create directories for each PostgreSQL version to avoid copy errors |
| 16 | +RUN for v in `seq 13 17`; do \ |
| 17 | + mkdir -p /usr/lib/postgresql/$v/lib; \ |
| 18 | + done |
| 19 | + |
| 20 | +# Build extension for all supported versions |
| 21 | +RUN for v in `seq 13 17`; do \ |
| 22 | + echo "Building for PostgreSQL version $v"; \ |
| 23 | + make USE_PGXS=1; \ |
| 24 | + cp pg_uuidv7.so /usr/lib/postgresql/$v/lib/; \ |
| 25 | + done |
| 26 | + |
| 27 | +# Create tarball and checksums |
| 28 | +RUN cp sql/pg_uuidv7--1.6.sql . && \ |
| 29 | + TARGETS=$(find * -name pg_uuidv7.so) && \ |
| 30 | + tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control && \ |
| 31 | + sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.6.sql pg_uuidv7.control > SHA256SUMS |
17 | 32 |
|
18 | 33 | FROM postgres:17-alpine AS env-deploy
|
19 | 34 |
|
20 |
| -# copy tarball and checksums |
21 |
| -COPY --from=0 /srv/pg_uuidv7.tar.gz /srv/SHA256SUMS /srv/ |
22 |
| - |
23 |
| -# add extension to postgres |
24 |
| -COPY --from=0 /srv/${PG_MAJOR}/pg_uuidv7.so /usr/local/lib/postgresql/pg_uuidv7 |
| 35 | +# Add extension to postgres |
| 36 | +COPY --from=0 /srv/pg_uuidv7.so /usr/local/lib/postgresql/pg_uuidv7 |
25 | 37 | COPY --from=0 /srv/pg_uuidv7.control /usr/local/share/postgresql/extension
|
26 | 38 | COPY --from=0 /srv/pg_uuidv7--1.6.sql /usr/local/share/postgresql/extension
|
27 | 39 |
|
|
0 commit comments