Skip to content

Commit 7d25e69

Browse files
committed
Switch to Alpine and reduce file size
1 parent a528966 commit 7d25e69

File tree

2 files changed

+490
-5
lines changed

2 files changed

+490
-5
lines changed

Dockerfile

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
FROM postgres:16
1+
FROM postgres:16-alpine AS env-build
22

3-
RUN apt-get update && apt-get -y install git build-essential postgresql-server-dev-16
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+
RUN apk add --no-cache build-base postgresql-dev git
4+
5+
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-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=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
25+
COPY --from=0 /srv/pg_uuidv7.control /usr/local/share/postgresql/extension
26+
COPY --from=0 /srv/pg_uuidv7--1.5.sql /usr/local/share/postgresql/extension
727

828
# Add a script to run the CREATE EXTENSION command
929
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)