Skip to content

Commit

Permalink
fix: split into build and deploy stages
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Dec 15, 2023
1 parent 06e19e8 commit 45b0c4f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
FROM postgres:16
FROM postgres:16 AS env-build

# install build dependencies
RUN apt-get update && apt-get -y upgrade \
&& apt-get install -y build-essential libpq-dev postgresql-server-dev-all

WORKDIR /srv
COPY . /srv

# build extension for all supported versions
RUN for v in `seq 13 16`; do pg_buildext build-$v $v; done

# create tarball and checksums
RUN cp sql/pg_uuidv7--1.4.sql . && TARGETS=$(find * -name pg_uuidv7.so) \
&& tar -czvf pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.4.sql pg_uuidv7.control \
&& sha256sum pg_uuidv7.tar.gz $TARGETS pg_uuidv7--1.4.sql pg_uuidv7.control > SHA256SUMS

RUN cp ${PG_MAJOR}/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib \
&& cp pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension \
&& cp pg_uuidv7--1.4.sql /usr/share/postgresql/${PG_MAJOR}/extension
FROM postgres:16 AS env-deploy

# copy tarball and checksums
COPY --from=0 /srv/pg_uuidv7.tar.gz /srv/SHA256SUMS /srv

# add extension to postgres
COPY --from=0 /srv/${PG_MAJOR}/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib
COPY --from=0 /srv/pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension
COPY --from=0 /srv/pg_uuidv7--1.4.sql /usr/share/postgresql/${PG_MAJOR}/extension

0 comments on commit 45b0c4f

Please sign in to comment.