Skip to content
Open
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
17 changes: 17 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# VCS
.git
.gitignore

# Local pixi environment (built inside the image via `pixi install`)
.pixi

# Local dev / bootstrap artifacts (regenerated in the image)
instance
report.md
docs/_build
GeoHealthCheck/static/lib
GeoHealthCheck/data.db

# Tooling / caches
.pytest_cache
**/__pycache__
*.pyc
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 79
exclude = .git,.cache,docs,docker,build,dist,GeoHealthCheck/migrations
exclude = .git,.cache,.pixi,docs,docker,build,dist,GeoHealthCheck/migrations
# max-complexity = 38
45 changes: 23 additions & 22 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# https://github.com/geopython/pycsw/blob/master/.github/workflows/main.yml
#
# Author: Just van den Broecke - 2021
# Migrated to pixi - 2026
#
name: Main GHC CI ⚙️

Expand All @@ -10,44 +11,44 @@ on: [ push, pull_request ]
jobs:
main:
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- python-version: 3.12.3
steps:
- name: Checkout ✅
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python ${{ matrix.python-version }} 🐍
uses: actions/setup-python@v2
# Installs pixi (pinned) and the `dev` environment from the committed
# pixi.lock (locked: true fails if the lock is out of sync). Python and
# all dependencies come from the lock, so no separate setup-python step.
- name: Setup pixi 🧰
uses: prefix-dev/setup-pixi@v0.10.0
with:
python-version: ${{ matrix.python-version }}

- name: Install Requirements 📦
run: |
python -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt
pixi-version: v0.72.0
environments: dev
locked: true
cache: true

- name: Setup GHC App and init DB 🗃️
run: |
invoke setup
echo -e "admin\ntest\ntest\nyou@example.com\nyou@example.com" | python3 GeoHealthCheck/models.py create
pixi run -e dev setup
echo -e "admin\ntest\ntest\nyou@example.com\nyou@example.com" | pixi run -e dev python3 GeoHealthCheck/models.py create

- name: Flake8 - Verify Coding Conventions ⚙️
run: flake8
run: pixi run -e dev flake8

- name: Load Fixtures Test Data ⚙️
run: python3 GeoHealthCheck/models.py load tests/data/fixtures.json y
run: pixi run -e dev python3 GeoHealthCheck/models.py load tests/data/fixtures.json y

- name: Run Probes ⚙️
run: python3 GeoHealthCheck/healthcheck.py
run: pixi run -e dev python3 GeoHealthCheck/healthcheck.py

- name: Run Unit Tests ⚙️
run: python3 tests/run_tests.py
run: pixi run -e dev test

- name: Publish Test Report 📄
if: always()
run: cat report.md >> "$GITHUB_STEP_SUMMARY" || true

- name: Build Docs 📖
run: cd docs && make html
run: pixi run -e dev bash -c "cd docs && make html"

- name: Cleanup 💯
run: python3 GeoHealthCheck/models.py drop
run: pixi run -e dev python3 GeoHealthCheck/models.py drop
25 changes: 13 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:noble
FROM ghcr.io/prefix-dev/pixi:0.72.0-noble

# Credits to yjacolin for providing first versions
LABEL original_developer="yjacolin <yves.jacolin@camptocamp.com>" \
Expand All @@ -12,14 +12,16 @@ ARG TZ="Etc/UTC"
ARG LANG="en_US.UTF-8"
ARG ADD_DEB_PACKAGES=""

# General ENV settings
# General ENV settings.
# DEB_PACKAGES holds only non-Python system tools: Python and all app/runtime
# deps (incl. gunicorn/gevent, lxml, pyproj) now come from the pixi env.
# `make` is needed at build time by `invoke setup` (docs build).
ENV LC_ALL="en_US.UTF-8" \
LANG="en_US.UTF-8" \
LANGUAGE="en_US.UTF-8" \
\
\
DEB_PACKAGES="locales gunicorn python3.12-venv postgresql-client python3-gunicorn python3-gevent python3-lxml python3-pyproj" \
DEB_BUILD_DEPS="make python3-pip" \
DEB_PACKAGES="locales ca-certificates make postgresql-client" \
ADMIN_NAME=admin \
ADMIN_PWD=admin \
ADMIN_EMAIL=admin.istrator@mydomain.com \
Expand Down Expand Up @@ -72,10 +74,10 @@ WSGI_WORKER_CLASS='gevent' \
# GHC User Plugins, best be overridden via Container environment \
GHC_USER_PLUGINS=''

# Install operating system dependencies
# Install operating system dependencies (non-Python only)
RUN \
apt-get update \
&& apt-get --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} ${ADD_DEB_PACKAGES} \
&& apt-get --no-install-recommends install -y ${DEB_PACKAGES} ${ADD_DEB_PACKAGES} \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& echo "For ${TZ} date=$(date)" && echo "Locale=$(locale)"

