[[TOC]] The PostGIS project uses docker for a number of regression tests and production use. We have two different docker setups. On OSGeo infrastructure we have docker.osgeo.org which docker images are pushed to via postgis-docker.osgeo.org. These are currently only used by dronie.osgeo.org and woodie.osgeo.org drone agents. They ware useful for general development as well, because they include multiple versions of PostgreSQL and also include pre-installed postgis versions for doing upgrade tests. == Docker OSGeo (Development) == The docker osgeo infrastructure you can log in via your osgeo user id. Only PostGIS development team members have push rights to this repo. More details of the images, dockerfiles in use by it can be found at [https://git.osgeo.org/gitea/postgis/postgis-docker PostGIS-docker repo]. Here is an example of how you can pull an image, retag and push to postgis-docker.osgeo.org **FOR DEVELOPMENT** {{{ #To develop and test using this image, do the following cd ~/ mkdir projects #this container has no built in entry point to keep it running, # create a fake one as discussed here - https://levelup.gitconnected.com/keep-docker-container-running-for-debugging-fc2dfa39472c #this might take a minute or so after download to start up # the below exposes the 5436 port of container as 6445 of the host, you can add additional for each cluster docker run -d \ --name postgis-dev \ --mount type=bind,source="$(pwd)/projects",target=/projects \ -p 6432:5432/tcp \ -p 6433:5433/tcp \ -p 6434:5434/tcp \ -p 6435:5435/tcp \ -p 6436:5436/tcp \ -p 6437:5437/tcp \ docker.osgeo.org/postgis/build-test:trisquel3 tail -f /dev/null cd projects git clone https://git.osgeo.org/gitea/postgis/postgis.git #once started you can attach to the container using docker exec -it postgis-dev /bin/bash # in the postgis-dev container, you should be able to do # below copied from https://git.osgeo.org/gitea/postgis/postgis/src/branch/master/ci/dronie/postgis_regress.sh cd /projects/postgis export PGVER=15 service postgresql start ${PGVER} export PGPORT=`grep ^port /etc/postgresql/$PGVER/main/postgresql.conf | awk '{print $3}'` export PATH=/usr/lib/postgresql/$PGVER/bin:$PATH #do this to be able to access from host psql -d postgres -c "ALTER SYSTEM SET listen_addresses='*';" # change whatever to something more secure, if you care psql -d postgres -p 5436 -c "ALTER ROLE postgres PASSWORD 'whatever';" echo "host all all 0.0.0.0/0 scram-sha-256" >> /etc/postgresql/${PGVER}/main/pg_hba.conf #shows you list of associate ports for each postgres version (connecting from your host machine would be 6 instead of 5) pg_lsclusters service postgresql restart ${PGVER} echo sh autogen.sh ./configure make make check make install #any changes you make to your local folder projects/postgis, will show in the container /projects/postgis #in the container # To stop it do docker stop postgis-dev # if you need to remove the container to get a new version do docker rm postgis-dev }}} === Connecting to PostgreSQL from your host machine === {{{ psql -U postgres -h localhost -p 6436 #this is the one running PG15 at time of writing }}} == Docker Hub PostGIS == Docker Hub is used for Github-actions testing and there is also a postgis for production use. The main link to all is [https://hub.docker.com/u/postgis] === Production === * **FOR PRODUCTION** [https://hub.docker.com/r/postgis/postgis] - has production images managed by a community of PostGIS users. To become a contributor go to [https://github.com/postgis/docker-postgis] === Development === * **FOR DEVELOPMENT** [https://hub.docker.com/r/postgis/postgis-build-env] - has development images managed by a PostGIS Development team set aside for regression testing. Do not use these for production use as they don't even have postgis installed on them. You can find the docker files here [https://github.com/postgis/postgis-build-env] The postgis-build-env images don't have PostGIS installed on them at all, but have all the key dependencies needed to compile PostGIS. The version **latest** includes pre-compiled in development versions proj, gdal, geos, postgresql, and sfcgal. It is used to catch possible issues with other upstream projects. You can set it up much the same as the docker.osgeo.org development suite detailed earlier. **FOR DEVELOPMENT** {{{ #To develop and test using this image, do the following cd ~/ mkdir projects #this container has no built in entry point to keep it running, # create a fake one as discussed here - https://levelup.gitconnected.com/keep-docker-container-running-for-debugging-fc2dfa39472c docker pull postgis/postgis-build-env:latest #this might take a minute or so after download to start up # this will expose the postgresql 5432 port, to host as 6444 (to prevent conflict with any other postgresql you are running on your host machine docker run -d \ --name postgis-build-env \ --mount type=bind,source="$(pwd)/projects",target=/projects \ postgis/postgis-build-env:latest tail -f /dev/null cd projects git clone https://git.osgeo.org/gitea/postgis/postgis.git #once started you can attach to it docker exec -it postgis-build-env /bin/bash # in the postgis-buildenv container, you should be able to do # below copied from https://git.osgeo.org/gitea/postgis/postgis/src/branch/master/ci/github/run_coverage.sh cd /projects/postgis # Flags for coverage build CFLAGS_COV="-g -O0 --coverage" LDFLAGS_COV="--coverage" #TODO fix this, container starts up using postgres, and so these fail if mounting an external source folder # using sudo makes paths not work /usr/local/pgsql/bin/pg_ctl -c -l /tmp/logfile -o '-F' start sudo ./autogen.sh sudo ldconfig /usr/local/pgsql/lib sudo ./configure CFLAGS="${CFLAGS_COV}" LDFLAGS="${LDFLAGS_COV}" --enable-debug sudo make -j 4 sudo make check sudo make install #any changes you make to your local folder projects/postgis, will show in the container /projects/postgis #in the container # To stop it do docker stop postgis-build-env # if you need to remove the container to get a new version do docker rm postgis-build-env }}}