2

I do need to use the PostGIS SFCGAL extension in its latest version (i.e. 1.4.1 at the time of writing).

This extension is based (and needs) the libsfcgal system library.

Because the official PostGIS docker image available at https://registry.hub.docker.com/r/postgis/postgis/ (postgis/postgis:15-master) is based on Debian 11 (bullseye), libsfcgal version is 1.3.9-2: https://packages.debian.org/bullseye/libsfcgal1 and so does the PostGIS extension:

-- Debian 11 (latest official PG15/PostGIS3.3 docker hub image)
SELECT postgis_full_version();

POSTGIS="3.4.0dev 3.3.0rc2-335-gae95dd219"
  [EXTENSION]
    PGSQL="150"
    GEOS="3.12.0dev-CAPI-1.18.0"
    SFCGAL="1.3.10"
    PROJ="9.2.0"
    LIBXML="2.9.10"
    LIBJSON="0.15"
    LIBPROTOBUF="1.3.3"
    WAGYU="0.5.0 (Internal)"
    TOPOLOGY

Well, actually 1.3.10, but the libsfcgal1 lib is currently not installed in the PostGIS Docker image, don't ask me why, neither where SFCGAL actually comes from... it's like that.

Whereas, e.g on Ubuntu 22.04.1:

# Ubuntu 22.04
POSTGIS="3.3.2 4975da8"
  [EXTENSION] 
    PGSQL="150"
    GEOS="3.10.2-CAPI-1.16.0"
    SFCGAL="SFCGAL 1.4.1, CGAL 5.3.1, BOOST 1.74.0"
    PROJ="8.2.1"
    LIBXML="2.9.13"
    LIBJSON="0.15"
    LIBPROTOBUF="1.3.3"
    WAGYU="0.5.0 (Internal)"
    TOPOLOGY

(LIBXML is also in an older state in the PostGIS Docker image than on Ubuntu. These two libs are the only one been older in the Docker image; all the other are more recent than on Ubuntu)

On Debian (because PostGIS docker images are based on Debian), the version 1.4.1 is actually available in sid, aka testing: https://packages.debian.org/sid/libsfcgal1

I've tried to installed libsfcgal1 using the testing apt repository, but then I face some troubles, becase apparently, installing this new libsfcgal1 version also reset locales to some empty values, therefore, PostgreSQL cannot initialize a new database, neither connect properly to it:

# psql -U postgres

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LANG = "en_US.utf8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
psql (15.1 (Debian 15.1-1.pgdg110+1))
Type "help" for help.

This is blocking when spinning up a container based on a Dockerfile as, e.g.:

FROM postgis/postgis:15-master

RUN echo 'deb http://deb.debian.org/debian testing main' >> /etc/apt/sources.list \
  && apt-get -y update \
  && DEBIAN_FRONTEND=noninteractive apt-get -y install \
  --no-install-recommends libsfcgal1

Then when starting a vanilla Compose file based on this Dockerimage:

$ docker compose up 

[+] Running 3/0
 ⠿ Network project_lan_access  Created                                                                                                                                                                        0.0s
 ⠿ Volume "project_pgdata"     Created                                                                                                                                                                        0.0s
 ⠿ Container project-db-1      Created                                                                                                                                                                        0.0s
Attaching to project-db-1
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1 exited with code 1
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1 exited with code 1
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1 exited with code 1
^CGracefully stopping... (press Ctrl+C again to force)
[+] Running 0/1
 ⠙ Container project-db-1  Stopping                                                                                                                                                                           0.2s
canceled

(which I have to manually stop because it's looping for ever...)

EDIT

By trying this Dockerfile:

FROM postgis/postgis:15-master

ENV LANGUAGE=en_US.UTF-8 # <-- new line!
ENV LC_ALL=en_US.UTF-8   # <-- new line!

RUN echo 'deb http://deb.debian.org/debian testing main' >> /etc/apt/sources.list \
  && apt-get -y update \
  && DEBIAN_FRONTEND=noninteractive apt-get -y install \
  --no-install-recommends libsfcgal1

I have two new warnings (setlocale: LC_ALL: cannot change locale (en_US.UTF-8)) prior to the same error loop than before when spinning up the container:

$ docker compose up
[+] Running 2/2
 ⠿ Network project_lan_access  Created                                                                                                                                                                        0.0s
 ⠿ Container project-db-1      Created                                                                                                                                                                        0.1s
Attaching to project-db-1
project-db-1  | bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
project-db-1  | bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1 exited with code 1
project-db-1  | bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1 exited with code 1
project-db-1  | initdb: error: invalid locale settings; check LANG and LC_* environment variables
project-db-1  | The files belonging to this database system will be owned by user "postgres".
project-db-1  | This user must also own the server process.
project-db-1  | 
project-db-1 exited with code 1
^CGracefully stopping... (press Ctrl+C again to force)
[+] Running 1/0
 ⠿ Container project-db-1  Stopped                                                                                                                                                                            0.0s
canceled

Therefore, my question is: how to properly install the SFCGAL 1.4.1 extension (as it is available on Ubuntu 22.04 for example) in the latest PostGIS docker image?

1 Answer 1

0

Short answer

One cannot simply install libsfcal1 because the PostGIS Docker image is currently building SFCGAL from Oslandia sources.

Detailed answer

In order to have PostGIS build with SFCGAL 1.4.1 support, one has to install libcgal-dev 5.5.1 from Debian testing (sid) in its Dockerfile.

Indeed, the libcgal-dev version is 5.2 on Debian bullseye, and an error is raised when compiling SFCGAL >= 1.4 from sources with this version of libcgal-dev:

-- Configuring incomplete, errors occurred!
See also "/usr/src/SFCGAL/cmake-build/CMakeFiles/CMakeOutput.log".
CMake Error at CMakeLists.txt:67 (find_package):
  Could not find a configuration file for package "CGAL" that is compatible
  with requested version "5.3".

  The following configuration files were considered but not accepted:

    /usr/lib/x86_64-linux-gnu/cmake/CGAL/CGALConfig.cmake, version: 5.2

A quick workaround is to fetch libcgal-dev 5.5.1 from Debian testing and update the git hash corresponding to the SFCGAL 1.4.1 release in the PostGIS Dockerfile.

The PostGIS docker image build should then work, giving you a fully functional PostGIS with SCFGAL 1.4.1 support:

POSTGIS="3.4.0dev 3.3.0rc2-390-gc2a0b2024"
  [EXTENSION]
    PGSQL="150"
    GEOS="3.12.0dev-CAPI-1.18.0"
    SFCGAL="SFCGAL 1.4.1, CGAL 5.5.1, BOOST 1.74.0"
    PROJ="9.2.0"
    LIBXML="2.9.10"
    LIBJSON="0.15"
    LIBPROTOBUF="1.3.3"
    WAGYU="0.5.0 (Internal)"
    TOPOLOGY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.