From 1e786d8da7bfcd54d905b05f455e0250758ab282 Mon Sep 17 00:00:00 2001 From: Rory de Zoete Date: Thu, 18 Aug 2022 12:47:01 +0200 Subject: [PATCH] Add postgis & plv8 extensions --- .github/workflows/build_and_test.yml | 14 +++++++ Dockerfile.compute-node | 60 ++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 Dockerfile.compute-node diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index dab34c84bc..706edd746e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -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 diff --git a/Dockerfile.compute-node b/Dockerfile.compute-node new file mode 100644 index 0000000000..1f699bfdaa --- /dev/null +++ b/Dockerfile.compute-node @@ -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"] \ No newline at end of file