Add postgis & plv8 extensions

This commit is contained in:
Rory de Zoete
2022-08-18 12:47:01 +02:00
parent 4013290508
commit 1e786d8da7
2 changed files with 74 additions and 0 deletions

View File

@@ -469,6 +469,20 @@ jobs:
- name: Kaniko build compute tools
run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --dockerfile Dockerfile.compute-tools --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-tools:$GITHUB_RUN_ID
compute-node-image-ext:
runs-on: dev
container: gcr.io/kaniko-project/executor:v1.9.0-debug
steps:
- name: Checkout
uses: actions/checkout@v1 # v3 won't work with kaniko
- name: Configure ECR login
run: echo "{\"credsStore\":\"ecr-login\"}" > /kaniko/.docker/config.json
- name: Kaniko build compute tools
run: /kaniko/executor --snapshotMode=redo --cache=true --cache-repo 369495373322.dkr.ecr.eu-central-1.amazonaws.com/cache --snapshotMode=redo --context . --dockerfile Dockerfile.compute-node --destination 369495373322.dkr.ecr.eu-central-1.amazonaws.com/compute-node:$GITHUB_RUN_ID-ext
compute-node-image:
runs-on: dev
container: gcr.io/kaniko-project/executor:v1.9.0-debug

60
Dockerfile.compute-node Normal file
View File

@@ -0,0 +1,60 @@
ARG COMPUTE_TOOLS_TAG=latest
FROM debian:bullseye-slim AS build-deps
RUN apt update && \
apt install -y git automake libtool build-essential bison flex libreadline-dev zlib1g-dev libxml2-dev \
libcurl4-openssl-dev libossp-uuid-dev
# Build Postgres from the neon postgres repository.
FROM build-deps AS pg-build
RUN git clone -b main https://github.com/neondatabase/postgres.git postgres && \
cd postgres && \
./configure CFLAGS='-O2 -g3' --enable-debug --with-uuid=ossp && \
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s install && \
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C contrib/ install && \
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C contrib/neon install && \
# Install headers
make MAKELEVEL=0 -j $(getconf _NPROCESSORS_ONLN) -s -C src/include install
# Build PostGIS from upstream the upstream PostGIS mirror. PostGIS compiles against neon postgres sources without changes.
# Perhaps we could even use the upstream binaries, compiled against vanilla Postgres, but it would require some
# investigation to check that it works, and also keeps working in the future. So for now, we compile our own binaries.
FROM build-deps AS postgis-build
COPY --from=pg-build /usr/local/pgsql/ /usr/local/pgsql/
RUN apt update && \
apt install -y gdal-bin libgdal-dev libprotobuf-c-dev protobuf-c-compiler
RUN git clone -b stable-3.2 https://github.com/postgis/postgis.git postgis && \
cd postgis && \
./autogen.sh && \
export PATH="/usr/local/pgsql/bin:$PATH" && \
./configure && \
make -j $(getconf _NPROCESSORS_ONLN) install
# Compile and run the Neon-specific `compute_ctl` binary
FROM 369495373322.dkr.ecr.eu-central-1.amazonaws.com/rust:$COMPUTE_TOOLS_TAG AS compute-tools
COPY compute_tools compute_tools
COPY workspace_hack workspace_hack
RUN cd compute_tools && cargo build --release
# Put it all together into the final image
FROM debian:bullseye-slim
RUN apt update && \
apt install -y libreadline-dev libossp-uuid-dev
# Add user postgres
RUN mkdir /var/db && useradd -m -d /var/db/postgres postgres && \
echo "postgres:test_console_pass" | chpasswd && \
mkdir /var/db/postgres/compute && mkdir /var/db/postgres/specs && \
chown -R postgres:postgres /var/db/postgres && \
chmod 0750 /var/db/postgres/compute
RUN echo '/usr/local/lib' >> /etc/ld.so.conf && /sbin/ldconfig
#COPY --from=pg-build /usr/local/pgsql /usr/local/pgsql
COPY --from=postgis-build /usr/local/pgsql /usr/local/pgsql
COPY --from=compute-tools /home/nonroot/compute_tools/target/release/compute_ctl /usr/local/bin/compute_ctl
USER postgres
ENTRYPOINT ["/usr/local/bin/compute_ctl"]