Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions deployment/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,64 +27,74 @@ The PostgresQL docker will be build in multiple steps:
- Step 2: Build the [PLV8 extension](./naksha-pg-2-plv8)
- Step 3: Build other [miscellaneous extensions](./naksha-pg-3-misc) like GZIP
- Step 4: Build [PL/Java extension](./naksha-pg-4-pljava), which is experimental for now
- Step 5: Build the [release](./naksha-pg-release) that contains configuration and start script, we do it as a standalone step, because this allows easily to change the configuration of the PostgresQL database without the need to compile anything again.
- Step 5: Build [PL/Rust extension](./naksha-pg-5-plrust)
- Step 6: Build the [release](./naksha-pg-release) that contains configuration and start script, we do it as a standalone step, because this allows easily to change the configuration of the PostgresQL database without the need to compile anything again.

### Build
The Naksha PostgresQL image is build in steps, follow these instructions:

```bash
# Define postgres version, and revision to be build
# v{pg-major}.{pg-minor}[.{pg-revision}]-r{revision}
export BASE_VER="v16.2-r4"
export POSTGIS_VER="v16.2-r4"
export PLV8_VER="v16.2-r4"
export MISC_VER="v16.2-r4"
export PLJAVA_VER="v16.2-r4"
export RELEASE_VER="v16.2-r4"
export BASE_VER="v17.4-r1"
export POSTGIS_VER="v17.4-r1"
export PLV8_VER="v17.4-r1"
export MISC_VER="v17.4-r1"
export PLJAVA_VER="v17.4-r1"
export PLRUST_VER="v17.4-r1"
export RELEASE_VER="v17.4-r1"
```

Ones done, start compiling
Once done, start compiling

```bash
cd deployment/docker/postgres

# Build base image and push
# Build base image
cd naksha-pg-0-base
docker build --platform=linux/arm64,linux/amd64 -t "$DR_NAKSHA_POSTGRES:base-${BASE_VER}" .
cd ..

# Build postgis image and push
# Build postgis image
cd naksha-pg-1-postgis
docker build --platform=linux/arm64,linux/amd64 \
--build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \
--build-arg="VERSION=${BASE_VER}" \
-t "${DR_NAKSHA_POSTGRES}:postgis-${POSTGIS_VER}" .
cd ..

# Build plv8 image and push
# Build plv8 image
cd naksha-pg-2-plv8
docker build --platform=linux/arm64,linux/amd64 \
--build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \
--build-arg="VERSION=${POSTGIS_VER}" \
-t "${DR_NAKSHA_POSTGRES}:plv8-${PLV8_VER}" .
cd ..

# Build miscellaneous image and push
# Build miscellaneous image
cd naksha-pg-3-misc
docker build --platform=linux/arm64,linux/amd64 \
--build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \
--build-arg="VERSION=${PLV8_VER}" \
-t "${DR_NAKSHA_POSTGRES}:misc-${MISC_VER}" .
cd ..

# Build pljava image and push
# Build pljava image
cd naksha-pg-4-pljava
docker build --platform=linux/arm64,linux/amd64 \
--build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \
--build-arg="VERSION=${MISC_VER}" \
-t "${DR_NAKSHA_POSTGRES}:pljava-${PLJAVA_VER}" .
cd ..

# Build plrust image
#cd naksha-pg-5-plrust
#docker build --platform=linux/arm64,linux/amd64 \
# --build-arg="DR_NAKSHA_POSTGRES=$DR_NAKSHA_POSTGRES" \
# --build-arg="VERSION=${PLJAVA_VER}" \
# -t "${DR_NAKSHA_POSTGRES}:plrust-${PLRUST_VER}" .
#cd ..

# Build the final postgres with run-scripts and default configurations
# Note, this can be done multiple times without any need to re-build the previous images
# Therefore we introduce the BASE var
Expand All @@ -94,6 +104,8 @@ docker build --platform=linux/arm64,linux/amd64 \
--build-arg="VERSION=${PLJAVA_VER}" \
-t "${DR_NAKSHA_POSTGRES}:${RELEASE_VER}" \
-t "${DR_NAKSHA_POSTGRES}:latest" .
cd ..
# --build-arg="VERSION=${PLRUST_VER}" \ for later when we include PL Rust
```

