Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ You can use standalone instance installed directly on your host machine but ther
To use the containerized Postgres with your locally runnning Naksha:
1) Pull docker image:
```bash
docker pull ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
docker pull ghcr.io/naksha-oss/naksha-postgres:v18.6
```
2) Run docker image with password set to default:
```bash
docker run -p 5432:5432 -e PGPASSWORD=password ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
docker run -p 5432:5432 -e PGPASSWORD=password ghcr.io/naksha-oss/naksha-postgres:v18.6
```

3) When the docker container is started for the first time, it will generate a random password so to simplify local development we can change it to default.
Expand Down
30 changes: 15 additions & 15 deletions deployment/docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ Before you can start building the image, install docker, for example [Docker Des
1. The first step is to export environment variables, and then login to your docker registry (**DR**), example of HERE registry:

```bash
export DR_USER='<here-user>'
export DR_PWD='<encrypted-password>'
export DR_HOST="hcr.data.here.com" #Do not set if publishing to Docker Hub
export DR_NAKSHA_POSTGRES="$DR_HOST/naksha/postgres" #For Docker Hub use "heremaps/naksha-postgres"
docker login -u="$DR_USER" -p="$DR_PWD" $DR_HOST
#Do not set DR_HOST if publishing to Docker Hub
#For Docker Hub use export DR_NAKSHA_POSTGRES="heremaps/naksha-postgres"
export DR_USER='naksha-oss'
export DR_HOST="ghcr.io"
export DR_NAKSHA_POSTGRES="$DR_HOST/naksha-oss/naksha-postgres"
docker login -u="$DR_USER" $DR_HOST
```

**Note**: If you feel saver, enter the password on CLI. The rest of the instructions are no longer environment dependent.

2. To build images supporting multi-platforms (ARM, AMD,...), enable containerd image store, or use a custom docker builder https://docs.docker.com/build/building/multi-platform/

The PostgresQL docker will be build in multiple steps:
Expand All @@ -35,12 +34,13 @@ 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"
# for later revisions, you can use v18.6-r1, v18.6-r2, ...
export BASE_VER="v18.6"
export POSTGIS_VER="v18.6"
export PLV8_VER="v18.6"
export MISC_VER="v18.6"
export PLJAVA_VER="v18.6"
export RELEASE_VER="v18.6"
```

Ones done, start compiling
Expand Down Expand Up @@ -169,12 +169,12 @@ mkdir -p ~/pg_temp
To create the container do the following:

```bash
docker pull ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
docker pull ghcr.io/naksha-oss/naksha-postgres:v18.6
docker run --name naksha_pg \
-v ~/pg_data:/usr/local/pgsql/data \
-v ~/pg_temp:/usr/local/pgsql/temp \
-p 0.0.0.0:5432:5432 \
-d ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
-d ghcr.io/naksha-oss/naksha-postgres:v18.6
```

When the docker container is started for the first time, it will generate a random password for the `postgres` user and store it inside the docker container in `/home/postgres/postgres.pwd`. You should remember this, because the password is stored in the database. It as well prints it, you can review like:
Expand Down
12 changes: 6 additions & 6 deletions deployment/docker/postgres/naksha-pg-0-base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ 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/v18.6/postgresql-18.6.tar.gz \
&& tar xzf postgresql-18.6.tar.gz \
&& cd postgresql-18.6 \
&& ./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 \
&& make -j$(nproc) world WITH_PGBLOCKSIZE=32K \
&& groupadd postgres -g 5430 \
&& useradd postgres -u 5432 -g 5430 \
&& make install-world \
Expand All @@ -23,4 +23,4 @@ RUN cd /tmp/ \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
30 changes: 16 additions & 14 deletions deployment/docker/postgres/naksha-pg-1-postgis/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ FROM ${DR_NAKSHA_POSTGRES}:base-${VERSION}
#
# Install Geos (https://libgeos.org/usage/download/)
RUN dnf install -y libxml2 libxml2-devel cmake \
&& export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) \
&& 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 \
&& wget https://download.osgeo.org/geos/geos-3.15.0.tar.bz2 \
&& tar xjf geos-3.15.0.tar.bz2 \
&& cd geos-3.15.0 \
&& mkdir _build \
&& cd _build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. \
&& make \
&& make -j$(nproc) \
&& make install \
&& echo "/usr/local/lib64" > /etc/ld.so.conf.d/usr_local_lib64.conf \
&& rm /etc/ld.so.cache && ldconfig \
Expand All @@ -24,7 +25,7 @@ RUN dnf install -y libxml2 libxml2-devel cmake \
&& cd /tmp/ \
&& git clone https://github.com/OSGeo/PROJ.git \
&& cd PROJ \
&& git checkout 9.4 \
&& git checkout 9.9 \
&& mkdir build \
&& cd build \
&& cmake .. \
Expand All @@ -38,25 +39,26 @@ RUN dnf install -y libxml2 libxml2-devel cmake \
&& cd /tmp/ \
&& git clone https://github.com/OSGeo/gdal.git \
&& cd gdal \
&& git checkout v3.8.4 \
&& git checkout v3.13.3 \
&& mkdir build \
&& cd build \
&& export GDAL_PYTHON_BINDINGS_WITHOUT_NUMPY=1 \
&& cmake -DCMAKE_BUILD_TYPE=Release .. \
&& cmake --build . \
&& cmake --build . --target install \
# Test if library is available: ldconfig -v -N | grep jdal
# Test if library is available: ldconfig -v -N | grep gdal
# 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 \
&& git checkout json-c-0.19 \
&& mkdir json-c-build \
&& cd json-c-build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release \
&& make \
&& make -j$(nproc) \
&& make install \
&& rm /etc/ld.so.cache && ldconfig \
# Test if library is available: ldconfig -v -N | grep json-c
Expand All @@ -66,11 +68,11 @@ RUN dnf install -y libxml2 libxml2-devel cmake \
&& cd /tmp/ \
&& git clone https://github.com/PCRE2Project/pcre2.git \
&& cd pcre2 \
&& git checkout pcre2-10.43 \
&& git checkout pcre2-10.48 \
&& mkdir pcre2-build \
&& cd pcre2-build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF \
&& make \
&& make -j$(nproc) \
&& make install \
&& rm /etc/ld.so.cache && ldconfig \
# Test if library is available: ldconfig -v -N | grep pcre2
Expand All @@ -81,10 +83,10 @@ RUN dnf install -y libxml2 libxml2-devel cmake \
&& cd /tmp/ \
&& git clone https://git.osgeo.org/gitea/postgis/postgis.git \
&& cd postgis \
&& git checkout 3.4.2 \
&& git checkout 3.6.4 \
&& ./autogen.sh \
&& ./configure \
&& make \
&& make -j$(nproc) \
&& export PGUSER=postgres \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'postgis';
Expand All @@ -93,4 +95,4 @@ RUN dnf install -y libxml2 libxml2-devel cmake \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
8 changes: 4 additions & 4 deletions deployment/docker/postgres/naksha-pg-2-plv8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ARG VERSION
FROM ${DR_NAKSHA_POSTGRES}:postgis-${VERSION}

# PLV8 extension (https://github.com/plv8/plv8.git)
# Note: Very slow, requires one hour!
# Note: Very slow, requires one hour! Or 30 minutes with 10 CPU cores.
RUN cd /tmp/ \
&& git clone https://github.com/plv8/plv8.git \
&& cd plv8 \
&& git checkout v3.2.2 \
&& make \
&& git checkout v3.2.5 \
&& make -j$(nproc) \
&& 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"]
18 changes: 9 additions & 9 deletions deployment/docker/postgres/naksha-pg-3-misc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ FROM ${DR_NAKSHA_POSTGRES}:plv8-${VERSION}
RUN cd /tmp/ \
&& git clone https://github.com/pramsey/pgsql-gzip.git \
&& cd pgsql-gzip \
&& git checkout v1.0.0 \
&& make \
&& git checkout v1.1.1 \
&& make -j$(nproc) \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'gzip';
#
# pg_hint_plan extension (https://github.com/ossc-db/pg_hint_plan)
&& cd /tmp/ \
&& git clone https://github.com/ossc-db/pg_hint_plan.git \
&& cd pg_hint_plan \
&& git checkout REL16_1_6_0 \
&& make \
&& git checkout REL18_1_8_0 \
&& make -j$(nproc) \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'pg_hint_plan';
#
# pg_cron extension (https://github.com/citusdata/pg_cron)
&& cd /tmp/ \
&& git clone https://github.com/citusdata/pg_cron.git \
&& cd pg_cron \
&& git checkout v1.6.2 \
&& make \
&& git checkout v1.6.8 \
&& make -j$(nproc) \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'pg_cron';
#
# pg_partman (https://github.com/pgpartman/pg_partman)
&& cd /tmp/ \
&& git clone https://github.com/pgpartman/pg_partman.git \
&& cd pg_partman \
&& git checkout v5.0.1 \
&& make \
&& git checkout v5.5.0 \
&& make -j$(nproc) \
&& make install \
# SELECT * FROM pg_available_extensions WHERE name = 'pg_partman';
#
Expand All @@ -43,4 +43,4 @@ RUN cd /tmp/ \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
9 changes: 5 additions & 4 deletions deployment/docker/postgres/naksha-pg-4-pljava/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ FROM ${DR_NAKSHA_POSTGRES}:misc-${VERSION}
# https://tada.github.io/pljava/use/policy.html
# https://www.percona.com/blog/postgresql-pl-java-how-to-part-1/
# https://www.slideshare.net/petereisentraut/postgresql-and-pljava
RUN dnf install -y java-21-amazon-corretto maven \
# NOTE: cannot maven install with parallel threads '-T 1C'
RUN dnf install -y java-25-amazon-corretto maven \
&& cd /tmp/ \
&& git clone https://github.com/tada/pljava.git \
&& cd pljava \
&& git checkout V1_6_6 \
&& git checkout V1_6_10 \
&& mvn clean install \
&& java -jar pljava-packaging/target/pljava-pg16.jar \
&& java -jar pljava-packaging/target/pljava-pg18.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"]
2 changes: 1 addition & 1 deletion deployment/docker/postgres/naksha-pg-release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ RUN dnf clean all \

EXPOSE 5432

CMD /usr/bin/run_postgres.sh
CMD ["/usr/bin/run_postgres.sh"]
4 changes: 2 additions & 2 deletions deployment/ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ sudo systemctl start docker
sudo systemctl enable docker

# Start the PostgresQL docker
sudo docker pull hcr.data.here.com/naksha-devops/naksha-postgres:amd64-v16.2-r0
sudo docker run --name naksha_pg --privileged -v /mnt/pg_data:/usr/local/pgsql/data -v /mnt/pg_temp:/usr/local/pgsql/temp --network host -d hcr.data.here.com/naksha-devops/naksha-postgres:amd64-v16.2-r0
sudo docker pull ghcr.io/naksha-oss/naksha-postgres:v18.6
sudo docker run --name naksha_pg --privileged -v /mnt/pg_data:/usr/local/pgsql/data -v /mnt/pg_temp:/usr/local/pgsql/temp --network host -d ghcr.io/naksha-oss/naksha-postgres:v18.6
sudo docker logs naksha_pg
# Find the generated postgres root password, looks like:
# Initialized database with password: zFKRsAEWoJteGUCobBxgJmNrDLeJARNP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class PostgresContainer {

private static final Logger log = LoggerFactory.getLogger(PostgresContainer.class);
private static final String NAKSHA_POSTGRES_IMAGE = "ghcr.io/naksha-oss/naksha-postgres:v16.2-r5";
private static final String NAKSHA_POSTGRES_IMAGE = "ghcr.io/naksha-oss/naksha-postgres:v18.6";
private static final Integer POSTGRES_CONTAINER_PORT = 5432;
private static final Integer LOCALHOST_PORT = 5432;
private static final Duration STARTUP_TIMEOUT = Duration.ofSeconds(90);
Expand Down
2 changes: 1 addition & 1 deletion here-naksha-cli/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ EOF
###############
# FINAL STAGE #
###############
FROM ghcr.io/naksha-oss/naksha-postgres:v16.2-r5
FROM ghcr.io/naksha-oss/naksha-postgres:v18.6

ARG JAVA_HOME NAKSHA_CLI_DIR CLI_FILES_PATH="/tmp/naksha-cli-files"
ARG srcStorageConfig="${CLI_FILES_PATH}/srcStorageConfig.json" srcMapId="" srcCollectionId=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PsqlTestStorage : PsqlStorage() {
}
}

internal const val POSTGRES_IMAGE_URI = "ghcr.io/naksha-oss/naksha-postgres:v16.2-r5"
internal const val POSTGRES_IMAGE_URI = "ghcr.io/naksha-oss/naksha-postgres:v18.6"
internal val dockerContainerInfo = AtomicReference<PsqlTestDockerContainerInfo?>()

/**
Expand Down
8 changes: 4 additions & 4 deletions here-naksha-lib-psql/src/jvmMain/resources/beautify.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CREATE EXTENSION IF NOT EXISTS plv8;

CREATE OR REPLACE FUNCTION js_beautify(json text, opt jsonb) RETURNS text AS $$
return require("beautify").js_beautify(json, opt)
CREATE OR REPLACE FUNCTION js_beautify(input_json text, opt jsonb) RETURNS text AS $$
return require("beautify").js_beautify(input_json, opt)
$$ LANGUAGE 'plv8' IMMUTABLE;

CREATE OR REPLACE FUNCTION js_beautify(json text) RETURNS text AS $$
return require("beautify").js_beautify(json, {"indent_size":2,"space_in_empty_paren":true})
CREATE OR REPLACE FUNCTION js_beautify(input_json text) RETURNS text AS $$
return require("beautify").js_beautify(input_json, {"indent_size":2,"space_in_empty_paren":true})
$$ LANGUAGE 'plv8' IMMUTABLE;
Loading