Skip to content

Commit

Permalink
Jammy updates to master branch (#104)
Browse files Browse the repository at this point in the history
* Docker changes for dev-31: (#98)

- Testing with wmo-staging PPA
- Check to ensure required ENVs are set
- Add SSL ceritficate volume mounts for dev-31

Co-authored-by: Geomet user for nightly docker builds <[email protected]>

* ensure MAP.WEB.METADATA wms_allow_getmap_without_styles set to true (#101)

* add MapServer configuration file for MapServer 8 (#102)

* Docker changes for dev-31 and MapServer 8: (#98) (#100)

- Testing with wmo-staging PPA
- Check to ensure required ENVs are set
- Add SSL ceritficate volume mounts for dev-31

Co-authored-by: Etienne Pelletier <[email protected]>

* Update deploy-nightly-docker.sh

---------

Co-authored-by: Geomet user for nightly docker builds <[email protected]>
Co-authored-by: Etienne Pelletier <[email protected]>
Co-authored-by: Tom Kralidis <[email protected]>
  • Loading branch information
4 people authored Jan 28, 2025
1 parent 35dfac6 commit 1fc896b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 11 deletions.
14 changes: 9 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM ubuntu:focal
FROM ubuntu:jammy

# Allow for change during docker build-time
ARG GEOMET_CLIMATE_URL=https://geomet-dev-22-nightly.cmc.ec.gc.ca/geomet-climate
ARG GEOMET_CLIMATE_URL=https://geomet-dev-31-nightly.edc-mtl.ec.gc.ca/geomet-climate

ENV BASEDIR=/data/web/geomet-climate-nightly \
DOCKERDIR=/data/web/geomet-climate-nightly/docker \
Expand All @@ -15,15 +15,19 @@ ENV BASEDIR=/data/web/geomet-climate-nightly \
GEOMET_CLIMATE_ES_URL=https://${GEOMET_CLIMATE_ES_USERNAME}:${GEOMET_CLIMATE_ES_PASSWORD}@localhost:9200 \
GEOMET_CLIMATE_OWS_DEBUG=5
# GEOMET_CLIMATE_OWS_LOG=/tmp/geomet-climate-ows.log
ENV DEBIAN_FRONTEND=noninteractive
ENV MAPSERVER_CONFIG_FILE=${GEOMET_CLIMATE_BASEDIR}/mapserver.conf

WORKDIR $BASEDIR

# Install system dependencies
RUN apt update && apt install -y software-properties-common && \
## Add this WMO PPA
add-apt-repository ppa:gcpp-kalxas/wmo && apt update && \
## Add this UbuntuGIS PPA (mappyfile)
add-apt-repository ppa:ubuntugis/ppa && apt update && \
## Add this WMO PPA (mapserver)
add-apt-repository ppa:gcpp-kalxas/wmo-staging && apt update && \
## Install dependencies from debian/control
apt install -y mapserver-bin python3-all python3-pip python3-click python3-gdal python3-mappyfile python3-mapscript python3-matplotlib python3-numpy python3-pyproj python3-yaml proj-bin proj-data && \
apt install -y mapserver-bin python3-all python3-pip python3-click python3-gdal python3-mappyfile python3-mapscript python3-matplotlib python3-numpy python3-pyproj python3-yaml proj-bin proj-data python3-certifi && \
# remove transient packages
apt clean autoclean && apt autoremove --yes && rm -fr /var/lib/{apt,dpkg,cache,log}/

Expand Down
14 changes: 13 additions & 1 deletion deploy/nightly-docker/deploy-nightly-docker.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# =================================================================
#
# Copyright (c) 2020 Government of Canada
# Copyright (c) 2025 Government of Canada
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -28,6 +28,18 @@ DATETIME=`date +%Y%m%d`
TIMESTAMP=`date +%Y%m%d.%H%M`
NIGHTLYDIR=geomet-climate-$TIMESTAMP

# Check if GEOMET_CLIMATE_ES_USERNAME is set and not empty
if [ -z "$GEOMET_CLIMATE_ES_USERNAME" ]; then
echo "Error: Environment variable GEOMET_CLIMATE_ES_USERNAME is not set or is empty."
exit 1
fi

# Check if GEOMET_CLIMATE_ES_PASSWORD is set and not empty
if [ -z "$GEOMET_CLIMATE_ES_PASSWORD" ]; then
echo "Error: Environment variable GEOMET_CLIMATE_ES_PASSWORD is not set or is empty."
exit 1
fi

echo "Deleting nightly builds > $DAYSTOKEEP days old"

cd $BASEDIR
Expand Down
2 changes: 1 addition & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.ym
docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml up -d

# test WMS endpoint
curl "http://geomet-dev-22.cmc.ec.gc.ca:8099/?service=WMS&version=1.3.0&request=GetCapabilities"
curl "http://geomet-dev-31.edc-mtl.ec.gc.ca:8099/?service=WMS&version=1.3.0&request=GetCapabilities"
```
3 changes: 1 addition & 2 deletions docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ services:
geomet-climate-nightly:
build:
args:
GEOMET_CLIMATE_URL: https://geomet-dev-22-nightly.cmc.ec.gc.ca/geomet-climate
# GEOMET_CLIMATE_URL: http://geomet-dev-22.cmc.ec.gc.ca:8099
GEOMET_CLIMATE_URL: https://geomet-dev-31-nightly.edc-mtl.ec.gc.ca/geomet-climate
environment:
GEOMET_CLIMATE_OWS_DEBUG: 5
GEOMET_CLIMATE_ES_URL: http://${GEOMET_CLIMATE_ES_USERNAME}:${GEOMET_CLIMATE_ES_PASSWORD}@localhost:9200
Expand Down
7 changes: 5 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ services:
build:
context: ..
network_mode: host
hostname: geomet-dev-22-docker.cmc.ec.gc.ca
hostname: geomet-dev-31-docker.cmc.ec.gc.ca
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- "/data/geomet/feeds/dd/climate:/data/geomet/feeds/dd/climate:ro"

# below is required so that the container has certificates required
# for SSL-enabled connections to internal hosts (geomet-dev-xx.edc-mtl.ec.gc.ca)
- "/etc/ssl/certs:/etc/ssl/certs:ro" # mount host ssl certs
- "/usr/local/share/ca-certificates/:/usr/local/share/ca-certificates/:ro" # mount host ca-certificates
networks:
default:
name: geomet_default
Expand Down
25 changes: 25 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
BASEDIR=/data/web/geomet-climate-nightly
GEOMET_CLIMATE_BASEDIR=$BASEDIR/build
GEOMET_CLIMATE_ES_URL=${GEOMET_CLIMATE_ES_URL}
MAPSERVER_CONFIG_FILE=${MAPSERVER_CONFIG_FILE}
MS_MAP_PATTERN=$GEOMET_CLIMATE_BASEDIR/mapfile/.*

# replace localhost ES URL with docker-host URL to ES
if [ $GEOMET_CLIMATE_ES_URL != "" ]
Expand All @@ -13,6 +15,26 @@ fi

cd $BASEDIR

# Ensure the directory for MAPSERVER_CONFIG_FILE exists
mkdir -p "$(dirname "$MAPSERVER_CONFIG_FILE")"

# Ensure MAPSERVER_CONFIG_FILE exists; create it if it doesn't
if [ ! -f "$MAPSERVER_CONFIG_FILE" ]; then
cat > "$MAPSERVER_CONFIG_FILE" <<EOF
CONFIG
ENV
MS_MAP_PATTERN "$MS_MAP_PATTERN"
END
END
EOF
echo "MapServer config file created: $MAPSERVER_CONFIG_FILE"
else
echo "MapServer config file already exists: $MAPSERVER_CONFIG_FILE"
fi

# Set appropriate permissions for the config file
chmod 644 "$MAPSERVER_CONFIG_FILE"

echo "Generating geomet-climate VRTs for all layers..."
geomet-climate vrt generate
echo "Generating geomet-climate tileindex for all layers..."
Expand All @@ -36,6 +58,9 @@ mapserv -nh QUERY_STRING="map=$GEOMET_CLIMATE_BASEDIR/mapfile/geomet-climate-WCS
echo "Caching WCS (French)..."
mapserv -nh QUERY_STRING="map=$GEOMET_CLIMATE_BASEDIR/mapfile/geomet-climate-WCS-fr.map&lang=fr&service=WCS&version=2.1.0&request=GetCapabilities" > $GEOMET_CLIMATE_BASEDIR/geomet-climate-WCS-2.0.1-capabilities-fr.xml && mv -f $GEOMET_CLIMATE_BASEDIR/geomet-climate-WCS-2.0.1-capabilities-fr.xml $GEOMET_CLIMATE_BASEDIR/mapfile




echo "Done."

# server runs
Expand Down
1 change: 1 addition & 0 deletions geomet-climate.env
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export GEOMET_CLIMATE_URL=https://geo.weather.gc.ca/geomet-climate
#export GEOMET_CLIMATE_ES_USERNAME=foo
#export GEOMET_CLIMATE_ES_PASSWORD=bar
export GEOMET_CLIMATE_ES_URL=http://${GEOMET_CLIMATE_ES_USERNAME}:${GEOMET_CLIMATE_ES_PASSWORD}@localhost:9200
export MAPSERVER_CONFIG_FILE=${GEOMET_CLIMATE_BASEDIR}/mapserver.conf
16 changes: 16 additions & 0 deletions geomet_climate/mapfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@

THISDIR = os.path.dirname(os.path.realpath(__file__))

MAPSERVER_CONFIG = f'''CONFIG
ENV
MS_MAP_PATTERN "{BASEDIR}/mapfile/.*"
END
END
'''


def gen_web_metadata(m, c, service, url):
"""
Expand Down Expand Up @@ -71,6 +78,7 @@ def gen_web_metadata(m, c, service, url):
d['ows_fees'] = c['identification']['fees']
d['ows_accessconstraints'] = c['identification']['accessconstraints']
d['wms_getmap_formatlist'] = 'image/png,image/jpeg'
d['wms_allow_getmap_without_styles'] = 'true'
d['ows_extent'] = ','.join(str(x) for x in m['extent'])
d['ows_role'] = c['provider']['role']
d['ows_http_max_age'] = 604800 # cache for one week
Expand Down Expand Up @@ -395,6 +403,14 @@ def mapfile():
def generate(ctx, service, layer):
"""generate mapfile"""

# generate MapServer config file if not present
mapserver_config_file = os.path.join(BASEDIR, 'mapserver.conf')

if not os.path.exists(mapserver_config_file):
os.makedirs(BASEDIR, exist_ok=True)
with open(mapserver_config_file, 'w+') as f:
f.write(MAPSERVER_CONFIG)

output_dir = '{}{}mapfile'.format(BASEDIR, os.sep)
template_dir = '{}{}mapfile{}template'.format(BASEDIR, os.sep, os.sep)

Expand Down
1 change: 1 addition & 0 deletions tests/geomet-climate-test.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export GEOMET_CLIMATE_BASEDIR=.
export GEOMET_CLIMATE_DATADIR=tests/data/climate
export GEOMET_CLIMATE_CONFIG=./tests/geomet-climate-test.yml
export GEOMET_CLIMATE_URL=http://localhost:8099
export MAPSERVER_CONFIG_FILE=${GEOMET_CLIMATE_BASEDIR}/mapserver.conf

0 comments on commit 1fc896b

Please sign in to comment.