From 0a5540cef719367a1d1eb53758623a1d69202378 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 6 Jan 2023 16:55:25 +0000 Subject: [PATCH] Add Docker, Dokku deploys, Python 3.10, upgrade all dependencies --- Dockerfile | 26 ++++++ app.json | 27 ++++++ docker/nginx.conf | 30 +++++++ requirements.in | 1 + requirements.txt | 97 ++++++++++------------ requirements_dev.txt | 192 +++++++++++++++++++++---------------------- 6 files changed, 225 insertions(+), 148 deletions(-) create mode 100644 Dockerfile create mode 100644 app.json create mode 100644 docker/nginx.conf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a777859 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +FROM python:3.10-bullseye + +# Setup + +WORKDIR /app +COPY . . + +RUN mkdir -p /app/static + +# Python + +RUN pip install -r requirements.txt + +RUN python manage.py collectstatic --noinput + +# Webserver + +RUN apt-get update +RUN apt-get --assume-yes install nginx +COPY docker/nginx.conf /etc/nginx/sites-available/default + +# Run + +EXPOSE 80 + +CMD /bin/bash -c "/etc/init.d/nginx start && gunicorn --bind 0.0.0.0:8000 cove_project.wsgi:application" diff --git a/app.json b/app.json new file mode 100644 index 0000000..06cef46 --- /dev/null +++ b/app.json @@ -0,0 +1,27 @@ +{ + "scripts": { + "dokku": { + "predeploy": "python manage.py migrate" + } + }, + "cron": [ + { + "command": "python manage.py expire_files", + "schedule": "@daily" + } + ], + "dokkusd": { + "volumes": [ + {"host_subdir": "database", "container_path": "/app/database"}, + {"host_subdir": "media", "container_path": "/app/media"} + ], + "environment_variables": { + "DB_NAME": "/app/database/db.sqlite", + "DEBUG": "False" + }, + "nginx": { + "client_max_body_size": "10m" + }, + "keep_git_dir": true + } +} diff --git a/docker/nginx.conf b/docker/nginx.conf new file mode 100644 index 0000000..17423f4 --- /dev/null +++ b/docker/nginx.conf @@ -0,0 +1,30 @@ + +upstream django { + server localhost:8000; +} + +server { + + listen 80; + + location / { + proxy_pass http://django; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $host; + proxy_redirect off; + } + + location /static/ { + alias /app/static/; + } + + location /media/ { + alias /app/media/; + } + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + client_max_body_size 10M; + +} diff --git a/requirements.in b/requirements.in index cc391a2..8c2b2d1 100644 --- a/requirements.in +++ b/requirements.in @@ -4,3 +4,4 @@ Django>3.2,<3.3 jsonschema libcovebods==0.14.0 libcoveweb>=0.19.0 +gunicorn diff --git a/requirements.txt b/requirements.txt index ef9a737..1d2d2b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,26 +1,26 @@ # -# This file is autogenerated by pip-compile with python 3.6 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # -# pip-compile requirements.in +# pip-compile # -asgiref==3.4.1 +asgiref==3.6.0 # via django -attrs==21.2.0 +attrs==22.2.0 # via jsonschema -backports-datetime-fromisoformat==1.0.0 +backports-datetime-fromisoformat==2.0.0 # via flattentool -btrees==4.9.2 +btrees==4.11.3 # via zodb cached-property==1.5.2 # via libcove -certifi==2022.6.15 +certifi==2022.12.7 # via # requests # sentry-sdk -cffi==1.14.6 +cffi==1.15.1 # via persistent -charset-normalizer==2.0.6 +charset-normalizer==2.1.1 # via requests contextlib2==21.6.0 # via schema @@ -28,32 +28,30 @@ dealer==2.1.0 # via -r requirements.in defusedxml==0.7.1 # via odfpy -django==3.2.14 +django==3.2.16 # via # -r requirements.in # django-bootstrap3 # libcovebods # libcoveweb -django-bootstrap3==15.0.0 +django-bootstrap3==22.2 # via libcoveweb -django-environ==0.7.0 +django-environ==0.9.0 # via libcoveweb et-xmlfile==1.1.0 # via openpyxl -flattentool==0.17.1 +flattentool==0.20.0 # via # libcove # libcovebods # libcoveweb -idna==3.2 +gunicorn==20.1.0 + # via -r requirements.in +idna==3.4 # via requests -ijson==3.1.4 +ijson==3.2.0.post0 # via flattentool -importlib-metadata==2.1.1 - # via - # django-bootstrap3 - # jsonschema -jsonref==0.2 +jsonref==1.0.1 # via # flattentool # libcove @@ -61,93 +59,88 @@ jsonschema==3.2.0 # via # -r requirements.in # libcove -libcove==0.26.0 +libcove==0.29.0 # via # libcovebods # libcoveweb libcovebods==0.14.0 # via -r requirements.in -libcoveweb==0.24.1 +libcoveweb==0.25.0 # via # -r requirements.in # libcovebods -lxml==4.6.5 +lxml==4.9.2 # via flattentool odfpy==1.4.1 # via flattentool -openpyxl==3.0.9 +openpyxl==3.0.10 # via flattentool -packaging==21.3 +packaging==22.0 # via libcovebods -persistent==4.7.0 +persistent==4.9.3 # via # btrees # zodb -pycparser==2.20 +pycparser==2.21 # via cffi -pyparsing==3.0.9 - # via packaging -pyrsistent==0.18.0 +pyrsistent==0.19.3 # via jsonschema python-dateutil==2.8.2 # via libcovebods -pytz==2021.1 +pytz==2022.7 # via # django # flattentool -requests==2.26.0 +requests==2.28.1 # via # libcove # libcoveweb +rfc3339-validator==0.1.4 + # via libcove rfc3987==1.3.8 # via libcove -schema==0.7.4 +schema==0.7.5 # via flattentool -sentry-sdk==1.7.2 +sentry-sdk==1.12.1 # via -r requirements.in six==1.16.0 # via # jsonschema # python-dateutil + # rfc3339-validator # zodb -sqlparse==0.4.2 +sqlparse==0.4.3 # via django -strict-rfc3339==0.7 - # via libcove transaction==3.0.1 # via zodb -typing-extensions==4.1.1 - # via asgiref uc-rfc6266-parser==0.1.0 # via libcoveweb -urllib3==1.26.6 +urllib3==1.26.13 # via # requests # sentry-sdk werkzeug==1.0.1 # via uc-rfc6266-parser -xmltodict==0.12.0 +xmltodict==0.13.0 # via flattentool -zc.lockfile==2.0 +zc-lockfile==2.0 # via zodb -zc.zlibstorage==1.2.0 +zc-zlibstorage==1.2.0 # via flattentool -zconfig==3.6.0 +zconfig==3.6.1 # via zodb -zipp==3.5.0 - # via importlib-metadata -zodb==5.6.0 +zodb==5.8.0 # via # flattentool - # zc.zlibstorage -zodbpickle==2.0.0 + # zc-zlibstorage +zodbpickle==2.6 # via zodb -zope.interface==5.4.0 +zope-interface==5.5.2 # via # btrees # persistent # transaction - # zc.zlibstorage + # zc-zlibstorage # zodb # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements_dev.txt b/requirements_dev.txt index fba300a..f0ddf54 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,44 +1,53 @@ # -# This file is autogenerated by pip-compile with python 3.6 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.10 +# by the following command: # # pip-compile requirements_dev.in # -asgiref==3.4.1 +asgiref==3.6.0 # via # -r requirements.txt # django -attrs==21.2.0 +async-generator==1.10 + # via + # trio + # trio-websocket +attrs==22.2.0 # via # -r requirements.txt # jsonschema + # outcome # pytest -backports-datetime-fromisoformat==1.0.0 + # trio +backports-datetime-fromisoformat==2.0.0 # via # -r requirements.txt # flattentool -btrees==4.9.2 +btrees==4.11.3 # via # -r requirements.txt # zodb +build==0.9.0 + # via pip-tools cached-property==1.5.2 # via # -r requirements.txt # libcove -certifi==2022.6.15 +certifi==2022.12.7 # via # -r requirements.txt # requests + # selenium # sentry-sdk -cffi==1.14.6 +cffi==1.15.1 # via # -r requirements.txt # persistent -charset-normalizer==2.0.6 +charset-normalizer==2.1.1 # via # -r requirements.txt # requests -click==8.0.1 +click==8.1.3 # via pip-tools contextlib2==21.6.0 # via @@ -50,17 +59,17 @@ defusedxml==0.7.1 # via # -r requirements.txt # odfpy -django==3.2.14 +django==3.2.16 # via # -r requirements.txt # django-bootstrap3 # libcovebods # libcoveweb -django-bootstrap3==15.0.0 +django-bootstrap3==22.2 # via # -r requirements.txt # libcoveweb -django-environ==0.7.0 +django-environ==0.9.0 # via # -r requirements.txt # libcoveweb @@ -68,39 +77,34 @@ et-xmlfile==1.1.0 # via # -r requirements.txt # openpyxl -flake8==3.9.2 +exceptiongroup==1.1.0 + # via + # pytest + # trio +flake8==6.0.0 # via -r requirements_dev.in -flattentool==0.17.1 +flattentool==0.20.0 # via # -r requirements.txt # libcove # libcovebods # libcoveweb -gitdb==4.0.7 - # via gitpython -gitpython==3.1.18 - # via transifex-client -idna==3.2 +gunicorn==20.1.0 + # via -r requirements.txt +h11==0.14.0 + # via wsproto +idna==3.4 # via # -r requirements.txt # requests -ijson==3.1.4 + # trio +ijson==3.2.0.post0 # via # -r requirements.txt # flattentool -importlib-metadata==2.1.1 - # via - # -r requirements.txt - # click - # django-bootstrap3 - # flake8 - # jsonschema - # pep517 - # pluggy - # pytest iniconfig==1.1.1 # via pytest -jsonref==0.2 +jsonref==1.0.1 # via # -r requirements.txt # flattentool @@ -109,141 +113,140 @@ jsonschema==3.2.0 # via # -r requirements.txt # libcove -libcove==0.26.0 +libcove==0.29.0 # via # -r requirements.txt # libcovebods # libcoveweb libcovebods==0.14.0 # via -r requirements.txt -libcoveweb==0.24.1 +libcoveweb==0.25.0 # via # -r requirements.txt # libcovebods -lxml==4.6.5 +lxml==4.9.2 # via # -r requirements.txt # flattentool -mccabe==0.6.1 +mccabe==0.7.0 # via flake8 odfpy==1.4.1 # via # -r requirements.txt # flattentool -openpyxl==3.0.9 +openpyxl==3.0.10 # via # -r requirements.txt # flattentool -packaging==21.3 +outcome==1.2.0 + # via trio +packaging==22.0 # via # -r requirements.txt + # build # libcovebods # pytest -pep517==0.11.0 - # via pip-tools -persistent==4.7.0 +pep517==0.13.0 + # via build +persistent==4.9.3 # via # -r requirements.txt # btrees # zodb -pip-tools==6.3.0 +pip-tools==6.12.1 # via -r requirements_dev.in pluggy==1.0.0 # via pytest -py==1.10.0 - # via pytest -pycodestyle==2.7.0 +pycodestyle==2.10.0 # via flake8 -pycparser==2.20 +pycparser==2.21 # via # -r requirements.txt # cffi -pyflakes==2.3.1 +pyflakes==3.0.1 # via flake8 -pyparsing==3.0.9 - # via - # -r requirements.txt - # packaging -pyrsistent==0.18.0 +pyrsistent==0.19.3 # via # -r requirements.txt # jsonschema -pytest==6.2.5 +pysocks==1.7.1 + # via urllib3 +pytest==7.2.0 # via # -r requirements_dev.in # pytest-django -pytest-django==4.4.0 +pytest-django==4.5.2 # via -r requirements_dev.in -pytest-localserver==0.5.0 +pytest-localserver==0.7.0 # via -r requirements_dev.in python-dateutil==2.8.2 # via # -r requirements.txt # libcovebods -python-slugify==4.0.1 - # via transifex-client -pytz==2021.1 +pytz==2022.7 # via # -r requirements.txt # django # flattentool -requests==2.26.0 +requests==2.28.1 # via # -r requirements.txt # libcove # libcoveweb - # transifex-client +rfc3339-validator==0.1.4 + # via + # -r requirements.txt + # libcove rfc3987==1.3.8 # via # -r requirements.txt # libcove -schema==0.7.4 +schema==0.7.5 # via # -r requirements.txt # flattentool -selenium==3.141.0 +selenium==4.7.2 # via -r requirements_dev.in -sentry-sdk==1.7.2 +sentry-sdk==1.12.1 # via -r requirements.txt six==1.16.0 # via # -r requirements.txt # jsonschema # python-dateutil + # rfc3339-validator # transifex-client # zodb -smmap==4.0.0 - # via gitdb -sqlparse==0.4.2 +sniffio==1.3.0 + # via trio +sortedcontainers==2.4.0 + # via trio +sqlparse==0.4.3 # via # -r requirements.txt # django -strict-rfc3339==0.7 +tomli==2.0.1 # via - # -r requirements.txt - # libcove -text-unidecode==1.3 - # via python-slugify -toml==0.10.2 - # via pytest -tomli==1.2.1 - # via pep517 + # build + # pep517 + # pytest transaction==3.0.1 # via # -r requirements.txt # zodb -transifex-client==0.14.3 +transifex-client==0.12.5 # via -r requirements_dev.in -typing-extensions==4.1.1 +trio==0.22.0 # via - # -r requirements.txt - # asgiref - # gitpython + # selenium + # trio-websocket +trio-websocket==0.9.2 + # via selenium uc-rfc6266-parser==0.1.0 # via # -r requirements.txt # libcoveweb -urllib3==1.26.6 +urllib3[socks]==1.26.13 # via # -r requirements.txt # requests @@ -255,45 +258,42 @@ werkzeug==1.0.1 # -r requirements.txt # pytest-localserver # uc-rfc6266-parser -wheel==0.37.0 +wheel==0.38.4 # via pip-tools -xmltodict==0.12.0 +wsproto==1.2.0 + # via trio-websocket +xmltodict==0.13.0 # via # -r requirements.txt # flattentool -zc.lockfile==2.0 +zc-lockfile==2.0 # via # -r requirements.txt # zodb -zc.zlibstorage==1.2.0 +zc-zlibstorage==1.2.0 # via # -r requirements.txt # flattentool -zconfig==3.6.0 +zconfig==3.6.1 # via # -r requirements.txt # zodb -zipp==3.5.0 - # via - # -r requirements.txt - # importlib-metadata - # pep517 -zodb==5.6.0 +zodb==5.8.0 # via # -r requirements.txt # flattentool - # zc.zlibstorage -zodbpickle==2.0.0 + # zc-zlibstorage +zodbpickle==2.6 # via # -r requirements.txt # zodb -zope.interface==5.4.0 +zope-interface==5.5.2 # via # -r requirements.txt # btrees # persistent # transaction - # zc.zlibstorage + # zc-zlibstorage # zodb # The following packages are considered to be unsafe in a requirements file: