From 3d36c4f33d78dd2a765627205b85119f5fabc650 Mon Sep 17 00:00:00 2001 From: Matthias De Smet Date: Mon, 19 Aug 2019 14:16:55 +0200 Subject: [PATCH 1/3] make requirements more lenient, text formatting --- setup.py | 71 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/setup.py b/setup.py index cdca4c6f..1ed1df4e 100644 --- a/setup.py +++ b/setup.py @@ -21,43 +21,45 @@ "Flask-Caching>=1.0.0", "Flask-DebugToolbar>=0.10.1", "Flask-Login>=0.4.0", - "Flask-SQLAlchemy==2.2", - "Flask-WTF==0.14.2", + "Flask-SQLAlchemy>=2.2", + "Flask-WTF>=0.14.2", "Flask==1.0.2", "future==0.16.0", "itsdangerous>=0.24", "Jinja2>=2.9.5", "markdown>=2.6.11", - "numpy==1.14.3", + "multiqc>=1.3", + "numpy>=1.14.3", "passlib==1.7.1", "plotly==2.0.15", - "pyyaml==3.12", + "pyyaml>=3.12", "SQLAlchemy>=1.1.5", - "Werkzeug==0.14.1", + "Werkzeug>=0.14.1", "WTForms>=2.1", # Testing - "pytest==3.0.6", - "WebTest==2.0.26", - "factory-boy==2.8.1", - "livereload==2.5.1", + "pytest>=3.0.6", + "WebTest>=2.0.26", + "factory-boy>=2.8.1", + "livereload>=2.5.1", # Lint and code style - #"flake8==3.3.0", - #flake8-blind-except==0.1.1", - #"flake8-debugger==1.4.0", - #"flake8-docstrings==1.0.3", - #"flake8-isort==2.1.3", - #"flake8-quotes==0.9.0", - #"isort==4.2.5", - #"pep8-naming==0.4.1", + # "flake8==3.3.0", + # flake8-blind-except==0.1.1", + # "flake8-debugger==1.4.0", + # "flake8-docstrings==1.0.3", + # "flake8-isort==2.1.3", + # "flake8-quotes==0.9.0", + # "isort==4.2.5", + # "pep8-naming==0.4.1", ] prod_reqs = dev_reqs + [ "psycopg2-binary>=2.6.2", "gunicorn>=19.7.1", ] -install_requires = prod_reqs if os.environ.get('MEGAQC_PRODUCTION') else dev_reqs +install_requires = prod_reqs if os.environ.get( + 'MEGAQC_PRODUCTION') else dev_reqs print("""----------------------------------- @@ -67,22 +69,23 @@ """.format(version)) setup( - name = 'megaqc', - version = version, - author = 'Phil Ewels', - author_email = 'phil.ewels@scilifelab.se', - description = "Collect and visualise data across multiple MultiQC runs", - long_description = __doc__, - keywords = ['bioinformatics', 'biology', 'sequencing', 'NGS', 'next generation sequencing', 'quality control'], - url = 'https://megaqc.info/', - download_url = 'https://github.com/ewels/MegaQC/releases', - license = 'GPLv3', - packages = ['megaqc'], - include_package_data = True, - zip_safe = False, - scripts = ['scripts/megaqc'], - install_requires = install_requires, - classifiers = [ + name='megaqc', + version=version, + author='Phil Ewels', + author_email='phil.ewels@scilifelab.se', + description="Collect and visualise data across multiple MultiQC runs", + long_description=__doc__, + keywords=['bioinformatics', 'biology', 'sequencing', 'NGS', + 'next generation sequencing', 'quality control'], + url='https://megaqc.info/', + download_url='https://github.com/ewels/MegaQC/releases', + license='GPLv3', + packages=['megaqc'], + include_package_data=True, + zip_safe=False, + scripts=['scripts/megaqc'], + install_requires=install_requires, + classifiers=[ 'Development Status :: 4 - Beta', 'Environment :: Console', 'Environment :: Web Environment', From f6cdf88fa5d023fef40dc4d2478313d096661852 Mon Sep 17 00:00:00 2001 From: Matthias De Smet Date: Mon, 19 Aug 2019 14:19:04 +0200 Subject: [PATCH 2/3] simplify docker image, decouple db, db settings settable with ENV variables --- Dockerfile | 86 ++++++++-------------------------------------- megaqc/settings.py | 9 +++-- 2 files changed, 20 insertions(+), 75 deletions(-) diff --git a/Dockerfile b/Dockerfile index b93d75ea..62220402 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,78 +1,20 @@ -FROM debian:latest +FROM tiangolo/meinheld-gunicorn-flask:python3.7 LABEL authors="phil.ewels@scilifelab.se,denis.moreno@scilifelab.se" \ description="Docker image running MegaQC" -# Install container-wide requrements -RUN apt-get update && apt-get install git -y && \ - apt-get install python2.7 -y && \ - apt-get install python2.7-dev -y && \ - apt-get install libyaml-dev -y && \ - apt-get install libffi-dev -y && \ - apt-get install libpng-dev -y && \ - apt-get install libfreetype6-dev -y && \ - apt-get install curl -y && \ - apt-get install gcc -y && \ - apt-get install g++ -y && \ - apt-get install apache2 -y - -# Enable apache mod_proxy -RUN a2enmod proxy -RUN a2enmod proxy_http - -# Overwrite apache config -RUN echo " \n\ - ServerName megaqc \n\ - ProxyPass / http://127.0.0.1:8000/ \n\ - ProxyPassReverse / http://127.0.0.1:8000/ \n\ -" > /etc/apache2/sites-enabled/000-default.conf - -# Fix matplotlib being dumb -RUN ln -s /usr/include/freetype2/ft2build.h /usr/include/ - -# Link python -RUN ln -s /usr/bin/python2.7 /usr/bin/python - -# Install pip -RUN curl -fsSL https://bootstrap.pypa.io/get-pip.py -o /opt/get-pip.py && \ - python /opt/get-pip.py && \ - rm /opt/get-pip.py - -# Install PostgreSQL and psycopg2 -RUN apt-get install postgresql-9.6 postgresql-server-dev-9.6 -y - -# Set data directory -ENV PGDATA /usr/local/lib/postgresql # Tell MegaQC to use postgres / psycopg2 -ENV MEGAQC_PRODUCTION 1 - -# create the data directory -RUN mkdir $PGDATA -RUN chown postgres $PGDATA -# Start postgres -# Create the basic requirements -RUN su postgres -c "/usr/lib/postgresql/9.6/bin/initdb" && \ -su postgres -c "/usr/lib/postgresql/9.6/bin/pg_ctl -D $PGDATA -w start" && \ -su postgres -c "/usr/lib/postgresql/9.6/bin/createuser megaqc_user" && \ -su postgres -c "/usr/lib/postgresql/9.6/bin/createdb megaqc -O megaqc_user" && \ -su postgres -c "/usr/lib/postgresql/9.6/bin/pg_ctl -D $PGDATA -w stop" - -# Install MegaQC -COPY . MegaQC -WORKDIR MegaQC -RUN python setup.py install - -# Set up the Postgres SQL server -RUN su postgres -c "/usr/lib/postgresql/9.6/bin/pg_ctl -D $PGDATA -w start" && \ - megaqc initdb && \ - su postgres -c "/usr/lib/postgresql/9.6/bin/pg_ctl -D $PGDATA -w stop" - -# Use volumes to persist logs and data -VOLUME ["/var/log/postgresql", "/usr/local/lib/postgresql"] - -# Run the MegaQC server -EXPOSE 80 -CMD su postgres -c "/usr/lib/postgresql/9.6/bin/pg_ctl -D $PGDATA -w start" && \ - service apache2 start && \ - gunicorn megaqc.wsgi:app --timeout 300 +ENV MEGAQC_PRODUCTION=1 \ + MEGAQC_SECRET="SuperSecretValueYouShouldReallyChange" \ + MEGAQC_CONFIG="" \ + APP_MODULE=megaqc.wsgi:app\ + DB_HOST="127.0.0.1" \ + DB_PORT="5432" \ + DB_NAME="megaqc" \ + DB_USER="megaqc" \ + DB_PASS="megaqcpswd" + +COPY . /app + +RUN pip install multiqc && python /app/setup.py install diff --git a/megaqc/settings.py b/megaqc/settings.py index 637d0ca1..2b5a3911 100644 --- a/megaqc/settings.py +++ b/megaqc/settings.py @@ -67,15 +67,18 @@ def update_db_uri(self): self.SQLALCHEMY_DATABASE ) + class ProdConfig(Config): """Production configuration.""" ENV = 'prod' DEBUG = False SQLALCHEMY_DBMS = 'postgresql' - SQLALCHEMY_USER = 'megaqc_user' - SQLALCHEMY_HOST = 'localhost:5432' - SQLALCHEMY_DATABASE = 'megaqc' + SQLALCHEMY_HOST = "{}:{}".format(os.environ.get( + 'DB_HOST', 'localhost'), os.environ.get('DB_PORT', '5432')) + SQLALCHEMY_USER = os.environ.get('DB_USER', 'megaqc') + SQLALCHEMY_PASS = os.environ.get('DB_PASS', 'megaqcpswd') + SQLALCHEMY_DATABASE = os.environ.get('DB_NAME', 'megaqc') DEBUG_TB_ENABLED = False # Disable Debug toolbar def __init__(self): From cf06e56f3cbf3ed425144da23243812e478a24a5 Mon Sep 17 00:00:00 2001 From: Matthias De Smet Date: Mon, 19 Aug 2019 15:06:18 +0200 Subject: [PATCH 3/3] fix double multiqc install --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 62220402..bf7c1dda 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,4 +17,4 @@ ENV MEGAQC_PRODUCTION=1 \ COPY . /app -RUN pip install multiqc && python /app/setup.py install +RUN python /app/setup.py install