From 243a51c61e18fc0f0096a8d012645a05a4c2cd07 Mon Sep 17 00:00:00 2001 From: Etienne Boileau Date: Mon, 24 Jun 2024 16:35:19 +0200 Subject: [PATCH] Prepare release --- client/src/views/SearchView.vue | 2 +- docker/app_container/Dockerfile | 2 +- docker/app_container/files/entry_point.py | 1 + docker/app_container/files/mini_cron.sh | 7 ++----- docker/app_container/files/run_flask.sh | 9 +++++++-- server/env_example | 4 ++++ server/pyproject.toml | 2 +- server/src/scimodom/services/bedtools.py | 2 ++ 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/client/src/views/SearchView.vue b/client/src/views/SearchView.vue index 74ddf6e1..6acceeab 100644 --- a/client/src/views/SearchView.vue +++ b/client/src/views/SearchView.vue @@ -236,7 +236,7 @@ function lazyLoad(event) { matchMode: 'in' } } - HTTP.get('/modification', { + HTTP.get('/modification/', { params: { modification: selectedModification.value.key, organism: selectedOrganism.value.key, diff --git a/docker/app_container/Dockerfile b/docker/app_container/Dockerfile index 8d2fd55c..2397a3fc 100644 --- a/docker/app_container/Dockerfile +++ b/docker/app_container/Dockerfile @@ -9,7 +9,7 @@ COPY docker/app_container/files/. /app/ RUN apt-get update \ && apt-get install -y bedtools findutils \ && useradd app \ - && mkdir -p /uploads /tmp/bedtools /app/venv \ + && mkdir -p /uploads /app/venv \ && chown -R app /uploads /install /app/venv \ && cp -r /install/migrations /install/alembic.ini /app diff --git a/docker/app_container/files/entry_point.py b/docker/app_container/files/entry_point.py index 6c155d51..cdd80e06 100755 --- a/docker/app_container/files/entry_point.py +++ b/docker/app_container/files/entry_point.py @@ -46,4 +46,5 @@ def get_secret(path): system("cd /app && /app/mini_cron.sh &") system( f"exec su - app /app/run_flask.sh {environ.get('HTTP_WORKER_PROCESSES')} {environ.get('HTTP_WORKER_TIMEOUT', 30)}" + f" {environ.get('HTTP_REVERSE_PROXY_IPS', '')}" ) diff --git a/docker/app_container/files/mini_cron.sh b/docker/app_container/files/mini_cron.sh index df445a7e..602c1686 100755 --- a/docker/app_container/files/mini_cron.sh +++ b/docker/app_container/files/mini_cron.sh @@ -12,11 +12,8 @@ then echo 'mini_cron.sh: No $UPLOAD_PATH - aborting.' exit 1 fi -if [[ -z $BEDTOOLS_TMP_PATH ]] -then - echo 'mini_cron.sh: No $BEDTOOLS_TMP_PATH - aborting.' - exit 1 -fi + +mkdir -p $BEDTOOLS_TMP_PATH while [[ 1 = 1 ]] do diff --git a/docker/app_container/files/run_flask.sh b/docker/app_container/files/run_flask.sh index b08376a4..64ccfc38 100755 --- a/docker/app_container/files/run_flask.sh +++ b/docker/app_container/files/run_flask.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh echo '### Activating venv ###' . /app/venv/bin/activate @@ -6,4 +6,9 @@ cd /app echo '### Upgrading Database ###' alembic upgrade head echo '### Starting gunicorn ###' -exec gunicorn -b 0.0.0.0:8000 -w $1 --timeout $2 'scimodom.app:create_app()' +extra_opts='' +if [ "X$3" != X ] +then + extra_opts="--forwarded-allow-ips=$3" +fi +exec gunicorn -b 0.0.0.0:8000 -w $1 --timeout $2 $extra_opts 'scimodom.app:create_app()' diff --git a/server/env_example b/server/env_example index ca99f0cd..2603f31c 100644 --- a/server/env_example +++ b/server/env_example @@ -9,6 +9,10 @@ HTTP_WORKER_TIMEOUT=120 # Usually you will have a reverse proxy in front to terminate TLS. # Use it's name below. HTTP_PUBLIC_URL=https://scimodom.my-site.org +# If we run behind a reverse proxy we need to know it's IP address(es) so that we trust +# the X-Forwarded-Proto header. Otherwise, we might generate incorrect redirects +# (http instead of https). +HTTP_REVERSE_PROXY_IPS=... # Mail server to use. It must be willing to relay emails # for your host/SMTP_FROM_ADDRESS. diff --git a/server/pyproject.toml b/server/pyproject.toml index 39b3ddc3..e41de248 100755 --- a/server/pyproject.toml +++ b/server/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ "Flask-Cors", "Flask-JWT-Extended", "mysqlclient", - "numpy", + "numpy<2", "pandas", "pybedtools", "python-dotenv", diff --git a/server/src/scimodom/services/bedtools.py b/server/src/scimodom/services/bedtools.py index e1831ee8..3a50b6dd 100644 --- a/server/src/scimodom/services/bedtools.py +++ b/server/src/scimodom/services/bedtools.py @@ -1,5 +1,6 @@ from functools import cache import logging +from os import makedirs from pathlib import Path from typing import Iterable, Sequence, Any @@ -91,6 +92,7 @@ def _remove_filno(feature, n_fields: int = 9, is_closest: bool = False): class BedToolsService: def __init__(self, tmp_path): + makedirs(tmp_path, exist_ok=True) pybedtools.helpers.set_tempdir(tmp_path) def annotate_data_using_ensembl(