**Notes**:
Expand Down
10 changes: 5 additions & 5 deletions deployment/docker/postgres/naksha-pg-0-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ FROM public.ecr.aws/amazonlinux/amazonlinux:latest
RUN dnf update -y
RUN dnf install -y bison-devel readline-devel zlib-devel openssl-devel wget vim
RUN dnf install -y mlocate icu libicu-devel e2fsprogs e2fsprogs-devel lz4 lz4-devel uuid uuid-devel sudo
RUN dnf install -y --allowerasing curl curl-devel
RUN dnf install -y --allowerasing curl curl-devel perl docbook-xsl libxslt
RUN dnf -y groupinstall "Development Tools"
RUN cd /tmp/ \
&& wget https://ftp.postgresql.org/pub/source/v16.2/postgresql-16.2.tar.gz \
&& tar xzf postgresql-16.2.tar.gz \
&& cd postgresql-16.2 \
&& wget https://ftp.postgresql.org/pub/source/v17.4/postgresql-17.4.tar.gz \
&& tar xzf postgresql-17.4.tar.gz \
&& cd postgresql-17.4 \
&& ./configure --prefix=/usr/local --with-blocksize=32 --with-wal-blocksize=32 --with-lz4 --with-zstd --with-openssl --with-uuid=ossp \
&& make world WITH_PGBLOCKSIZE=32K \
&& groupadd postgres -g 5430 \
Expand All @@ -23,4 +23,4 @@ RUN cd /tmp/ \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
2 changes: 1 addition & 1 deletion deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ RUN dnf install -y libxml2 libxml2-devel cmake \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
4 changes: 2 additions & 2 deletions deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ FROM ${DR_NAKSHA_POSTGRES}:postgis-${VERSION}
RUN cd /tmp/ \
&& git clone https://github.com/plv8/plv8.git \
&& cd plv8 \
&& git checkout v3.2.2 \
&& git checkout v3.2.3 \
&& make \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'plv8';
Expand All @@ -17,4 +17,4 @@ RUN cd /tmp/ \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
4 changes: 2 additions & 2 deletions deployment/docker/postgres/naksha-pg-3-misc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RUN cd /tmp/ \
&& cd /tmp/ \
&& git clone https://github.com/citusdata/pg_cron.git \
&& cd pg_cron \
&& git checkout v1.6.2 \
&& git checkout v1.6.4 \
&& make \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'pg_cron';
Expand All @@ -43,4 +43,4 @@ RUN cd /tmp/ \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
6 changes: 3 additions & 3 deletions deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ RUN dnf install -y java-21-amazon-corretto maven \
&& cd /tmp/ \
&& git clone https://github.com/tada/pljava.git \
&& cd pljava \
&& git checkout V1_6_6 \
&& git checkout V1_6_9 \
&& mvn clean install \
&& java -jar pljava-packaging/target/pljava-pg16.jar \
&& java -jar pljava-packaging/target/pljava-pg17.jar \
# SELECT * FROM pg_available_extensions WHERE name = 'pljava';
#
# Cleanup
&& rm -rf /tmp/*

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
37 changes: 37 additions & 0 deletions deployment/docker/postgres/naksha-pg-5-plrust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres
ARG VERSION
ARG TARGETPLATFORM
FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION}


# TOO BADDDD!!!!!!!!!!!!!! PL RUST DOES NOT SUPPORT POSTGRESQL 17 YET!!!!!!!!!!!!!!!!!




# https://github.com/tcdi/plrust
# https://plrust.io/install-plrust.html#trusted-installation-plus-cross-compilation
RUN curl --tlsv1.3 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y \
&& rustup component add llvm-tools-preview rustc-dev \
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
rustup target install aarch64-unknown-linux-gnu; \
elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
rustup target install x86_64-unknown-linux-gnu; \
fi \
&& cd ~/plrust/plrustc \
&& ./build.sh \
&& mv ~/plrust/build/bin/plrustc ~/.cargo/bin/ \
# install postgrestd
&& cd ~/plrust/plrust \
&& PG_VER=17 \
&& if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
STD_TARGETS="aarch64-postgres-linux-gnu "; \
elif [ "${TARGETPLATFORM}" = "linux/amd64" ]; then \
STD_TARGETS="x86_64-postgres-linux-gnu "; \
fi \
&& ./build \
&& cargo pgrx install --release --features trusted -c /usr/bin/pg_config

EXPOSE 5432

CMD ["/usr/bin/run_postgres.sh"]
3 changes: 2 additions & 1 deletion deployment/docker/postgres/naksha-pg-release/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres
ARG VERSION
FROM ${DR_NAKSHA_POSTGRES}:pljava-${VERSION}
#FROM ${DR_NAKSHA_POSTGRES}:plrust-${VERSION}

ADD files /

Expand All @@ -12,4 +13,4 @@ RUN chown postgres:postgres /usr/bin/run_postgres.sh \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
26 changes: 26 additions & 0 deletions deployment/docker/postgres16WithPLRust/naksha-pg-0-base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM public.ecr.aws/amazonlinux/amazonlinux:latest

# Execute all commands at ones, so we only get one layer

# Install PostgresQL (https://www.postgresql.org/ftp/source/)
RUN dnf update -y
RUN dnf install -y bison-devel readline-devel zlib-devel openssl-devel wget vim
RUN dnf install -y mlocate icu libicu-devel e2fsprogs e2fsprogs-devel lz4 lz4-devel uuid uuid-devel sudo
RUN dnf install -y --allowerasing curl curl-devel
RUN dnf -y groupinstall "Development Tools"
RUN cd /tmp/ \
&& wget https://ftp.postgresql.org/pub/source/v16.8/postgresql-16.8.tar.gz \
&& tar xzf postgresql-16.8.tar.gz \
&& cd postgresql-16.8 \
&& ./configure --prefix=/usr/local --with-blocksize=32 --with-wal-blocksize=32 --with-lz4 --with-zstd --with-openssl --with-uuid=ossp \
&& make world WITH_PGBLOCKSIZE=32K \
&& groupadd postgres -g 5430 \
&& useradd postgres -u 5432 -g 5430 \
&& make install-world \
&& updatedb \
# Cleanup
&& rm -rf /tmp/*

EXPOSE 5432

CMD ["/usr/bin/run_postgres.sh"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres
ARG VERSION
FROM ${DR_NAKSHA_POSTGRES}:base-${VERSION}

#
# Install Geos (https://libgeos.org/usage/download/)
RUN dnf install -y libxml2 libxml2-devel cmake \
&& cd /tmp/ \
&& wget https://download.osgeo.org/geos/geos-3.12.1.tar.bz2 \
&& tar xjf geos-3.12.1.tar.bz2 \
&& cd geos-3.12.1 \
&& mkdir _build \
&& cd _build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
&& make \
&& make install \
&& echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr_local_lib64.conf \
&& rm /etc/ld.so.cache && ldconfig \
# Test if library is available: ldconfig -v -N | grep geos
#
# Proj4 (https://proj.org/en/9.4/development/index.html)
# https://github.com/OSGeo/PROJ
&& dnf install -y sqlite sqlite-devel libtiff libtiff-devel \
&& cd /tmp/ \
&& git clone https://github.com/OSGeo/PROJ.git \
&& cd PROJ \
&& git checkout 9.4 \
&& mkdir build \
&& cd build \
&& cmake .. \
&& cmake --build . \
&& cmake --build . --target install \
&& rm /etc/ld.so.cache && ldconfig \
#
# Install GDal (https://gdal.org/index.html)
# https://github.com/OSGeo/gdal
&& dnf install -y python3-devel python3-setuptools \
&& cd /tmp/ \
&& git clone https://github.com/OSGeo/gdal.git \
&& cd gdal \
&& git checkout v3.8.4 \
&& mkdir build \
&& cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . \
&& cmake --build . --target install \
# Test if library is available: ldconfig -v -N | grep jdal
# JSON-C
# This library is needed for some POSTGIS functions
# See: https://postgis.net/docs/postgis_installation.html#installation_configuration
# https://github.com/json-c/json-c
&& cd /tmp/ \
&& git clone https://github.com/json-c/json-c.git \
&& cd json-c \
&& git checkout json-c-0.17 \
&& mkdir json-c-build \
&& cd json-c-build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& make \
&& make install \
&& rm /etc/ld.so.cache && ldconfig \
# Test if library is available: ldconfig -v -N | grep json-c
# PCRE
# See: https://postgis.net/docs/postgis_installation.html#installation_configuration
# https://github.com/PCRE2Project/pcre2 \
&& cd /tmp/ \
&& git clone https://github.com/PCRE2Project/pcre2.git \
&& cd pcre2 \
&& git checkout pcre2-10.43 \
&& mkdir pcre2-build \
&& cd pcre2-build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF \
&& make \
&& make install \
&& rm /etc/ld.so.cache && ldconfig \
# Test if library is available: ldconfig -v -N | grep pcre2
# PostGis extension
# https://postgis.net/docs/postgis_installation.html
# https://git.osgeo.org/gitea/postgis/postgis
&& dnf install -y protobuf protobuf-devel protobuf-c-devel libxslt libxslt-devel autoconf autoconf-archive perl-Time-HiRes libpq libpq-devel \
&& cd /tmp/ \
&& git clone https://git.osgeo.org/gitea/postgis/postgis.git \
&& cd postgis \
&& git checkout 3.4.2 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& export PGUSER=postgres \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'postgis';
# Cleanup
&& rm -rf /tmp/*

EXPOSE 5432

CMD ["/usr/bin/run_postgres.sh"]
20 changes: 20 additions & 0 deletions deployment/docker/postgres16WithPLRust/naksha-pg-2-plv8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG DR_NAKSHA_POSTGRES=hcr.data.here.com/naksha/postgres
ARG VERSION
FROM ${DR_NAKSHA_POSTGRES}:postgis-${VERSION}

# PLV8 extension (https://github.com/plv8/plv8.git)
# Note: Very slow, requires one hour!
RUN cd /tmp/ \
&& git clone https://github.com/plv8/plv8.git \
&& cd plv8 \
&& git checkout v3.2.3 \
&& make \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'plv8';
#
# Cleanup
&& rm -rf /tmp/*

EXPOSE 5432

CMD ["/usr/bin/run_postgres.sh"]
Loading