Skip to content

Commit 13d5439

Browse files
authored
Issue #438 - Upgrade Docker Image - Ubuntu Jammy - Python 3.10 fixes #452
#452 fixed #438 upgrade Dockerfile to Ubuntu Jammy - Python 3.10 #438 refine requirements
1 parent f64e481 commit 13d5439

11 files changed

+48
-53
lines changed

Dockerfile

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
FROM python:3.7-alpine
2-
3-
# Thanks to http://www.sandtable.com/reduce-docker-image-sizes-using-alpine
4-
# FROM debian:jessie
1+
FROM ubuntu:jammy
52

63
# Credits to yjacolin for providing first versions
74
LABEL original_developer="yjacolin <[email protected]>" \
@@ -10,12 +7,19 @@ LABEL original_developer="yjacolin <[email protected]>" \
107
# These are default values,
118
# Override when running container via docker(-compose)
129

10+
# ARGS
11+
ARG TZ="Etc/UTC"
12+
ARG LANG="en_US.UTF-8"
13+
ARG ADD_DEB_PACKAGES=""
14+
1315
# General ENV settings
1416
ENV LC_ALL="en_US.UTF-8" \
1517
LANG="en_US.UTF-8" \
1618
LANGUAGE="en_US.UTF-8" \
1719
\
1820
\
21+
DEB_PACKAGES="locales gunicorn python3-gunicorn python3-gevent python3-psycopg2 python3-lxml python3-pyproj" \
22+
DEB_BUILD_DEPS="make python3-pip" \
1923
# GHC ENV settings\
2024
ADMIN_NAME=admin \
2125
ADMIN_PWD=admin \
@@ -57,7 +61,7 @@ HOST=0.0.0.0 \
5761
PORT=80 \
5862
WSGI_WORKERS=4 \
5963
WSGI_WORKER_TIMEOUT=6000 \
60-
WSGI_WORKER_CLASS='eventlet' \
64+
WSGI_WORKER_CLASS='gevent' \
6165
\
6266
# GHC Core Plugins modules and/or classes, seldom needed to set: \
6367
# if not specified here or in Container environment \
@@ -69,9 +73,12 @@ WSGI_WORKER_CLASS='eventlet' \
6973
# GHC User Plugins, best be overridden via Container environment \
7074
GHC_USER_PLUGINS=''
7175

