Skip to content

Commit

Permalink
Merge pull request #477 from HXLStandard/HXL-79
Browse files Browse the repository at this point in the history
HXL-79
  • Loading branch information
davidmegginson committed Jul 27, 2023
2 parents 10ca95d + d0d9cf7 commit 13f5987
Show file tree
Hide file tree
Showing 28 changed files with 40 additions and 1,220 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Release 2.1:
- remove all SQL support

2023-07-13 Release 2.0.2:
- update to libhxl==5.0.2 to support the .hxl extension for CSV files

Expand Down
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ COPY . .

RUN apk add \
git \
sqlite \
libffi-dev \
unit \
unit-python3 && \
mkdir -p \
/etc/services.d/hxl \
/srv/db \
/srv/cache \
/srv/config \
/srv/output \
/var/log/proxy && \
mv config.py.TEMPLATE /srv/config/config.py && \
cp hxl_proxy/schema-mysql.sql hxl_proxy/schema-sqlite3.sql /srv/config/ && \
mv docker_files/hxl_run /etc/services.d/hxl/run && \
mv docker_files/app.py docker_files/app_nr.py docker_files/app_elastic.py . && \
pip3 --no-cache-dir install --upgrade \
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ test-docker:
run-local: $(VENV)
. $(VENV) && HXL_PROXY_CONFIG=../local/config.py flask --app hxl_proxy run

run-detached: $(VENV)
. $(VENV) && HXL_PROXY_CONFIG=../local/config.py screen -d -m flask --app hxl_proxy run

debug-local: $(VENV)
. $(VENV) && HXL_PROXY_CONFIG=../local/config.py flask --debug --app hxl_proxy run

Expand Down
30 changes: 0 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,10 @@ python setup.py test

To configure the proxy, make a copy of config.py.TEMPLATE (e.g. to config.py), and change its values as necessary. The environment variable HXL\_PROXY\_CONFIG should point to your local config file's location. More details appear below.

## Admin interface

