-
Notifications
You must be signed in to change notification settings - Fork 0
Mapserver Installation
Mukau Mapserver Repository builds an image of PostgreSQL/PostGIS and Mapserver. The Mukau system uses Mapserver as the main GIS engine for connecting to the database and rendering the layers for consumption by the frontend webmap in WMS standards. The OSGEO Mapserver instance connects to database and process the layers for visualization by use of mapfiles.
This componets brings in the ability to separate Mapserver to its own docker container, since it can live independently from the Mukau wagtail CMS. The MapViewer will need to be configured to point to the new dockerized Mapserver instance.
This section describes the installation steps for the Mukau Mapserver component as a standalone. It also describes the steps inorder to push any changes made to the Mukau entrypoint.
In order to install Mukau Mapserver, the following softwares need to be installed first:
Mukau requires docker in order to function. Follow these instructions to install docker on Windows, and these instructions to install docker on Mac OS. If you are running Linux, follow the instructions on this page that are appropriate for the Linux distribution you are using.
- Introduction
- Installation in Development
- Deploy Latest Development (Local) updates to Staging/Production
- Other commands
Mukau Mapserver Repository builds an image of PostgreSQL/PostGIS and Mapserver. The Mukau system uses Mapserver as the main GIS engine for connecting to the database and rendering the layers for consumption by the frontend webmap in WMS standards. The OSGEO Mapserver instance connects to database and process the layers for visualization by use of mapfiles.
This componets brings in the ability to separate Mapserver to its own docker container, since it can live independently from the Mukau wagtail CMS. The MapViewer will need to be configured to point to the new dockerized Mapserver instance.
git clone https://github.com/icpac-igad/mukau-mapserver.gitTo create a .env file at the root of the project execute:
cp .env.sample .envThe .env file expects the following Environment Variables:
| Variable | Description |
|---|---|
| POSTGRES_DB_MS | The mukau database name |
| POSTGRES_USER_MS | |
| POSTGRES_PASSWORD_MS | password for the postgres user |
| POSTGRES_PORT_MS | |
| GIS_USER | gis |
| GIS_USER_PASS | password for the gis user |
| MAP_USER | mapuser |
| MAP_USER_PASS | password for the map user |
| MAPSERVER_PORT | port mukua mapserver will be running on |
| MAPSERVER_IMAGE_URI | The mapserver production image to use. This should be the URI to the image on a local or remote private registry, with the version tag e.g localhost:5000/mukau-mapserver:1.0 |
You can view the available tags for mukau-mapserver image at https://eahazardswatch.icpac.net/v2/mukau-mapserver/tags/list. This requires authentication.
This is the container that runs the mukau postgresql database. This container does not need a Dockerfile since it uses the official postgis/postgis:12-master image that already has Postgresql + Postgis installed. All the files required by this container will be inside the /database directory.
A sql folder needs to be created inside the /database/initdb/ folder. This directory will contain a list of scripts and sql files to initialize the mukau database with users and data.
These files must be downloaded (https://edo.jrc.ec.europa.eu/documents/mukau/pgsql_data.tar) and copied into this sql/ folder like so:
- gis_tables
- map_tables
Inside the folder /database/initdb/ there are two scripts as described below:
-
01.init.sh- Which will create the necessary database users and privileges -
02.database_data_population.sh- Which will populate the database using the sql files in the/database/initdb/sqlfolder
To make the database init file execute as a program, run:
chmod +x /database/initdb/01.init.shTo build the docker image, run:
sudo docker-compose buildsudo docker-compose up -dThe application should now be available at http:127.0.0.1:<MAPSERVER_PORT> . The <MAPSERVER_PORT> config is specified in the .env file.
Change the MAPSERVER_IMAGE_URI tag version in the .env file to a higher version. The convension used is that version numbers ending in an odd number (for example 1.1) are development versions, while versions ending in an even number (for example (1.2) are release versions.
For example, set this variable in the production .env:
MAPSERVER_IMAGE_URI=localhost:5000/mukau-mapserver:1.0To build the docker image, run:
sudo docker-compose buildMirror local tag (MUKAU-GEOCMS) with the remote tag(MUKAU-DOCKER).
sudo docker tag <local_tag> <remote_tag>For example:
sudo docker tag localhost:5000/mukau-mapserver:1.0 eahazardswatch.icpac.net/mukau-mapserver:1.0 Next, login to the eahazardswatch.icpac.net registry, execute the command below and provide appropriate credentials.
sudo docker login eahazardswatch.icpac.netPush the new image to the private registry, run:
sudo docker push <remote_tag>For example,
sudo docker push eahazardswatch.icpac.net/mukau-mapserver:1.0 To view the status of the database, run:
sudo docker logs mukau_mapserver_db -f
To view the status of the mapserver app, run:
sudo docker logs mapserver -f
To update the application, for example after changing the MAPSERVER_IMAGE_URI variable in .env file just run again:
sudo docker-compose stopthen
sudo docker-compose upTo stop and remove everything including volumes run (reset). NOTE: This will result in lose of any data save to the database
sudo docker-compose down --volumesdocker exec -it <DB_CONTAINER> psql -U <DB_USER> <DB_NAME>
sudo docker exec -it <DB_CONTAINER> pg_dump -U <DB_USER> -t <DB_TABLE> <DB_NAME> > 'path_to_ouput.sql'docker exec -t <DB_CONTAINER> pg_dumpall -c -U <DB_USER> | gzip > ./tmp/dump_$(date +"%Y-%m-%d_%H_%M_%S").gzgunzip < your_dump.sql.gz | docker exec -i <DB_CONTAINER> psql -U <DB_USER> -d <DB_NAME>Access to the running container (mukau-mapserver or any container name, the one defined in docker-compose.yml)
docker exec -it <CONTAINER> bash