From 3f012b8cb9baa9cf6782f63b8ce28a123392d955 Mon Sep 17 00:00:00 2001 From: Bee Webb Date: Thu, 31 Oct 2024 13:01:21 +0000 Subject: [PATCH] wip dynamic dashboard run using gunicorn --- .dockerignore | 2 ++ Dockerfile | 6 +++++- git.sh | 7 ++++--- requirements.in | 3 ++- requirements.txt | 8 ++++++-- requirements_dev.txt | 3 +++ 6 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..7a451343fe --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +data +out diff --git a/Dockerfile b/Dockerfile index 623da6f290..fc8b288d98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.12-bookworm -WORKDIR /work +WORKDIR /work/IATI-Dashboard/dashboard COPY requirements.txt /work/IATI-Dashboard/requirements.txt @@ -8,6 +8,8 @@ RUN git config --global --add safe.directory /work/IATI-Stats/data RUN pip install -r /work/IATI-Dashboard/requirements.txt +COPY . /work/IATI-Dashboard + # 2024-03-20: Emergency fix # We were seeing cert errors inside the docker container after a new Lets Encrypt was issued. # @@ -17,3 +19,5 @@ RUN pip install -r /work/IATI-Dashboard/requirements.txt # I tried installing the LE root cert's manually but that didn't work. # As live is broken for now we need this emergency fix, but we should remove it in the future. RUN echo "check_certificate=off" > /root/.wgetrc + +CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--timeout", "120", "ui.wsgi:application"] diff --git a/git.sh b/git.sh index c7b6c780a5..2962d03967 100755 --- a/git.sh +++ b/git.sh @@ -9,8 +9,10 @@ mkdir out echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Fetching data" ./fetch_data.sh &> fetch_data.log || exit 1 +cd dashboard + echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running plots.py" -python plots.py || exit 1 +python make_plots.py || exit 1 echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_csv.py" python make_csv.py || exit 1 @@ -18,8 +20,7 @@ python make_csv.py || exit 1 echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running speakers kit.py" python speakers_kit.py || exit 1 -echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Running make_html.py" -python make_html.py $1 $2|| exit 1 +cd .. echo "LOG: `date '+%Y-%m-%d %H:%M:%S'` - Copying static elements" cp static/img/favicon.png out/ diff --git a/requirements.in b/requirements.in index 523b2f0a4e..488212fa86 100644 --- a/requirements.in +++ b/requirements.in @@ -1,4 +1,5 @@ django +gunicorn flask frozen-flask jinja2 @@ -11,4 +12,4 @@ lxml requests markupsafe itsdangerous -tqdm \ No newline at end of file +tqdm diff --git a/requirements.txt b/requirements.txt index afde658def..cb1e9ed6fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ # This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile requirements.in +# pip-compile # asgiref==3.8.1 # via django @@ -30,6 +30,8 @@ fonttools==4.54.1 # via matplotlib frozen-flask==1.0.2 # via -r requirements.in +gunicorn==23.0.0 + # via -r requirements.in idna==3.10 # via requests itsdangerous==2.2.0 @@ -56,7 +58,9 @@ numpy==2.1.1 # contourpy # matplotlib packaging==24.1 - # via matplotlib + # via + # gunicorn + # matplotlib pillow==10.4.0 # via matplotlib pyparsing==3.1.4 diff --git a/requirements_dev.txt b/requirements_dev.txt index 480e11b876..32fbe21f09 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -58,6 +58,8 @@ fonttools==4.54.1 # matplotlib frozen-flask==1.0.2 # via -r requirements.txt +gunicorn==23.0.0 + # via -r requirements.txt idna==3.10 # via # -r requirements.txt @@ -95,6 +97,7 @@ numpy==2.1.1 packaging==24.1 # via # -r requirements.txt + # gunicorn # matplotlib # pytest pillow==10.4.0