Expand All @@ -87,13 +89,12 @@ COPY docker/scripts/*.sh docker/config_site.py docker/plugins /
# Add Source Code
COPY . /GeoHealthCheck

# Install
WORKDIR /GeoHealthCheck

# Install: create the locked pixi `prod` env and bootstrap GHC
RUN \
chmod a+x /*.sh && ./install.sh \
# Cleanup TODO: remove unused Locales and TZs \
&& apt-get remove --purge -y ${DEB_BUILD_DEPS} \
chmod a+x /*.sh && /install.sh \
&& apt-get clean \
&& apt autoremove -y \
&& rm -rf /var/lib/apt/lists/*


Expand All @@ -102,4 +103,4 @@ VOLUME ["/GeoHealthCheck/DB/"]

EXPOSE ${PORT}

ENTRYPOINT /run-web.sh
ENTRYPOINT ["/run-web.sh"]
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ Easiest is [to run GHC using Docker](https://github.com/geopython/GeoHealthCheck
Below a quick overview of a manual install on Unix-based systems like Apple MacOS and Linux.

```bash
virtualenv GeoHealthCheck && cd $_
. bin/activate
git clone https://github.com/geopython/GeoHealthCheck.git
cd GeoHealthCheck
pip3 install Invoke
# install the environment (Python + all deps) and open a shell in it
pixi install -e prod
pixi shell -e prod
# setup installation
invoke setup
# generate secret key
Expand Down Expand Up @@ -69,30 +69,50 @@ python3 GeoHealthCheck/models.py load <.json data file> [y/n]

## Install with Pixi

[Pixi](https://pixi.sh) manages the environment; tasks run via `pixi run`,
so no shell activation is needed.

```
git clone https://github.com/geopython/GeoHealthCheck.git
cd GeoHealthCheck

# Install production environment
pixi install -e prod
pixi shell -e prod
invoke setup

# bootstrap the app (config, static assets, i18n, local docs, DB)
pixi run -e prod setup

# generate secret key
invoke create-secret-key
pixi run -e prod invoke create-secret-key
# setup local configuration (overrides GeoHealthCheck/config_main.py)
vi instance/config_site.py
# edit at least secret key:
# - SECRET_KEY # copy/paste result string from `invoke create-secret-key`
# - SECRET_KEY # copy/paste result string from the command above

# Optional: edit other settings or leave defaults (see above)

# setup superuser account passsword and email directly
invoke create admin admin a@a.com
# setup superuser account password and email directly
pixi run -e prod invoke create admin admin a@a.com

# run locally
python GeoHealthCheck/app.py
pixi run -e prod python GeoHealthCheck/app.py

```

### Development and tests

```
# install the dev environment (adds flake8, pytest, ...)
pixi install -e dev

# bootstrap once, needed before the tests can run
pixi run -e dev setup

# run the unit tests
pixi run -e dev test
```

Prefer an interactive shell? `pixi shell -e prod` (or `-e dev`) activates the
environment, after which `invoke ...` and `python ...` work directly.

More in the [full GHC documentation](http://docs.geohealthcheck.org/).
8 changes: 3 additions & 5 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ The GHC installation is at `/GeoHealthCheck` within the Docker Container.
# Bash into running GHC Container
docker exec -it docker_geohealthcheck_1 bash

# setup Python venv
source /venv/bin/activate .
cd /GeoHealthCheck/
# next can use Invoke commands e.g. DB upgrade
invoke upgrade

# next can use Invoke commands via the pixi env, e.g. DB upgrade
pixi run -e prod invoke upgrade

etc
```
Expand Down
3 changes: 1 addition & 2 deletions docker/scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ echo "Using DB_TYPE=${DB_TYPE}"
# Create DB shorthand
function create_db() {
pushd /GeoHealthCheck/ || exit 1
source bin/activate

invoke create -u ${ADMIN_NAME} -p ${ADMIN_PWD} -e ${ADMIN_EMAIL}
pixi run -e prod invoke create -u ${ADMIN_NAME} -p ${ADMIN_PWD} -e ${ADMIN_EMAIL}
popd || exit 1
}

Expand Down
25 changes: 11 additions & 14 deletions docker/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/bin/bash

# GHC Source was added in Dockerfile, install
# NB we use gunicorn/eventlet async workers as some Probes may take a long time
# e.g. fetching Metadata (Caps) and testing all layers
# Install Python packages for installation and setup
# GHC source was added in the Dockerfile; set up the pixi environment.
# NB we use gunicorn/gevent async workers as some Probes may take a long time
# e.g. fetching Metadata (Caps) and testing all layers.
set -e

python3 -m venv GeoHealthCheck
pushd /GeoHealthCheck || exit 1
cd /GeoHealthCheck || exit 1

source bin/activate
# Create the locked `prod` environment: Python plus all app/runtime deps
# (incl. gunicorn/gevent, lxml, pyproj, invoke) from conda-forge/PyPI.
pixi install --locked -e prod

# Bootstrap GHC itself: static JS assets, i18n .mo files, local docs, dirs.
pixi run -e prod setup

# Docker-specific deps
pip3 install --no-cache-dir -r docker/scripts/requirements.txt

# Sets up GHC itself
invoke setup
# Use the Docker-specific site config (overrides the default from setup).
mv /config_site.py /GeoHealthCheck/instance/config_site.py

# Copy possible Plugins into app tree
Expand All @@ -28,5 +27,3 @@ then
# Remove to allow later Volume mount of /plugins
rm -rf /plugins
fi

popd || exit 1
1 change: 0 additions & 1 deletion docker/scripts/requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions docker/scripts/run-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ echo "START /run-runner.sh"
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH

cd /GeoHealthCheck
source bin/activate
invoke runner-daemon
pixi run -e prod invoke runner-daemon

echo "END /run-runner.sh"
3 changes: 1 addition & 2 deletions docker/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ echo "START /run-tests.sh"
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH

cd /GeoHealthCheck
source bin/activate
invoke run-tests
pixi run -e prod invoke run-tests

echo "END /run-tests.sh"
12 changes: 5 additions & 7 deletions docker/scripts/run-web.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Runs the GHC app with gunicorn
# Runs the GHC app with gunicorn (from the pixi `prod` env)

echo "START /run-web.sh"

Expand All @@ -10,20 +10,18 @@ echo "START /run-web.sh"
# Configure: DB and plugins.
/configure.sh

# Make sure PYTHONPATH includes GeoHealthCheck
# Make sure PYTHONPATH includes GeoHealthCheck (for intra-package imports)
export PYTHONPATH=/GeoHealthCheck/GeoHealthCheck:$PYTHONPATH

pushd /GeoHealthCheck || exit 1
cd /GeoHealthCheck || exit 1

source bin/activate

invoke upgrade
pixi run -e prod invoke upgrade

# SCRIPT_NAME should not have value '/'
[ "${SCRIPT_NAME}" = '/' ] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /"

echo "Running GHC WSGI on ${HOST}:${PORT} with ${WSGI_WORKERS} workers and SCRIPT_NAME=${SCRIPT_NAME}"
exec gunicorn --pythonpath /GeoHealthCheck/lib/python3.12/site-packages/ --workers ${WSGI_WORKERS} \
exec pixi run -e prod gunicorn --chdir /GeoHealthCheck --workers ${WSGI_WORKERS} \
--worker-class=${WSGI_WORKER_CLASS} \
--timeout ${WSGI_WORKER_TIMEOUT} \
--name="Gunicorn_GHC" \
Expand Down
12 changes: 5 additions & 7 deletions docs/admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ create db

To create the database execute the following:

Open a command line, (if needed activate your virtualenv), and do ::
Open a command line, (if needed, activate the pixi environment with ``pixi shell -e prod``), and do ::

python3 GeoHealthCheck/models.py create

Expand All @@ -28,7 +28,7 @@ drop db

To delete the database execute the following, however you will loose all your information. So please ensure backup if needed:

Open a command line, (if needed activate your virtualenv), and do ::
Open a command line, (if needed, activate the pixi environment with ``pixi shell -e prod``), and do ::

python3 GeoHealthCheck/models.py drop

Expand Down Expand Up @@ -75,10 +75,8 @@ a password is forgotten and somehow the email-based reset is not available nor w
In that case, password-hashes can be created from the command-line using the Python library `passlib <https://passlib.readthedocs.io/en/stable/>`_
within an interactive Python-shell as follows: ::

$ pip3 install passlib
# or in Debian/Ubuntu: apt-get install python-passlib

python3
# passlib is part of the pixi environment; open a Python shell in it:
pixi run -e prod python3
>>> from passlib.hash import pbkdf2_sha256
>>>
>>> hash = pbkdf2_sha256.hash("mynewpassword")
Expand Down Expand Up @@ -109,5 +107,5 @@ Then copy-paste the hash-string into the `password`-field of the User-record in
Build Documentation
-------------------

Open a command line, (if needed activate your virtualenv) and move into the directory ``GeoHealthCheck/doc/``.
Open a command line, (if needed, activate the pixi environment with ``pixi shell -e prod``) and move into the directory ``GeoHealthCheck/doc/``.
In there, type ``make html`` plus ENTER and the documentation should be built locally.
Loading
Loading