From 092ed87541f42b3c4449b741919017f3a0f68d88 Mon Sep 17 00:00:00 2001 From: Kevin Ngai Date: Mon, 25 Nov 2024 16:47:15 -0800 Subject: [PATCH] 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 - point to kngai repo for deploy-nightly-docker.sh --- Dockerfile | 14 +++++++---- .../nightly-docker/deploy-nightly-docker.sh | 17 +++++++++++-- docker/README.md | 2 +- docker/docker-compose.override.yml | 3 +-- docker/docker-compose.yml | 7 ++++-- docker/entrypoint.sh | 25 +++++++++++++++++++ geomet-climate.env | 1 + tests/geomet-climate-test.env | 1 + 8 files changed, 58 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 76d5a9a..9f1a572 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ @@ -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}/ diff --git a/deploy/nightly-docker/deploy-nightly-docker.sh b/deploy/nightly-docker/deploy-nightly-docker.sh index 31765e5..d3d4a06 100644 --- a/deploy/nightly-docker/deploy-nightly-docker.sh +++ b/deploy/nightly-docker/deploy-nightly-docker.sh @@ -19,7 +19,8 @@ # ================================================================= BASEDIR=/data/web/geomet-climate-nightly -GEOMET_CLIMATE_GITREPO=https://github.com/ECCC-CCCS/geomet-climate.git +# GEOMET_CLIMATE_GITREPO=https://github.com/ECCC-CCCS/geomet-climate.git +GEOMET_CLIMATE_GITREPO=https://github.com/kngai/geomet-climate.git DAYSTOKEEP=7 # you should be okay from here @@ -28,6 +29,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 @@ -44,7 +57,7 @@ done rm -fr latest echo "Generating nightly build for $TIMESTAMP" mkdir $NIGHTLYDIR && cd $NIGHTLYDIR -git clone $GEOMET_CLIMATE_GITREPO . -b master --depth=1 +git clone $GEOMET_CLIMATE_GITREPO . -b jammy --depth=1 echo "Stopping/building/starting Docker setup" docker compose -f docker/docker-compose.yml -f docker/docker-compose.override.yml build --no-cache diff --git a/docker/README.md b/docker/README.md index e789d17..c52dcc7 100644 --- a/docker/README.md +++ b/docker/README.md @@ -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" ``` diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml index cfe9f8f..de39119 100644 --- a/docker/docker-compose.override.yml +++ b/docker/docker-compose.override.yml @@ -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 diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 9ddebe4..ca9c150 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -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 diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index ec3e51c..7ceb673 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -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 != "" ] @@ -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" < $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 diff --git a/geomet-climate.env b/geomet-climate.env index 1dffbaa..8060e47 100644 --- a/geomet-climate.env +++ b/geomet-climate.env @@ -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 diff --git a/tests/geomet-climate-test.env b/tests/geomet-climate-test.env index bbdbb41..8567854 100644 --- a/tests/geomet-climate-test.env +++ b/tests/geomet-climate-test.env @@ -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