diff --git a/Dockerfile.compute-node b/Dockerfile.compute-node index 1d6c2f354f..2f34f6dc15 100644 --- a/Dockerfile.compute-node +++ b/Dockerfile.compute-node @@ -1,3 +1,4 @@ +ARG PG_VERSION ARG REPOSITORY=369495373322.dkr.ecr.eu-central-1.amazonaws.com ARG IMAGE=rust ARG TAG=pinned @@ -180,6 +181,62 @@ RUN wget https://github.com/michelp/pgjwt/archive/9742dab1b2f297ad3811120db7b214 make -j $(getconf _NPROCESSORS_ONLN) install PG_CONFIG=/usr/local/pgsql/bin/pg_config && \ echo 'trusted = true' >> /usr/local/pgsql/share/extension/pgjwt.control +######################################################################################### +# +# Layer "rust extensions" +# This layer is used to build `pgx` deps +# +######################################################################################### +FROM build-deps AS rust-extensions-build +COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/ + +RUN apt-get update && \ + apt-get install -y curl libclang-dev cmake && \ + useradd -ms /bin/bash nonroot -b /home + +ENV HOME=/home/nonroot +ENV PATH="/home/nonroot/.cargo/bin:/usr/local/pgsql/bin/:$PATH" +USER nonroot +WORKDIR /home/nonroot +ARG PG_VERSION + +RUN curl -sSO https://static.rust-lang.org/rustup/dist/$(uname -m)-unknown-linux-gnu/rustup-init && \ + chmod +x rustup-init && \ + ./rustup-init -y --no-modify-path --profile minimal --default-toolchain stable && \ + rm rustup-init && \ + cargo install --git https://github.com/vadim2404/pgx --branch neon_abi_v0.6.1 --locked cargo-pgx && \ + /bin/bash -c 'cargo pgx init --pg${PG_VERSION:1}=/usr/local/pgsql/bin/pg_config' + +USER root + +######################################################################################### +# +# Layer "pg-jsonschema-pg-build" +# Compile "pg_jsonschema" extension +# +######################################################################################### + +FROM rust-extensions-build AS pg-jsonschema-pg-build + +RUN git clone --depth=1 --single-branch --branch neon_abi_v0.1.4 https://github.com/vadim2404/pg_jsonschema/ && \ + cd pg_jsonschema && \ + cargo pgx install --release && \ + echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_jsonschema.control + +######################################################################################### +# +# Layer "pg-graphql-pg-build" +# Compile "pg_graphql" extension +# +######################################################################################### + +FROM rust-extensions-build AS pg-graphql-pg-build + +RUN git clone --depth=1 --single-branch --branch neon_abi_v1.1.0 https://github.com/vadim2404/pg_graphql && \ + cd pg_graphql && \ + cargo pgx install --release && \ + echo "trusted = true" >> /usr/local/pgsql/share/extension/pg_graphql.control + ######################################################################################### # # Layer "neon-pg-ext-build" @@ -195,6 +252,8 @@ COPY --from=h3-pg-build /h3/usr / COPY --from=unit-pg-build /usr/local/pgsql/ /usr/local/pgsql/ COPY --from=vector-pg-build /usr/local/pgsql/ /usr/local/pgsql/ COPY --from=pgjwt-pg-build /usr/local/pgsql/ /usr/local/pgsql/ +COPY --from=pg-jsonschema-pg-build /usr/local/pgsql/ /usr/local/pgsql/ +COPY --from=pg-graphql-pg-build /usr/local/pgsql/ /usr/local/pgsql/ COPY pgxn/ pgxn/ RUN make -j $(getconf _NPROCESSORS_ONLN) \