Skip to content

Commit e4032f5

Browse files
author
Homme Zwaagstra
committed
Initial commit.
0 parents  commit e4032f5

File tree

6 files changed

+261
-0
lines changed

6 files changed

+261
-0
lines changed

Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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:2.1.1
9+
10+
MAINTAINER Homme Zwaagstra <hrz@geodata.soton.ac.uk>
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"]

README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Mapserver in Docker
2+
3+
[![](https://imagelayers.io/badge/geodata/mapserver:latest.svg)](https://imagelayers.io/?images=geodata/gdal: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+
<http://localhost:8080/?map=/usr/local/share/mapserver/examples/test.map&mode=map>.
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+
http://localhost:8080/?map=/maps/my-app.map

build.sh

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env bash
2+
3+
##
4+
# Build the docker image
5+
#
6+
7+
# Exit on any non-zero status.
8+
trap 'exit' ERR
9+
set -E
10+
11+
# Install the build dependencies.
12+
apt-get update -y
13+
apt-get install -y \
14+
wget \
15+
build-essential \
16+
cmake
17+
18+
# Install the runtime dependencies.
19+
apt-get install -y \
20+
libfcgi-dev \
21+
fcgiwrap \
22+
nginx \
23+
libcairo2-dev \
24+
libpixman-1-dev \
25+
libfreetype6-dev \
26+
libfribidi-dev \
27+
libharfbuzz-dev \
28+
libexempi-dev \
29+
apache2-dev \
30+
libapr1-dev \
31+
libaprutil1-dev \
32+
libxslt1-dev \
33+
ruby-dev \
34+
librsvg2-dev
35+
36+
# Create the mapserver build environment.
37+
cd /tmp
38+
wget http://download.osgeo.org/mapserver/mapserver-7.0.1.tar.gz
39+
tar -xzf mapserver-7.0.1.tar.gz
40+
cd mapserver-7.0.1
41+
mkdir build
42+
cd build
43+
44+
# Configure Mapserver. Inital list generated with:
45+
# grep -o -P "WITH_[\w]+" ../CMakeLists.txt | sort | uniq
46+
cmake -DCMAKE_PREFIX_PATH=/usr/local \
47+
-DWITH_APACHE_MODULE=OFF \
48+
-DWITH_CAIRO=ON \
49+
-DWITH_CAIROSVG=ON \
50+
-DWITH_CLIENT_WFS=ON \
51+
-DWITH_CLIENT_WMS=ON \
52+
-DWITH_CSHARP=OFF \
53+
-DWITH_CURL=ON \
54+
-DWITH_EXEMPI=ON \
55+
-DWITH_FCGI=ON \
56+
-DWITH_FRIBIDI=ON \
57+
-DWITH_GDAL=ON \
58+
-DWITH_GENERIC_NINT=ON \
59+
-DWITH_GEOS=ON \
60+
-DWITH_GIF=ON \
61+
-DWITH_HARFBUZZ=ON \
62+
-DWITH_ICONV=ON \
63+
-DWITH_JAVA=OFF \
64+
-DWITH_KML=ON \
65+
-DWITH_LIBXML2=ON \
66+
-DWITH_MSSQL2008=OFF \
67+
-DWITH_MYSQL=ON \
68+
-DWITH_OGR=ON \
69+
-DWITH_ORACLESPATIAL=OFF \
70+
-DWITH_ORACLE_PLUGIN=OFF \
71+
-DWITH_PERL=ON \
72+
-DWITH_PHP=OFF\
73+
-DWITH_PIXMAN=ON \
74+
-DWITH_POINT_Z_M=ON \
75+
-DWITH_POSTGIS=ON \
76+
-DWITH_PROJ=ON \
77+
-DWITH_PYTHON=ON \
78+
-DWITH_RSVG=ON\
79+
-DWITH_RUBY=ON \
80+
-DWITH_SOS=ON \
81+
-DWITH_SVGCAIRO=OFF\
82+
-DWITH_THREAD_SAFETY=ON \
83+
-DWITH_V8=OFF \
84+
-DWITH_WCS=ON \
85+
-DWITH_WFS=ON \
86+
-DWITH_WMS=ON \
87+
-DWITH_XMLMAPFILE=ON \
88+
../
89+
90+
# Build and install Mapserver.
91+
make
92+
make install
93+
94+
# Install the test mapfile.
95+
cd /tmp/build
96+
mkdir -p /usr/local/share/mapserver/examples
97+
cp test.map /usr/local/share/mapserver/examples/
98+
99+
# Set up the Nginx Mapserver configuration.
100+
cp ./mapserver /etc/nginx/sites-available/mapserver
101+
ln -s /etc/nginx/sites-available/mapserver /etc/nginx/sites-enabled/mapserver
102+
rm /etc/nginx/sites-enabled/default
103+
104+
# Set up the run script for starting services.
105+
cp ./run.sh /usr/local/bin/run.sh
106+
chmod +x /usr/local/bin/run.sh
107+
108+
# Clean up APT when done.
109+
apt-get autoremove -y
110+
apt-get clean -y
111+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

mapserver

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

run.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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;"

test.map

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

0 commit comments

Comments
 (0)