Skip to content

Commit 0903961

Browse files
imordarora
authored andcommitted
chore: compile pg_jsonschema from source for OrioleDb Dockerfile
1 parent 1237e64 commit 0903961

File tree

1 file changed

+56
-6
lines changed

1 file changed

+56
-6
lines changed

docker/orioledb/Dockerfile

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ARG libsodium_release=1.0.18
2626
ARG pgsodium_release=3.1.6
2727
ARG pg_graphql_release=1.4.2
2828
ARG pg_stat_monitor_release=1.1.1
29-
ARG pg_jsonschema_release=0.1.4
29+
ARG pg_jsonschema_release=0.2.0
3030
ARG vault_release=0.2.8
3131
ARG groonga_release=12.0.8
3232
ARG pgroonga_release=2.4.0
@@ -574,6 +574,7 @@ RUN ls -al target/release
574574
RUN mkdir archive
575575
RUN cp target/release/pg_graphql-pg${postgresql_major}/usr/local/share/postgresql/extension/pg_graphql* archive
576576
RUN cp target/release/pg_graphql-pg${postgresql_major}/usr/local/lib/postgresql/pg_graphql.so archive
577+
577578
# name of the package directory before packaging
578579
ENV package_dir=pg_graphql-v${pg_graphql_release}-pg${postgresql_major}-${TARGETARCH}-linux-gnu
579580

@@ -638,11 +639,60 @@ RUN checkinstall -D --install=no --fstrans=no --backup=no --pakdir=/tmp --nodoc
638639
####################
639640
# 22-pg_jsonschema.yml
640641
####################
641-
FROM base as pg_jsonschema
642-
# Download package archive
642+
FROM rust-toolchain as pg_jsonschema-source
643+
# Download and extract
643644
ARG pg_jsonschema_release
644-
ADD "https://github.com/supabase/pg_jsonschema/releases/download/v${pg_jsonschema_release}/pg_jsonschema-v${pg_jsonschema_release}-pg${postgresql_major}-${TARGETARCH}-linux-gnu.deb" \
645-
/tmp/pg_jsonschema.deb
645+
ARG pg_jsonschema_release_checksum
646+
ADD --checksum=${pg_jsonschema_release_checksum} \
647+
"https://github.com/supabase/pg_jsonschema/archive/refs/tags/v${pg_jsonschema_release}.tar.gz" \
648+
/tmp/pg_jsonschema.tar.gz
649+
RUN tar -xvf /tmp/pg_jsonschema.tar.gz -C /tmp && \
650+
rm -rf /tmp/pg_jsonschema.tar.gz
651+
WORKDIR /tmp/pg_jsonschema-${pg_jsonschema_release}
652+
RUN cargo pgrx package --no-default-features --features pg${postgresql_major}
653+
654+
# Create installable package
655+
RUN mkdir archive
656+
RUN cp target/release/pg_jsonschema-pg${postgresql_major}/usr/local/share/postgresql/extension/pg_jsonschema* archive
657+
RUN cp target/release/pg_jsonschema-pg${postgresql_major}/usr/local/lib/postgresql/pg_jsonschema.so archive
658+
RUN ls -al archive
659+
660+
# name of the package directory before packaging
661+
ENV package_dir=pg_jsonschema-v${pg_jsonschema_release}-pg${postgresql_major}-${TARGETARCH}-linux-gnu
662+
663+
## Copy files into directory structure
664+
RUN mkdir -p ${package_dir}/usr/lib/postgresql/lib
665+
RUN mkdir -p ${package_dir}/var/lib/postgresql/extension
666+
RUN cp archive/*.so ${package_dir}/usr/lib/postgresql/lib
667+
RUN cp archive/*.control ${package_dir}/var/lib/postgresql/extension
668+
RUN cp archive/*.sql ${package_dir}/var/lib/postgresql/extension
669+
670+
# symlinks to Copy files into directory structure
671+
RUN mkdir -p ${package_dir}/usr/lib/postgresql/${postgresql_major}/lib
672+
WORKDIR ${package_dir}/usr/lib/postgresql/${postgresql_major}/lib
673+
RUN cp -s ../../lib/*.so .
674+
WORKDIR ../../../../../..
675+
676+
RUN mkdir -p ${package_dir}/usr/share/postgresql/${postgresql_major}/extension
677+
WORKDIR ${package_dir}/usr/share/postgresql/${postgresql_major}/extension
678+
679+
RUN cp -s ../../../../../var/lib/postgresql/extension/pg_jsonschema.control .
680+
RUN cp -s ../../../../../var/lib/postgresql/extension/pg_jsonschema*.sql .
681+
WORKDIR ../../../../../..
682+
683+
RUN mkdir -p ${package_dir}/DEBIAN
684+
RUN touch ${package_dir}/DEBIAN/control
685+
RUN echo 'Package: pg-jsonschema' >> ${package_dir}/DEBIAN/control
686+
RUN echo 'Version:' ${pg_jsonschema_release} >> ${package_dir}/DEBIAN/control
687+
RUN echo "Architecture: ${TARGETARCH}" >> ${package_dir}/DEBIAN/control
688+
RUN echo 'Maintainer: supabase' >> ${package_dir}/DEBIAN/control
689+
RUN echo 'Description: A PostgreSQL extension' >> ${package_dir}/DEBIAN/control
690+
691+
# Create deb package
692+
RUN chown -R root:root ${package_dir}
693+
RUN chmod -R 00755 ${package_dir}
694+
RUN dpkg-deb --build --root-owner-group ${package_dir}
695+
RUN cp ./*.deb /tmp/pg_jsonschema.deb
646696

647697
####################
648698
# 23-vault.yml
@@ -869,7 +919,7 @@ COPY --from=pgsodium-source /tmp/*.deb /tmp/
869919
COPY --from=pg_hashids-source /tmp/*.deb /tmp/
870920
COPY --from=pg_graphql-source /tmp/*.deb /tmp/
871921
COPY --from=pg_stat_monitor-source /tmp/*.deb /tmp/
872-
COPY --from=pg_jsonschema /tmp/*.deb /tmp/
922+
COPY --from=pg_jsonschema-source /tmp/*.deb /tmp/
873923
COPY --from=vault-source /tmp/*.deb /tmp/
874924
COPY --from=pgroonga-source /tmp/*.deb /tmp/
875925
COPY --from=wrappers /tmp/*.deb /tmp/

0 commit comments

Comments
 (0)