Skip to content

Commit a8c31e0

Browse files
authored
Update Dockerfile
1 parent 6b0daeb commit a8c31e0

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

Dockerfile

+24-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
FROM postgres:16-alpine
1+
FROM postgres:16-alpine AS env-build
22

3-
RUN apk update && apk add git build-base postgresql-dev
4-
RUN postgres --version
5-
RUN git clone https://github.com/fboulnois/pg_uuidv7
6-
RUN cd pg_uuidv7 && make && make install && ls -la
3+
# install build dependencies
4+
RUN apk update && apk upgrade \
5+
&& apk add build-base postgresql-dev
76

8-
COPY ./init.sql /docker-entrypoint-initdb.d/init.sql
7+
WORKDIR /srv
8+
COPY . /srv
9+
10+
# build extension for P16
11+
RUN pg_buildext build-16 16
12+
13+
# create tarball and checksums
14+
RUN cp sql/pg_uuidv7--1.5.sql . && TARGETS=$(find * -name pg_uuidv7.so) \
15+
&& tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.5.sql pg_uuidv7.control \
16+
&& sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.5.sql pg_uuidv7.control > SHA256SUMS
17+
18+
FROM postgres:16-alpine AS env-deploy
19+
20+
# copy tarball and checksums
21+
COPY --from=env-build /srv/pg_uuidv7.tar.gz /srv/SHA256SUMS /srv/
22+
23+
# add extension to postgres
24+
COPY --from=env-build /srv/${PG_MAJOR}/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib
25+
COPY --from=env-build /srv/pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension
26+
COPY --from=env-build /srv/pg_uuidv7--1.5.sql /usr/share/postgresql/${PG_MAJOR}/extension
927

1028
# Add a script to run the CREATE EXTENSION command
1129
RUN printf '#!/bin/sh\npsql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "CREATE EXTENSION pg_uuidv7;"' > /docker-entrypoint-initdb.d/init.sh

0 commit comments

Comments
 (0)