72-
RUN apk add --no-cache --virtual .build-deps gcc build-base libxslt-dev libxml2-dev linux-headers postgresql-dev \
73-
&& apk add --no-cache bash postgresql-client libxslt libxml2 tzdata openntpd proj-dev proj-util \
74-
&& rm -rf /var/cache/apk/* /tmp/* /var/tmp/*
76+
# Install operating system dependencies
77+
RUN \
78+
apt-get update \
79+
&& apt-get --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} ${ADD_DEB_PACKAGES} \
80+
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
81+
&& echo "For ${TZ} date=$(date)" && echo "Locale=$(locale)"
7582

7683
# Add standard files and Add/override Plugins
7784
# Alternative Entrypoints to run GHC jobs
@@ -81,8 +88,15 @@ COPY docker/scripts/*.sh docker/config_site.py docker/plugins /
8188
# Add Source Code
8289
COPY . /GeoHealthCheck
8390

84-
# Install and Remove build-related packages for smaller image size
85-
RUN chmod a+x /*.sh && bash install.sh && apk del .build-deps
91+
# Install
92+
RUN \
93+
chmod a+x /*.sh && ./install.sh \
94+
# Cleanup TODO: remove unused Locales and TZs
95+
&& apt-get remove --purge -y ${DEB_BUILD_DEPS} \
96+
&& apt-get clean \
97+
&& apt autoremove -y \
98+
&& rm -rf /var/lib/apt/lists/*
99+
86100

87101
# For SQLite
88102
VOLUME ["/GeoHealthCheck/DB/"]

docker/scripts/configure.sh

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
echo "START /configure.sh"
55

6-
source /venv/bin/activate .
7-
86
# Make sure PYTHONPATH includes GeoHealthCheck
97
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH
108

@@ -14,9 +12,9 @@ echo "Using DB_TYPE=${DB_TYPE}"
1412

1513
# Create DB shorthand
1614
function create_db() {
17-
pushd /GeoHealthCheck/
15+
pushd /GeoHealthCheck/ || exit 1
1816
paver create -u ${ADMIN_NAME} -p ${ADMIN_PWD} -e ${ADMIN_EMAIL}
19-
popd
17+
popd || exit 1
2018
}
2119

2220
# Init actions per DB type

docker/scripts/cron-jobs-daily.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# /bin/bash
1+
#!/bin/bash
22

3-
source /venv/bin/activate .
4-
python /GeoHealthCheck/GeoHealthCheck/models.py flush
3+
python3 /GeoHealthCheck/GeoHealthCheck/models.py flush
54

docker/scripts/cron-jobs-hourly.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# /bin/bash
1+
#!/bin/bash
22

3-
source /venv/bin/activate .
43

54
# Copy possible mounted Plugins into app tree
65
if [ -d /plugins ]

docker/scripts/install.sh

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#!/bin/bash
22

3-
cd /
4-
python3 -m venv venv
5-
source /venv/bin/activate
6-
73
# GHC Source was added in Dockerfile, install
84
# NB we use gunicorn/eventlet async workers as some Probes may take a long time
95
# e.g. fetching Metadata (Caps) and testing all layers
106
# Install Python packages for installation and setup
11-
pip install --upgrade pip
12-
pip install -I -r /GeoHealthCheck/docker/scripts/requirements.txt
137

14-
cd /GeoHealthCheck
8+
pushd /GeoHealthCheck || exit 1
9+
10+
# Docker-specific deps
11+
pip install -r docker/scripts/requirements.txt
1512

1613
# Sets up GHC itself
1714
paver setup
@@ -27,3 +24,5 @@ then
2724
# Remove to allow later Volume mount of /plugins
2825
rm -rf /plugins
2926
fi
27+
28+
popd || exit 1

docker/scripts/requirements.txt

-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
Paver==1.3.4
2-
psycopg2==2.9.2
3-
eventlet==0.30.2
4-
gunicorn==20.1.0
5-
Werkzeug==0.16.1
6-
tzlocal<3.0

docker/scripts/run-runner.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
echo "START /run-runner.sh"
44

55
# Set the timezone.
6-
/set-timezone.sh
6+
# /set-timezone.sh
77

88
# Configure: DB and plugins.
99
/configure.sh
1010

11-
# Run the GHC daemon process
12-
# that schedules healthcheck jobs
13-
source /venv/bin/activate .
14-
1511
# Make sure PYTHONPATH includes GeoHealthCheck
1612
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH
1713

docker/scripts/run-tests.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@
88
echo "START /run-tests.sh"
99

1010
# Set the timezone.
11-
/set-timezone.sh
11+
# /set-timezone.sh
1212

1313
# Configure: DB and plugins.
1414
/configure.sh
1515

16-
# Run the GHC daemon process
17-
# that schedules healthcheck jobs
18-
source /venv/bin/activate .
19-
2016
# Make sure PYTHONPATH includes GeoHealthCheck
2117
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH
2218

docker/scripts/run-web.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
echo "START /run-web.sh"
66

77
# Set the timezone.
8-
/set-timezone.sh
8+
# /set-timezone.sh
99

1010
# Configure: DB and plugins.
1111
/configure.sh
1212

13-
source /venv/bin/activate .
1413
# Make sure PYTHONPATH includes GeoHealthCheck
1514
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH
1615

pavement.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def create(options):
179179

180180
if all([username, password, email]):
181181
args = '%s %s %s' % (username, password, email)
182-
sh('python %s create %s' % (path('GeoHealthCheck/models.py'), args))
182+
sh('python3 %s create %s' % (path('GeoHealthCheck/models.py'), args))
183183

184184

185185
@task
@@ -206,7 +206,7 @@ def upgrade():
206206

207207
info('Upgrading database...')
208208
with pushd(path('%s/GeoHealthCheck' % BASEDIR)):
209-
sh('python manage.py db upgrade')
209+
sh('python3 manage.py db upgrade')
210210

211211

212212
@task
@@ -302,13 +302,13 @@ def update_translations():
302302
@task
303303
def runner_daemon():
304304
"""Run the HealthCheck runner daemon scheduler"""
305-
sh('python %s' % path('GeoHealthCheck/scheduler.py'))
305+
sh('python3 %s' % path('GeoHealthCheck/scheduler.py'))
306306

307307

308308
@task
309309
def run_healthchecks():
310310
"""Run all HealthChecks directly"""
311-
sh('python %s' % path('GeoHealthCheck/healthcheck.py'))
311+
sh('python3 %s' % path('GeoHealthCheck/healthcheck.py'))
312312

313313

314314
def sphinx_make():
@@ -322,4 +322,4 @@ def sphinx_make():
322322
@task
323323
def run_tests():
324324
"""Run all tests"""
325-
sh('python %s' % path('tests/run_tests.py'))
325+
sh('python3 %s' % path('tests/run_tests.py'))

requirements.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Jinja2==2.11.3
1+
Jinja2==3.0.3
22
markupsafe==2.0.1
33
Flask==1.1.1
44
Flask-Babel==0.12.2
@@ -8,13 +8,13 @@ Flask-Script==2.0.6
88
SQLAlchemy==1.3.8
99
Flask-SQLAlchemy==2.4.0
1010
itsdangerous==1.1.0
11-
pyproj==2.6.1.post1
12-
lxml==4.9.1
11+
pyproj >=2.6.1
12+
lxml >= 4.8.0, <= 4.9.2
1313
OWSLib==0.20.0
1414
jsonschema==3.0.2 # downgrade from 3.2.0 on sept 29, 2020, issue 331, consider better fix
1515
openapi-spec-validator==0.2.8
16-
Sphinx==4.1.1
17-
sphinx-rtd-theme==0.5.2
16+
Sphinx==5.3.0
17+
sphinx-rtd-theme==1.2.2
1818
requests>=2.23.0
1919
WTForms==2.2.1
2020
APScheduler==3.6.1

0 commit comments

Comments
 (0)