To enable the admin interface, you need to enter the MD5 hash of a password into the ADMIN_PASSWORD_MD5 field in the config file. If your password were "hello-kitty" (don't do that!), you could generate the hash like this using Python3:

$ python -c 'import hashlib; print(hashlib.md5("hello-kitty".encode("utf-8")).hexdigest())'

## Caching

Choose and configure your input and output caches as needed, following the examples in the config template. You may need to create local directories or databases, depending on the caching backends you choose.

## Database support

### Using SQLite3

* DB_TYPE - (required) set to "sqlite3"
* DB_FILE - (required) a file (which the proxy will create if necessary) containing a SQLite3 database of saved configurations. The file's directory must exist and be readable and writable by the web-server process.

The database schema appears in hxl_proxy/schema-sqlite3.sql

### Using MySQL

* DB_TYPE - (required) set to "mysql"
* DB_HOST - (optional) address of the MySQL host (defaults to "localhost")
* DB_PORT - (optional) port number of the MySQL host (must be a number; defaults to 3306)
* DB_DATABASE - (optional) database name for the HXL Proxy (defaults to "hxl_proxy")
* DB_USERNAME - (required) database username
* DB_PASSWORD - (required) database password

Note that for MySQL, you *must* create the database manually. A schema appears in hxl_proxy/schema-mysql.sql

## Authorisation tokens

To use the Google Drive selector, you will require a client ID and OAuth id from Google. To allow users to log in via Humanitarian.ID, you will require a client ID, client secret, and redirect URI from the Humanitarian.ID team.

## P-codes and mapping

For mapping, the Proxy uses a collection of GeoJSON files hosted online. If you want to use a local copy (e.g. for offline demos), clone the GitHub repository at https://github.com/hxlstandard/p-codes and set the new base URL as the value of PCODE_BASE_URL. Note that the server serving the local copy must implement CORS, since the shapes get loaded on the browser side: https://www.w3.org/TR/cors/
Expand Down
50 changes: 0 additions & 50 deletions config.py.TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -115,60 +115,10 @@ ITOS_CACHE_NAME = 'itos-in' # no trailing colon needed
ITOS_CACHE_BACKEND = 'memory'
ITOS_CACHE_TIMEOUT = 604800

#
# Database connection info
#

# 'sqlite3' or 'mysql'
DB_TYPE=os.getenv('DB_TYPE', 'sqlite3')

# Schema file, for tests.
DB_SCHEMA_FILE = os.getenv('DB_SCHEMA_FILE', 'schema-sqlite3.sql')

# SQLite3 settings
DB_FILE='/tmp/hxl-proxy.db'

# MySQL settings
DB_HOST = os.getenv('MYSQL_HOST', 'localhost')
DB_DATABASE = os.getenv('MYSQL_DB', 'hxl_proxy')
DB_PORT = os.getenv('DB_PORT', 3306)
DB_USERNAME = os.getenv('MYSQL_USER', '')
DB_PASSWORD = os.getenv('MYSQL_PASS', '')

#
# Values for Google Drive access
#
GOOGLE_CLIENT_ID = os.getenv('GOOGLE_CLIENT_ID', '<client id>')
GOOGLE_OAUTH_ID = os.getenv('GOOGLE_OAUTH_ID', '<oauth id>')

#
# Values for Humanitarian.ID remote login
#
HID_CLIENT_ID = os.getenv('HID_CLIENT_ID', '<client id>')
HID_CLIENT_SECRET = os.getenv('HID_CLIENT_SECRET', '<client secret>')
HID_REDIRECT_URI = os.getenv('HID_REDIRECT_URI', '<redirect URI>')
HID_BASE_URL = os.getenv('HID_BASE_URL', 'https://auth.humanitarian.id') # change to http://auth.dev.humanitarian.id for dev testing

#
# Where to find shapes, etc. for p-codes. Usually leave as-is.
#
PCODE_BASE_URL = 'https://hxlstandard.github.io/p-codes'

#
# Countries available for mapping (update as needed).
#
PCODE_COUNTRY_MAP = {
'Burundi': 'BDI',
'Cameroon': 'CMR',
'Chad': 'TCD',
'Ecuador': 'ECU',
'Guinea': 'GIN',
'Haiti': 'HTI',
'Mali': 'MLI',
'Nepal': 'NPL',
'Niger': 'NER',
'Nigeria': 'NGA',
'Somalia': 'SOM',
}

# end
5 changes: 0 additions & 5 deletions docker-compose-github-actions.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
version: '2.2'

services:
mysql:
extends:
file: docker-compose.common.yml
service: mysql

redis:
extends:
file: docker-compose.common.yml
Expand Down
9 changes: 0 additions & 9 deletions docker-compose.common.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
version: '2.2'

services:
mysql:
image: public.ecr.aws/unocha/mysql:10.6
hostname: mysql
container_name: hxl-proxy-mysql
environment:
MYSQL_DB: hxl
MYSQL_USER: hxl
MYSQL_PASS: hxl

redis:
image: public.ecr.aws/unocha/redis:5
hostname: redis
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ services:
entrypoint: ['./run.sh']
working_dir: /srv/www
environment:
DB_TYPE: 'sqlite'
CACHE_TYPE: 'redis'
CACHE_REDIS_URL: 'redis://redis:6379/0'
FLASK_HOST: '0.0.0.0'
Expand Down
1 change: 0 additions & 1 deletion docker_files/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
proxy:
entrypoint: []
environment:
DB_TYPE: sqlite
HXL_PROXY_CONFIG: /srv/config/config.py
PS1: '\h \w ~> '
TERM: xterm
Expand Down
110 changes: 0 additions & 110 deletions hxl_proxy/admin.py

This file was deleted.

Loading

0 comments on commit 13f5987

Please sign in to comment.