-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab3a2b2
commit f69056e
Showing
11 changed files
with
269 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,11 +25,14 @@ LABEL maintainer="[email protected]" | |
|
||
ENV TZ="Etc/UTC" \ | ||
DEBIAN_FRONTEND="noninteractive" \ | ||
DEBIAN_PACKAGES="bash curl git python3-pip python3-setuptools vim" | ||
DEBIAN_PACKAGES="bash cron curl git python3-pip python3-setuptools vim" | ||
|
||
# copy the app | ||
COPY . /app | ||
|
||
# add to crontab | ||
COPY ./docker/wis2-gdc-management.cron /etc/cron.d/wis2-gdc-management.cron | ||
|
||
RUN apt-get update -y && \ | ||
# install dependencies | ||
apt-get install -y ${DEBIAN_PACKAGES} && \ | ||
|
@@ -42,6 +45,8 @@ RUN apt-get update -y && \ | |
# cleanup | ||
apt autoremove -y && \ | ||
apt-get -q clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
rm -rf /var/lib/apt/lists/* && \ | ||
chmod 0644 /etc/cron.d/wis2-gdc-management.cron && \ | ||
crontab /etc/cron.d/wis2-gdc-management.cron | ||
|
||
ENTRYPOINT [ "/app/docker/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,16 @@ FROM geopython/pygeoapi:latest | |
|
||
LABEL maintainer="Tom Kralidis <[email protected]>" | ||
|
||
ENV PYGEOAPI_CONFIG=/pygeoapi/local.config.yml | ||
ENV PYGEOAPI_OPENAPI=/pygeoapi/local.openapi.yml | ||
|
||
RUN pip3 install pywcmp && \ | ||
pywcmp bundle sync | ||
|
||
COPY ./wis2-gdc.yml /pygeoapi/local.config.yml | ||
COPY ./app.py /pygeoapi/pygeoapi/app.py | ||
COPY ./entrypoint.sh /app/docker/wis2-gdc-api/entrypoint.sh | ||
|
||
RUN chmod +x /app/docker/wis2-gdc-api/entrypoint.sh | ||
|
||
ENTRYPOINT [ "/app/docker/wis2-gdc-api/entrypoint.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
############################################################################### | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
############################################################################### | ||
|
||
from flask import Flask, make_response, redirect | ||
from pygeoapi.flask_app import BLUEPRINT as pygeoapi_blueprint | ||
|
||
app = Flask(__name__, static_url_path='/static') | ||
app.url_map.strict_slashes = False | ||
|
||
app.register_blueprint(pygeoapi_blueprint, url_prefix='/') | ||
|
||
try: | ||
from flask_cors import CORS | ||
CORS(app) | ||
except ImportError: # CORS needs to be handled by upstream server | ||
pass | ||
|
||
|
||
@app.route('/archive.zip') | ||
def archive(): | ||
|
||
headers = { | ||
'Content-Type': 'application/zip' | ||
} | ||
|
||
with open('/data/archive.zip') as fh: | ||
response = make_response(fh.read(), 200) | ||
response.headers = headers | ||
|
||
return response | ||
|
||
return redirect('https://docs.wis2box.wis.wmo.int', code=302) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
############################################################################### | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
############################################################################### | ||
|
||
# pygeoapi entry script | ||
|
||
echo "START /entrypoint.sh" | ||
|
||
set +e | ||
|
||
# gunicorn env settings with defaults | ||
SCRIPT_NAME="/" | ||
CONTAINER_NAME="wis2-gdc-api" | ||
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 | ||
|
||
# Lock all Python files (for gunicorn hot reload) | ||
find . -type f -name "*.py" | xargs chmod -R 0444 | ||
|
||
echo "Trying to generate OpenAPI document" | ||
pygeoapi openapi generate ${PYGEOAPI_CONFIG} --output-file ${PYGEOAPI_OPENAPI} | ||
|
||
[[ $? -ne 0 ]] && error "ERROR: OpenAPI document could not be generated" | ||
|
||
echo "openapi.yml generated continue to pygeoapi" | ||
|
||
case ${entry_cmd} in | ||
# 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}" | ||
exec gunicorn --workers ${WSGI_WORKERS} \ | ||
--worker-class=${WSGI_WORKER_CLASS} \ | ||
--timeout ${WSGI_WORKER_TIMEOUT} \ | ||
--name=${CONTAINER_NAME} \ | ||
--bind ${CONTAINER_HOST}:${CONTAINER_PORT} \ | ||
--reload \ | ||
--reload-extra-file ${PYGEOAPI_CONFIG} \ | ||
pygeoapi.app:app | ||
;; | ||
*) | ||
error "unknown command arg: must be run (default)" | ||
;; | ||
esac | ||
|
||
echo "END /entrypoint.sh" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0 0 * * * su -c "wis2-gdc archive /data/archive.zip" > /proc/1/fd/1 2>/proc/1/fd/2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters