Skip to content

Commit 07c3d13

Browse files
authored
fix: 🐛 Overhaul Dockerfile
1 parent 9608950 commit 07c3d13

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

Dockerfile

+30-18
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
FROM postgres:17-alpine AS env-build
22

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
512
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
1732

1833
FROM postgres:17-alpine AS env-deploy
1934

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
2537
COPY --from=0 /srv/pg_uuidv7.control /usr/local/share/postgresql/extension
2638
COPY --from=0 /srv/pg_uuidv7--1.6.sql /usr/local/share/postgresql/extension
2739

0 commit comments

Comments
 (0)