-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from internetofwater/gt-access
gitops workflow
- Loading branch information
Showing
4 changed files
with
36 additions
and
44 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 |
---|---|---|
|
@@ -27,57 +27,43 @@ | |
# | ||
# ================================================================= | ||
|
||
FROM ubuntu:jammy | ||
FROM python:3.11-alpine as build | ||
|
||
LABEL maintainer="Benjamin Webb <[email protected]>" | ||
|
||
ARG ADD_DEB_PACKAGES="\ | ||
python3-gdal \ | ||
python3-psycopg2 \ | ||
python3-rasterio" | ||
|
||
LABEL description="Docker image for the NLDI API" | ||
# ENV settings | ||
ENV TZ=${TZ} \ | ||
LANG=${LANG} \ | ||
DEBIAN_FRONTEND="noninteractive" \ | ||
DEB_BUILD_DEPS="\ | ||
curl \ | ||
gcc \ | ||
unzip" \ | ||
DEB_PACKAGES="\ | ||
locales \ | ||
tzdata \ | ||
gunicorn \ | ||
python3-dateutil \ | ||
python3-flask \ | ||
python3-flask-cors \ | ||
python3-gevent \ | ||
python3-greenlet \ | ||
python3-pip \ | ||
python3-tz \ | ||
python3-unicodecsv \ | ||
python3-yaml \ | ||
${ADD_DEB_PACKAGES}" | ||
PIP_NO_CACHE_DIR=1 | ||
|
||
# Install operating system dependencies | ||
RUN \ | ||
apk update && apk add curl build-base libpq-dev proj-util proj-dev gdal-dev geos-dev | ||
|
||
COPY ./requirements-docker.txt ./requirements.txt ./req/ | ||
|
||
|
||
RUN pip install --no-cache-dir -r ./req/requirements.txt | ||
RUN pip install --no-cache-dir -r ./req/requirements-docker.txt | ||
|
||
|
||
|
||
FROM python:3.11-alpine as nldi | ||
RUN apk update && apk add --no-cache gcompat libstdc++ curl proj-util libpq-dev | ||
ADD . /nldi | ||
WORKDIR /nldi | ||
COPY --from=build /usr/local/lib/python3.11/site-packages/ /usr/local/lib/python3.11/site-packages/ | ||
COPY --from=build /usr/lib/libgdal.so.35 /usr/lib/libgeos.so.3.12.2 /usr/lib/libproj.so.25 /usr/lib/libgeos_c.so.1.18.2 /usr/lib/ | ||
COPY --from=build /usr/local/bin/pygeoapi /usr/local/bin/gunicorn /usr/local/bin/ | ||
|
||
# Install operating system dependencies | ||
RUN \ | ||
apt-get update -y \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get --no-install-recommends install -y ${DEB_PACKAGES} ${DEB_BUILD_DEPS} \ | ||
# Install nldi | ||
&& pip3 install --no-deps https://github.com/geopython/pygeoapi/archive/refs/heads/master.zip \ | ||
&& pip3 install -r requirements-docker.txt \ | ||
&& pip3 install -e . \ | ||
# Cleanup | ||
&& apt-get remove --purge -y ${DEB_BUILD_DEPS} \ | ||
&& apt-get clean \ | ||
&& apt autoremove -y \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
# Set default config and entrypoint for Docker Image | ||
ln -s /usr/lib/libgdal.so.35 /usr/lib/libgdal.so \ | ||
&& ln -s /usr/lib/libgeos.so.3.12.2 /usr/lib/libgeos.so \ | ||
# && ln -s /usr/lib/libproj.so.25 /usr/lib/libproj.so \ | ||
&& ln -s /usr/lib/libgeos_c.so.1.18.2 /usr/lib/libgeos_c.so.1 \ | ||
&& ln -s /usr/lib/libgeos_c.so.1 /usr/lib/libgeos_c.so | ||
|
||
RUN pip install -e . \ | ||
&& cp /nldi/docker/default.source.yml /nldi/local.source.yml \ | ||
&& cp /nldi/docker/pygeoapi.config.yml /nldi/pygeoapi.config.yml \ | ||
&& cp /nldi/docker/entrypoint.sh /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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/bash | ||
#!/bin/sh | ||
# ================================================================= | ||
# | ||
# Author: Benjamin Webb <[email protected]> | ||
|
@@ -40,7 +40,7 @@ export PYGEOAPI_CONFIG="${NLDI_HOME}/pygeoapi.config.yml" | |
export PYGEOAPI_OPENAPI="${NLDI_HOME}/pygeoapi.openapi.yml" | ||
|
||
# gunicorn env settings with defaults | ||
export SCRIPT_NAME=${NLDI_PATH:=/} | ||
#export SCRIPT_NAME=${NLDI_PATH:=/} | ||
CONTAINER_NAME=${CONTAINER_NAME:=nldi} | ||
CONTAINER_HOST=${CONTAINER_HOST:=0.0.0.0} | ||
CONTAINER_PORT=${CONTAINER_PORT:=80} | ||
|
@@ -78,7 +78,7 @@ run) | |
|
||
# SCRIPT_NAME should not have value '/' | ||
[[ "${SCRIPT_NAME}" = '/' ]] && export SCRIPT_NAME="" && echo "make SCRIPT_NAME empty from /" | ||
|
||
unset SCRIPT_NAME | ||
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} \ | ||
|
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