├── run.sh ├── Dockerfile ├── test.map ├── mapserver └── README.md /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ## 4 | # Run Nginx with the mapserver FastCGI service. 5 | # 6 | 7 | # Exit on any non-zero status. 8 | trap 'exit' ERR 9 | set -E 10 | 11 | service fcgiwrap start 12 | nginx -g "daemon off;" 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ## 2 | # geodata/mapserver 3 | # 4 | # MapServer compiled with a broad range of options enabled including a 5 | # comprehensive GDAL library. 6 | # 7 | 8 | FROM geodata/gdal:latest 9 | 10 | MAINTAINER Homme Zwaagstra 11 | 12 | USER root 13 | 14 | # Install the application. 15 | ADD . /tmp/build/ 16 | RUN /tmp/build/build.sh 17 | 18 | EXPOSE 80 19 | 20 | # Start the fcgi and web servers. 21 | CMD ["/usr/local/bin/run.sh"] 22 | -------------------------------------------------------------------------------- /test.map: -------------------------------------------------------------------------------- 1 | # A valid mapfile used for testing 2 | MAP 3 | NAME valid 4 | STATUS ON 5 | EXTENT 0 0 4000 3000 6 | SIZE 400 300 7 | IMAGECOLOR 200 255 255 8 | CONFIG "CGI_CONTEXT_URL" "1" 9 | 10 | WEB 11 | IMAGEPATH "./" 12 | IMAGEURL "/tmp/" 13 | END 14 | 15 | LAYER 16 | NAME "credits" 17 | STATUS DEFAULT 18 | TRANSFORM FALSE 19 | TYPE POINT 20 | CLASSGROUP "group1" 21 | FEATURE 22 | POINTS 23 | 200 150 24 | END 25 | TEXT 'Hello world. Mapserver rocks.' 26 | END 27 | CLASS 28 | GROUP "group1" 29 | LABEL 30 | TYPE BITMAP 31 | STYLE 32 | GEOMTRANSFORM 'labelpnt' 33 | COLOR 0 0 0 34 | END 35 | END 36 | END 37 | CLASS 38 | GROUP "group2" 39 | LABEL 40 | TYPE BITMAP 41 | STYLE 42 | GEOMTRANSFORM 'labelpnt' 43 | COLOR 0 0 255 44 | END 45 | END 46 | END 47 | END 48 | 49 | END 50 | -------------------------------------------------------------------------------- /mapserver: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80 default_server; 3 | listen [::]:80 default_server ipv6only=on; 4 | 5 | error_log stderr; 6 | access_log /dev/stdout; 7 | 8 | # Make site accessible from http://localhost/ 9 | server_name localhost; 10 | 11 | location / { 12 | gzip off; 13 | fastcgi_pass unix:/var/run/fcgiwrap.socket; 14 | fastcgi_param SCRIPT_FILENAME /usr/local/bin/mapserv; 15 | fastcgi_param QUERY_STRING $query_string; 16 | fastcgi_param REQUEST_METHOD $request_method; 17 | fastcgi_param CONTENT_TYPE $content_type; 18 | fastcgi_param CONTENT_LENGTH $content_length; 19 | fastcgi_param GATEWAY_INTERFACE CGI/1.1; 20 | fastcgi_param SERVER_SOFTWARE nginx; 21 | fastcgi_param SCRIPT_NAME $fastcgi_script_name; 22 | fastcgi_param REQUEST_URI $request_uri; 23 | fastcgi_param DOCUMENT_URI $document_uri; 24 | fastcgi_param DOCUMENT_ROOT $document_root; 25 | fastcgi_param SERVER_PROTOCOL $server_protocol; 26 | fastcgi_param REMOTE_ADDR $remote_addr; 27 | fastcgi_param REMOTE_PORT $remote_port; 28 | fastcgi_param SERVER_ADDR $server_addr; 29 | fastcgi_param SERVER_PORT $server_port; 30 | fastcgi_param SERVER_NAME $server_name; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Mapserver in Docker 2 | 3 | [![](https://imagelayers.io/badge/geodata/mapserver:latest.svg)](https://imagelayers.io/?images=geodata/mapserver:latest) 4 | 5 | This is an Ubuntu derived image containing 6 | [MapServer](http://www.mapserver.org/) running under the Nginx web server as a 7 | FastCGI service. Mapserver is compiled with a broad range of options, including 8 | a comprehensive version of GDAL. 9 | 10 | Each branch in the git repository corresponds to a supported Map server version 11 | (e.g. `7.0.1`) with the master branch following MapServer master. These branch 12 | names are reflected in the image tags on the Docker Hub. 13 | 14 | ## Usage 15 | 16 | The HTTP endpoint for the MapServer `mapserv` CGI binary is the root URL at 17 | `/`. This can be tested by mapping the web server's port `80` on the container 18 | to port `8080` on the host: 19 | 20 | docker run -p 8080:80 geodata/mapserver 21 | 22 | You can then test using the included example mapfile by pointing your browser at 23 | . 24 | 25 | Other than the test mapfile located at 26 | `/usr/local/share/mapserver/examples/test.map` no other MapServer configuration 27 | is provided: you will need to provide appropriate mapfiles and ancilliary 28 | configuration files (e.g. templates) for running Mapserver, either via volume or 29 | bind mounts or in a derived image. E.g. assuming you have the mapfile 30 | 'my-app.map' in the current working directory, you could mount it as: 31 | 32 | docker run -v $(pwd):/maps:ro -p 8080:80 geodata/mapserver 33 | 34 | You will then be able to access the map from your host machine at 35 | . 36 | --------------------------------------------------------------------------------