-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
45 lines (36 loc) · 1.5 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
FROM postgres:17-alpine AS env-build
# 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
RUN git clone https://github.com/fboulnois/pg_uuidv7.git /srv
# 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
# 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
# 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
# Add a script to run the CREATE EXTENSION command
RUN printf '#!/bin/sh\npsql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_uuidv7;"' > /docker-entrypoint-initdb.d/init.sh
# Make the entrypoint script executable
RUN chmod +x /docker-entrypoint-initdb.d/init.sh
CMD ["postgres"]