Skip to content

Commit

Permalink
Merge pull request #11 from yettoapp/pgx_ulid-fix
Browse files Browse the repository at this point in the history
Fix how pgx-ulid package is installed
  • Loading branch information
gjtorikian authored Feb 24, 2025
2 parents 50b46e0 + 2f48ddc commit 0ed4158
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.log
14 changes: 10 additions & 4 deletions service/postgres/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ FROM builder AS builder-pgx_ulid

# Download the extension
WORKDIR /tmp
RUN curl -L -o pgx_ulid.deb "https://github.com/pksunkara/pgx_ulid/releases/download/v0.2.0/pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_VERSION_MAJOR}-amd64-linux-gnu.deb"
RUN curl -L -o pgx_ulid.deb "https://github.com/pksunkara/pgx_ulid/releases/download/v${PGX_ULID_VERSION}/pgx_ulid-v${PGX_ULID_VERSION}-pg${PG_VERSION_MAJOR}-amd64-linux-gnu.deb"

###################
# pgvector
Expand All @@ -78,10 +78,16 @@ RUN curl -L -o pgvector.tar.gz "https://github.com/pgvector/pgvector/archive/ref
FROM postgres:${PG_VERSION_MAJOR}-${DEBIAN_VERSION}

ARG PG_VERSION_MAJOR
ARG PGX_ULID_VERSION

# Copy the compiled pgx_ulid extension from the builder stage
COPY --from=builder-pgx_ulid /tmp/pgx_ulid.deb /tmp
RUN dpkg -i /tmp/pgx_ulid.deb && rm /tmp/pgx_ulid.deb
# unsure why but `PGX_ULID_VERSION` is unavailable, so we'll do it the long way
RUN dpkg -i /tmp/pgx_ulid.deb && rm /tmp/pgx_ulid.deb && \
mv /usr/share/postgresql/${PG_VERSION_MAJOR}/extension/ulid.control /usr/share/postgresql/${PG_VERSION_MAJOR}/extension/pgx_ulid.control && \
for file in /usr/share/postgresql/${PG_VERSION_MAJOR}/extension/ulid--*.sql; do \
mv "$file" "/usr/share/postgresql/${PG_VERSION_MAJOR}/extension/pgx_ulid--${file##*--}"; \
done

# Copy the compiled pgvector extension from the builder stage
COPY --from=builder-pgvector /tmp/pgvector*.deb /tmp
Expand All @@ -94,8 +100,8 @@ RUN apt-get autoremove -y && \
rm -rf /tmp

# Configure shared_preload_libraries
RUN echo 'ALTER SYSTEM SET shared_preload_libraries = 'pgx_ulid';\n\
CREATE EXTENSION IF NOT EXISTS ulid;\n' > /docker-entrypoint-initdb.d/01-init.sql
RUN echo "ALTER SYSTEM SET shared_preload_libraries = 'pgx_ulid';\n\
CREATE EXTENSION IF NOT EXISTS pgx_ulid;\n" > /docker-entrypoint-initdb.d/01-init.sql

USER postgres

Expand Down

0 comments on commit 0ed4158

Please sign in to comment.