Skip to content

Commit

Permalink
Merge pull request #427 from mboudet/dev
Browse files Browse the repository at this point in the history
Update Flask (and the rest)
  • Loading branch information
mboudet authored Jan 9, 2024
2 parents e443c6a + 5a9980a commit aaffd84
Show file tree
Hide file tree
Showing 8 changed files with 794 additions and 844 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.11
- name: Install flake8
run: pip install flake8
- name: Flake8
Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.11
- name: Update apt cache
run: sudo apt-get update
- name: Install python-ldap deps
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ serve-askomics: check-venv build-config create-user
@echo 'Serving AskOmics...'
. $(ACTIVATE)
ifeq ($(MODE), dev)
FLASK_ENV=development FLASK_APP=app flask run --host=$(HOST) --port $(PORT)
FLASK_DEBUG=development FLASK_APP=app flask run --host=$(HOST) --port $(PORT)
else
FLASK_ENV=production FLASK_APP=app gunicorn --timeout $(TIMEOUT) -w $(WORKERS) -b $(HOST):$(PORT) app
FLASK_APP=app gunicorn --timeout $(TIMEOUT) -w $(WORKERS) -b $(HOST):$(PORT) app
endif

serve-celery: check-venv build-config create-user
Expand Down
13 changes: 6 additions & 7 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ verify_ssl = true
name = "pypi"

[packages]
werkzeug = "==0.16.1"
flask = "<2"
flask-reverse-proxy-fix = "*"
werkzeug = "*"
flask = "<3"
validate-email = "*"
gunicorn = "*"
python-magic = "*"
rdflib = "*"
sparqlwrapper = "*"
requests = "*"
celery = "==5.0.5"
celery = "*"
redis = "*"
watchdog = "*"
gitpython = "*"
biopython = "*"
bcbio-gff = "*"
biopython = "==1.81"
bcbio-gff = "==0.7.0"
bioblend = "*"
pysam = "*"
pybedtools = "*"
Expand All @@ -29,7 +28,7 @@ tld = "*"
argh = "*"
python-ldap = "*"
python-dateutil = "*"
markupsafe = "==2.0.1"
markupsafe = "*"

[dev-packages]
pytest = "*"
Expand Down
1,586 changes: 761 additions & 825 deletions Pipfile.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions askomics/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import configparser
import os

from askomics.api.admin import admin_bp
from askomics.api.auth import auth_bp
Expand All @@ -20,14 +21,13 @@
from askomics.api.results import results_bp
from askomics.api.galaxy import galaxy_bp
from askomics.api.ontology import onto_bp
from askomics.middleware import PrefixMiddleware

from celery import Celery
from kombu import Exchange, Queue

from flask import Flask

from flask_reverse_proxy_fix.middleware import ReverseProxyPrefixFix

from pkg_resources import get_distribution

import sentry_sdk
Expand Down Expand Up @@ -109,14 +109,16 @@ def create_app(config='config/askomics.ini', app_name='askomics', blueprints=Non
for blueprint in blueprints:
app.register_blueprint(blueprint)

if app.config['ENV'] == "production":
is_gunicorn = "gunicorn" in os.environ.get("SERVER_SOFTWARE", "")

if is_gunicorn:
log_level = 10 if app.config['DEBUG'] else 20
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(log_level)

if proxy_path:
ReverseProxyPrefixFix(app)
app.wsgi_app = PrefixMiddleware(app.wsgi_app, prefix=proxy_path.rstrip("/"))

return app

Expand Down
13 changes: 13 additions & 0 deletions askomics/middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class PrefixMiddleware(object):

def __init__(self, app, prefix=''):
self.app = app
self.prefix = prefix

def __call__(self, environ, start_response):
if self.prefix is not None:
environ['SCRIPT_NAME'] = self.prefix
path_info = environ['PATH_INFO']
if path_info.startswith(self.prefix):
environ['PATH_INFO'] = path_info[len(self.prefix):]
return self.app(environ, start_response)
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/askomics/flaskomics-base:4.0.0-alpine3.13 AS builder
FROM quay.io/askomics/flaskomics-base:4.6.0-alpine3.19 AS builder
MAINTAINER "Xavier Garnier <[email protected]>"

COPY . /askomics
Expand All @@ -7,7 +7,7 @@ WORKDIR /askomics
RUN make clean-config fast-install build

# Final image
FROM alpine:3.13
FROM alpine:3.19

WORKDIR /askomics
RUN apk add --no-cache make python3 bash git libc-dev libstdc++ nodejs-current npm openldap-dev
Expand Down
4 changes: 2 additions & 2 deletions docker/DockerfileCelery
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/askomics/flaskomics-base:4.0.0-alpine3.13 AS builder
FROM quay.io/askomics/flaskomics-base:4.6.0-alpine3.19 AS builder
MAINTAINER "Xavier Garnier <[email protected]>"

COPY . /askomics
Expand All @@ -7,7 +7,7 @@ WORKDIR /askomics
RUN make clean-config fast-install

# Final image
FROM alpine:3.13
FROM alpine:3.19

WORKDIR /askomics
RUN apk add --no-cache make python3 bash git libc-dev libstdc++ openldap-dev
Expand Down

0 comments on commit aaffd84

Please sign in to comment.