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"]