Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker changes for dev-31 and MapServer 8 #100

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
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
17 changes: 15 additions & 2 deletions deploy/nightly-docker/deploy-nightly-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
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
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