Skip to content

Commit

Permalink
Make MapServer work for development again (#594)
Browse files Browse the repository at this point in the history
* Set base image using .env and update MapServer port number.

* Specify MAP_URL and LEGEND_URL for local development.

* Write conn files as root.
  • Loading branch information
emacgillavry authored Sep 11, 2024
1 parent cc27177 commit 714be5a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
POSTGRES_DATA_DIR=
POSTGRES_PASSWORD=
POSTGRES_PASSWORD=
BASE_IMAGE=
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
FROM ubuntu:22.04
LABEL maintainer="[email protected]"
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ="Europe/Amsterdam"

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
apache2 \
cgi-mapserver \
curl \
gdal-bin \
gdal-data \
gosu \
mapserver-bin \
python3-pip \
wget \
Expand Down Expand Up @@ -38,5 +37,4 @@ RUN rm -rf /srv/mapserver/private

EXPOSE 8080

USER www-data
CMD /bin/docker-entrypoint.sh
3 changes: 3 additions & 0 deletions Dockerfile.topografie
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ ARG BASE_IMAGE

FROM ${BASE_IMAGE}

USER root
# Copy referentiekaarten mapfiles into the root dir so they will be served

RUN rm -rf /srv/mapserver/private
COPY /referentiekaarten/ /srv/mapserver/
RUN chown -R 999:999 /srv/ && chown -R 999:999 /etc/apache2/
USER www-data
22 changes: 13 additions & 9 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ services:
build:
context: .
ports:
- "8383:80"
- "8383:8080"
environment:
# Used by apache to allow complete access for local dev
LOCAL: "true"
Expand All @@ -55,8 +55,8 @@ services:
DATASERVICES_DB_PASSWORD_PATH: insecure
DATASERVICES_DB_HOST: database

MAP_URL: "http://map"
LEGEND_URL: "http://map"
MAP_URL: "http://localhost:8383"
LEGEND_URL: "http://localhost:8383"

volumes:
- .:/srv/mapserver/
Expand All @@ -65,8 +65,10 @@ services:
build:
context: .
dockerfile: Dockerfile.private
args:
BASE_IMAGE: ${BASE_IMAGE}
ports:
- "8384:80"
- "8384:8080"
environment:
# Used by apache to allow complete access for local dev
LOCAL: "true"
Expand All @@ -81,8 +83,8 @@ services:
DATASERVICES_DB_PASSWORD_PATH: insecure
DATASERVICES_DB_HOST: database

MAP_URL: "http://map"
LEGEND_URL: "http://map"
MAP_URL: "http://localhost:8383"
LEGEND_URL: "http://localhost:8383"

volumes:
- ./tools/:/srv/mapserver/tools/
Expand All @@ -95,8 +97,10 @@ services:
build:
context: .
dockerfile: Dockerfile.topografie
args:
BASE_IMAGE: ${BASE_IMAGE}
ports:
- "8385:80"
- "8385:8080"
environment:
# Used by apache to allow complete access for local dev
LOCAL: "true"
Expand All @@ -111,8 +115,8 @@ services:
DATASERVICES_DB_PASSWORD_PATH: insecure
DATASERVICES_DB_HOST: database

MAP_URL: "http://map"
LEGEND_URL: "http://map"
MAP_URL: "http://localhost:8383"
LEGEND_URL: "http://localhost:8383"

volumes:
- ./tools/:/srv/mapserver/tools/
Expand Down
2 changes: 2 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ CONNECTION "host=${DATASERVICES_DB_HOST} dbname=${DATASERVICES_DB_NAME} user=${D
PROCESSING "CLOSE_CONNECTION=DEFER"
EOF

gosu www-data bash

# 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.
Expand Down

0 comments on commit 714be5a

Please sign in to comment.