Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
FROM ubuntu:24.04
LABEL maintainer="datapunt@amsterdam.nl"
ARG DEBIAN_FRONTEND=noninteractive
# build-time inputs
ARG EXTRA_ARG1
ARG EXTRA_ARG2

ENV MAP_URL="${EXTRA_ARG1:-http://localhost:8383}" \
LEGEND_URL="${EXTRA_ARG2:-http://localhost:8383}"

# echo domain variables used
RUN echo "Using ARGS=$EXTRA_ARG1 LEGEND_URL=$EXTRA_ARG2"
RUN echo "Using MAP_URL=$MAP_URL LEGEND_URL=$LEGEND_URL"

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
apache2 \
Expand All @@ -16,15 +27,22 @@ RUN apt-get update -y \

# Enable these Apache modules
RUN a2enmod actions cgid headers rewrite
# rm default access log
RUN a2disconf other-vhosts-access-log

# Configure localhost in Apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN sed -i '/^Listen 80$/d' /etc/apache2/ports.conf

#config file
COPY mapserver.conf /usr/local/etc/
RUN echo "SetEnv MAPSERVER_CONFIG_FILE \"/usr/local/etc/mapserver.conf\"" >> /etc/apache2/apache2.conf

# apache config
RUN rm /etc/apache2/mods-enabled/alias.conf
COPY docker/conf/custom.conf /etc/apache2/conf-enabled/
COPY docker/conf/ports.conf /etc/apache2/ports.conf

COPY docker/000-default.conf /etc/apache2/sites-available/
COPY docker/docker-entrypoint.sh /bin
COPY epsg /usr/share/proj
Expand All @@ -35,8 +53,14 @@ RUN groupmod -o -g 999 www-data
RUN mkdir /var/lock/apache2 && mkdir /var/run/apache2
RUN chown -R 999:999 /var/lock/apache2 && chown -R 999:999 /var/run/apache2 && chown -R 999:999 /var/log/apache2/
RUN chown -R 999:999 /srv/ && chown -R 999:999 /etc/apache2/
# maps
COPY --chown=999:999 . /srv/mapserver/
RUN for i in /srv/mapserver/*.map; do echo $i; done
RUN : "${MAP_URL:?MAP_URL not set}" \
&& : "${LEGEND_URL:?LEGEND_URL not set}" \
&& for i in /srv/mapserver/*.map; do sed -i 's#MAP_URL_REPLACE#'"$MAP_URL"'#g' $i ; sed -i 's#LEGEND_URL_REPLACE#'"$LEGEND_URL"'#g' $i; done
RUN rm -rf /srv/mapserver/private
RUN python3 /srv/mapserver/tools/make_indexjson.py /srv/mapserver/*.map > /srv/mapserver/index.json

EXPOSE 8080

Expand Down
2 changes: 1 addition & 1 deletion docker/000-default.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Never run the server with LOCAL set in production

<VirtualHost *:80>
<VirtualHost *:8080>
ServerAdmin datapunt@amsterdam.nl
DocumentRoot /srv/mapserver

Expand Down
3 changes: 3 additions & 0 deletions docker/conf/custom.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Timeout 600
ErrorLog /dev/stderr
CustomLog /dev/stdout combined
1 change: 1 addition & 0 deletions docker/conf/ports.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Listen 8080
20 changes: 0 additions & 20 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,11 @@ CONNECTION "host=${DATASERVICES_DB_HOST} dbname=${DATASERVICES_DB_NAME} user=${D
PROCESSING "CLOSE_CONNECTION=DEFER"
EOF

# Configure apache to redirect errors to stderr.
# The mapserver will redirect errors to apache errorstream (see header.inc and private/header.inc)
# and apache will then redirect this to stderr, which will then be redirected to syslog/kibana.
# ref: http://mapserver.org/optimization/debugging.html#steps-to-enable-mapserver-debugging
# https://serverfault.com/questions/711168/writing-apache2-logs-to-stdout-stderr
sed -i 's/ErrorLog .*/ErrorLog \/dev\/stderr/' /etc/apache2/apache2.conf
sed -i 's/Timeout 300/Timeout 600/' /etc/apache2/apache2.conf
# set listen port to non-privileged port
sed -i '0,/Listen [0-9]*/s//Listen 8080/' /etc/apache2/ports.conf
sed -i s/\<VirtualHost.*/\<VirtualHost\ \*\:8080\>/ /etc/apache2/sites-enabled/000-default.conf

# Replace actual location of the mapserver depending on the environment
shopt -s globstar nullglob

for i in **/*.map; do
sed -i 's#MAP_URL_REPLACE#'"$MAP_URL"'#g' $i
sed -i 's#LEGEND_URL_REPLACE#'"$LEGEND_URL"'#g' $i
done

mkdir -p /srv/mapserver/config
# python3 /srv/mapserver/tools/make_mapfile_config.py > /srv/mapserver/sld/config.json

echo Make JSON index of maps
python3 /srv/mapserver/tools/make_indexjson.py /srv/mapserver/*.map > /srv/mapserver/index.json

echo Starting server
# Apache gets grumpy about PID files pre-existing
rm -f /var/run/apache2/apache2.pid
Expand Down