72b9a647ff
* Bump gdal to v3 * Fix query duplicates with bbox for PG * Add backward compatibility for axis order * Move travis to bionic dist Fix gdal version 3 on travis by pinning latest ubuntu unstable release Fix ubuntugis sources on travis Remove pinned python gdal version Add mongodb start Enable mongod service Fix package name Install mongo from official community repos Add mongo enable and start commands * Fix wrong axis mapping strategy Add author * Move base image to bullseye for docker build * Fix remaining unchanged places for #364 * Make image size smaller * Add docker build and cite tests Fix python version Move steps after docker build elsewhere Fix uppercase characters Fix internal port Daemonize the run process * Check logs and run test command from the entrypoint * Remove the execution of mongo tests for test command Remove the execution of mongo tests for test command Fix failed command * Add delay and move build to install step Remove grep command for now Use single quote
109 lines
3.3 KiB
Bash
Executable File
109 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# =================================================================
|
|
#
|
|
# Authors: Just van den Broecke <justb4@gmail.com>
|
|
#
|
|
# Copyright (c) 2019 Just van den Broecke
|
|
#
|
|
# Permission is hereby granted, free of charge, to any person
|
|
# obtaining a copy of this software and associated documentation
|
|
# files (the "Software"), to deal in the Software without
|
|
# restriction, including without limitation the rights to use,
|
|
# copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the
|
|
# Software is furnished to do so, subject to the following
|
|
# conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be
|
|
# included in all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
# OTHER DEALINGS IN THE SOFTWARE.
|
|
#
|
|
# =================================================================
|
|
|
|
# pygeoapi entry script
|
|
|
|
echo "START /entrypoint.sh"
|
|
|
|
set +e
|
|
|
|
export PYGEOAPI_HOME=/pygeoapi
|
|
export PYGEOAPI_CONFIG="${PYGEOAPI_HOME}/local.config.yml"
|
|
export PYGEOAPI_OPENAPI="${PYGEOAPI_HOME}/local.openapi.yml"
|
|
|
|
# gunicorn env settings with defaults
|
|
SCRIPT_NAME=${SCRIPT_NAME:=/}
|
|
CONTAINER_NAME=${CONTAINER_NAME:=pygeoapi}
|
|
CONTAINER_HOST=${CONTAINER_HOST:=0.0.0.0}
|
|
CONTAINER_PORT=${CONTAINER_PORT:=80}
|
|
WSGI_WORKERS=${WSGI_WORKERS:=4}
|
|
WSGI_WORKER_TIMEOUT=${WSGI_WORKER_TIMEOUT:=6000}
|
|
WSGI_WORKER_CLASS=${WSGI_WORKER_CLASS:=gevent}
|
|
|
|
# What to invoke: default is to run gunicorn server
|
|
entry_cmd=${1:-run}
|
|
|
|
# Shorthand
|
|
function error() {
|
|
echo "ERROR: $@"
|
|
exit -1
|
|
}
|
|
|
|
# Workdir
|
|
cd ${PYGEOAPI_HOME}
|
|
|
|
echo "Trying to generate openapi.yml"
|
|
pygeoapi generate-openapi-document -c ${PYGEOAPI_CONFIG} > ${PYGEOAPI_OPENAPI}
|
|
|
|
[[ $? -ne 0 ]] && error "openapi.yml could not be generated ERROR"
|
|
|
|
echo "openapi.yml generated continue to pygeoapi"
|
|
|
|
case ${entry_cmd} in
|
|
# Run Unit tests
|
|
test)
|
|
for test_py in $(ls tests/test_*.py)
|
|
do
|
|
# Skip tests requireing backend server or libs installed
|
|
case ${test_py} in
|
|
tests/test_elasticsearch__provider.py)
|
|
;&
|
|
tests/test_postgresql_provider.py)
|
|
;&
|
|
tests/test_mongo_provider.py)
|
|
echo "Skipping: ${test_py}"
|
|
;;
|
|
*)
|
|
python3 -m pytest ${test_py}
|
|
;;
|
|
esac
|
|
done
|
|
;;
|
|
|
|
# Run pygeoapi server
|
|
run)
|
|
# SCRIPT_NAME should not have value '/'
|
|
[[ "${SCRIPT_NAME}" = '/' ]] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /"
|
|
|
|
echo "Start gunicorn name=${CONTAINER_NAME} on ${CONTAINER_HOST}:${CONTAINER_PORT} with ${WSGI_WORKERS} workers and SCRIPT_NAME=${SCRIPT_NAME}"
|
|
gunicorn --workers ${WSGI_WORKERS} \
|
|
--worker-class=${WSGI_WORKER_CLASS} \
|
|
--timeout ${WSGI_WORKER_TIMEOUT} \
|
|
--name=${CONTAINER_NAME} \
|
|
--bind ${CONTAINER_HOST}:${CONTAINER_PORT} \
|
|
pygeoapi.flask_app:APP
|
|
;;
|
|
*)
|
|
error "unknown command arg: must be run (default) or test"
|
|
;;
|
|
esac
|
|
|
|
echo "END /entrypoint.sh"
|