Closed austinm911 closed 7 months ago
The Dockerfile is mainly for building the code, but I could make it a functional Postgres instance too. In the meantime, you'll probably want to have your own Dockerfile that does something like this:
FROM postgres:15
COPY --from=pg_uuidv7 /srv/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib
COPY --from=pg_uuidv7 /srv/pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension
COPY --from=pg_uuidv7 /srv/pg_uuidv7--1.2.sql /usr/share/postgresql/${PG_MAJOR}/extension
The Dockerfile is mainly for building the code, but I could make it a functional Postgres instance too. In the meantime, you'll probably want to have your own Dockerfile that does something like this:
FROM postgres:15 COPY --from=pg_uuidv7 /srv/pg_uuidv7.so /usr/lib/postgresql/${PG_MAJOR}/lib COPY --from=pg_uuidv7 /srv/pg_uuidv7.control /usr/share/postgresql/${PG_MAJOR}/extension COPY --from=pg_uuidv7 /srv/pg_uuidv7--1.2.sql /usr/share/postgresql/${PG_MAJOR}/extension
Thanks for the reply. I was able to get this working below to make it all work in one step. Still learning docker but now I understand a bit more on using it as a base image. Thanks again
FROM postgres:15-bullseye
# Install packages for building the extension
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y build-essential libpq-dev postgresql-server-dev-all
# Set the working directory and copy source files
WORKDIR /srv
COPY . /srv
# Build the extension
RUN make
# Package the extension and create checksums
RUN tar -czvf pg_uuidv7.tar.gz pg_uuidv7--1.2.sql pg_uuidv7.control pg_uuidv7.so && \
sha256sum pg_uuidv7--1.2.sql pg_uuidv7.control pg_uuidv7.so pg_uuidv7.tar.gz > SHA256SUMS
# Install the extension
RUN cp pg_uuidv7.so /usr/lib/postgresql/15/lib/ && \
cp pg_uuidv7--1.2.sql pg_uuidv7.control /usr/share/postgresql/15/extension/
Makefile
MODULES = pg_uuidv7
EXTENSION = pg_uuidv7
DATA = pg_uuidv7--1.2.sql
PG_CONFIG = /usr/lib/postgresql/15/bin/pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)
If you don't want to modify the Makefile, you could also do the following (assumes you're using v1.3.0 of the extension which now builds for multiple Postgres versions):
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.3.sql /usr/share/postgresql/${PG_MAJOR}/extension
I'll likely set this in a future version of the extension.
I have followed these steps, and I feel I almost got it working, except for this last error when running CREATE EXTENSION pg_uuidv7;
:
ERROR: could not load library "/usr/lib/postgresql/15/lib/pg_uuidv7.so": /usr/lib/postgresql/15/lib/pg_uuidv7.so: cannot open shared object file: No such file or directory
I see the file does exist at this path when I manually go into my container. I have tried to explicitly set permissions to postgres:postgres
but this doesn't seem to help. Do you have any other ideas here? Any help is much appreciated.
This issue is resolved as of v1.4.0.
Hi, I am quite new to docker so please bear with me.
I am trying to create temporary docker containers with testcontainers node to test using vitest my Postgres 15 database. I am using pg_uuidv7 on Neon.tech so trying to replicate the extension.
For example tables in my db are like (defined using drizzle)
I forked the repo and built the image
Started the container
Then I connected to the database using beekeeper and ran the SQL statement
CREATE EXTENSION pg_uuidv7
I am not seeing the pg_uuidv7 files in the container. Not sure if i am missing something or did something wrong. Thanks!