Dockerization

This commit is contained in:
Athanasios Lakes 2024-12-12 14:09:51 +01:00
parent fc7e7afae6
commit bcaa066468
12 changed files with 223 additions and 118 deletions

26
docker-compose-deploy.yml Normal file

@ -0,0 +1,26 @@
version: '3.8'
services:
app:
build:
context: .
volumes:
- static_data/vol/web
env_file:
- .env
environment:
- SECRET_KEY=${SECRET_KEY}
- ALLOWED_HOSTS=${ALLOWED_HOSTS}
proxy:
build:
context: ./proxy
volumes:
- static_data:/vol/static
ports:
- "8080:8080"
depends_on:
- extremum
volumes:
static_data:

@ -20,20 +20,17 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
from dotenv import load_dotenv SECRET_KEY = os.environ.get('SECRET_KEY', "changeme")
env_path = load_dotenv(os.path.join(BASE_DIR, '.env'))
load_dotenv(env_path)
SECRET_KEY = os.getenv('SECRET_KEY', "django-insecure-0w^ybt_7vclag#rrutc_eo)m+l^@ml)t%jsg6n06siu)xyls+-")
# DEBUG setting # DEBUG setting
DEBUG = os.getenv('DEBUG', 'False') == 'True' DEBUG = bool(int(os.environ('DEBUG', 0)))
ALLOWED_HOSTS = ['127.0.0.1'] ALLOWED_HOSTS = []
ALLOWED_HOSTS_ENV = os.environ.get('ALLOWED_HOSTS')
if ALLOWED_HOSTS_ENV :
ALLOWED_HOSTS.extend(ALLOWED_HOSTS_ENV.split(','))
DEBUG_PROPAGATE_EXCEPTIONS = True DEBUG_PROPAGATE_EXCEPTIONS = True
SECURE_HSTS_SECONDS = 31536000 # One year SECURE_HSTS_SECONDS = 31536000 # One year
SECURE_HSTS_INCLUDE_SUBDOMAINS = True SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True SECURE_HSTS_PRELOAD = True
@ -66,7 +63,7 @@ MIDDLEWARE = [
"django_htmx.middleware.HtmxMiddleware", "django_htmx.middleware.HtmxMiddleware",
] ]
ROOT_URLCONF = "extremum_web.urls" ROOT_URLCONF = "extremum.urls"
TEMPLATES = [ TEMPLATES = [
{ {
@ -84,7 +81,7 @@ TEMPLATES = [
}, },
] ]
WSGI_APPLICATION = "extremum_web.wsgi.application" WSGI_APPLICATION = "extremum.wsgi.application"
# Database # Database
@ -124,10 +121,13 @@ AUTH_PASSWORD_VALIDATORS = [
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/ # https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = "/static/" STATIC_URL = "/static/static"
STATICFILES_DIRS = [BASE_DIR / "base/static"] STATICFILES_DIRS = [BASE_DIR / "base/static"]
STATIC_ROOT = BASE_DIR / 'staticfiles' # Define where static files are collected MEDIA_URL = "/static/media"
STATIC_ROOT = BASE_DIR / 'vol/web/static' # Define where static files are collected
MEDIA_ROOT = BASE_DIR / 'vol/web/media' # Define where static files are collected
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

@ -11,6 +11,6 @@ import os
from django.core.wsgi import get_wsgi_application from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'extremum_web.settings') os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'extremum.settings')
application = get_wsgi_application() application = get_wsgi_application()

12
proxy/default.conf Normal file

@ -0,0 +1,12 @@
server {
listen 8080;
location /static {
alias /vol/static;
}
location / {
uwsgi_pass app:8000;
include /etc/nginx/uwsgi_params;
}
}

13
proxy/uwsgi_params Normal file

@ -0,0 +1,13 @@
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;

@ -1,193 +1,237 @@
absl-py==2.1.0
alembic==1.13.2
anyio==4.4.0 anyio==4.4.0
argon2-cffi==23.1.0 argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0 argon2-cffi-bindings==21.2.0
args==0.1.0
arrow==1.3.0 arrow==1.3.0
asgiref==3.8.1 asgiref==3.8.1
asttokens==2.4.1 asttokens==2.4.1
astunparse==1.6.3
async-lru==2.0.4 async-lru==2.0.4
async-timeout==4.0.3
attrs==23.2.0 attrs==23.2.0
autobahn==23.6.2
Automat==22.10.0
autopage==0.5.2
Babel==2.15.0 Babel==2.15.0
backcall==0.2.0
beautifulsoup4==4.12.3 beautifulsoup4==4.12.3
black==24.4.2
bleach==6.1.0 bleach==6.1.0
blinker==1.4 blinker==1.8.2
cached-property==1.5.1 cachetools==5.4.0
certifi==2019.11.28 certifi==2024.6.2
cffi==1.16.0 cffi==1.16.0
chardet==3.0.4 channels==4.1.0
channels-redis==4.2.0
charset-normalizer==3.3.2 charset-normalizer==3.3.2
click==8.1.7 click==8.1.7
cloud-init==24.3.1 cliff==4.7.0
codecov==2.1.13 clint==0.5.1
collective.checkdocs==0.2 cmaes==0.10.0
cmd2==2.4.3
colorlog==6.8.2
comm==0.2.2 comm==0.2.2
configobj==5.0.6 constantly==23.10.4
contourpy==1.2.1 contourpy==1.2.1
coverage==7.5.1 coverage==7.6.1
crayons==0.4.0 cryptography==42.0.8
cryptography==2.8
cycler==0.12.1 cycler==0.12.1
dbus-python==1.2.16 Cython==3.0.10
debugpy==1.8.1 daphne==4.1.2
dash==2.9.3
dash-bootstrap-components==1.6.0
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
debugpy==1.8.2
decorator==5.1.1 decorator==5.1.1
defusedxml==0.7.1 defusedxml==0.7.1
distlib==0.3.8 dice-ml==0.11
distro==1.4.0 dict-and-html==1.0.11
dj-database-url==2.3.0 diff-match-patch==20230430
Django==5.0.6 Django==4.2.13
docker==4.1.0 django-bootstrap-v5==1.0.11
docker-compose==1.25.0 django-htmx==1.18.0
dockerpty==0.4.1 django-import-export==4.0.3
docopt==0.6.2 django-plotly-dash==2.3.1
docutils==0.21.2 django-redis==5.4.0
dpd_components==0.1.0
et-xmlfile==1.1.0 et-xmlfile==1.1.0
exceptiongroup==1.2.1 exceptiongroup==1.2.1
executing==2.0.1 executing==2.0.1
fastjsonschema==2.19.1 fastdtw==0.3.4
filelock==3.14.0 fastjsonschema==2.20.0
flake8==7.0.0 Flask==3.0.3
fonttools==4.53.0 flatbuffers==1.12
fonttools==4.51.0
fqdn==1.5.1 fqdn==1.5.1
fs==2.4.16 gast==0.4.0
gease==0.0.11 google-auth==2.32.0
gunicorn==23.0.0 google-auth-oauthlib==0.4.6
google-pasta==0.2.0
greenlet==3.0.3
grpcio==1.65.1
h11==0.14.0 h11==0.14.0
h5py==3.11.0
html-and-py==1.0.14
httpcore==1.0.5 httpcore==1.0.5
httpx==0.27.0 httpx==0.27.0
idna==2.8 hyperlink==21.0.0
importlib-metadata==1.5.0 idna==3.7
ipykernel==6.29.4 imbalanced-learn==0.12.3
ipython==8.12.3 incremental==22.10.0
ipykernel==6.29.5
ipython==8.25.0
ipywidgets==8.1.3
isoduration==20.11.0 isoduration==20.11.0
isort==5.13.2 itsdangerous==2.2.0
jedi==0.19.1 jedi==0.19.1
Jinja2==3.1.4 Jinja2==3.1.4
jinja2-fsloader==0.3.0
joblib==1.4.2 joblib==1.4.2
json5==0.9.25 json5==0.9.25
jsonpatch==1.22 jsonpointer==3.0.0
jsonpointer==2.0
jsonschema==4.22.0 jsonschema==4.22.0
jsonschema-specifications==2023.12.1 jsonschema-specifications==2023.12.1
jupyter==1.0.0
jupyter_client==8.6.2
jupyter-console==6.6.3
jupyter_core==5.7.2
jupyter-events==0.10.0 jupyter-events==0.10.0
jupyter-lsp==2.2.5 jupyter-lsp==2.2.5
jupyter_client==8.6.1 jupyter_server==2.14.2
jupyter_core==5.7.2
jupyter_server==2.14.1
jupyter_server_terminals==0.5.3 jupyter_server_terminals==0.5.3
jupyterlab==4.2.1 jupyterlab==4.2.4
jupyterlab_pygments==0.3.0 jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.2 jupyterlab_server==2.27.3
jupyterlab_widgets==3.0.11
keract==4.5.1
keras==2.9.0
Keras-Preprocessing==1.1.2
kiwisolver==1.4.5 kiwisolver==1.4.5
libclang==18.1.1
llvmlite==0.43.0 llvmlite==0.43.0
lml==0.1.0 Mako==1.3.5
lxml==5.2.2 mamba==0.11.3
Markdown==3.6
MarkupSafe==2.1.5 MarkupSafe==2.1.5
matplotlib==3.9.0 matplotlib==3.9.0
matplotlib-inline==0.1.7 matplotlib-inline==0.1.7
mccabe==0.7.0
mistune==3.0.2 mistune==3.0.2
moban==0.8.2 ml-dtypes==0.4.0
moban-jinja2-github==0.0.4 mlxtend==0.23.1
more-itertools==4.2.0 msgpack==1.0.8
mypy-extensions==1.0.0
nbclient==0.10.0 nbclient==0.10.0
nbconvert==7.16.4 nbconvert==7.16.4
nbeats-keras==1.8.0
nbformat==5.10.4 nbformat==5.10.4
nest-asyncio==1.6.0 nest-asyncio==1.6.0
netifaces==0.10.4 ngrok==1.4.0
nose==1.3.7 notebook==7.2.1
notebook_shim==0.2.4 notebook_shim==0.2.4
npx==0.1.6
numba==0.60.0 numba==0.60.0
numpy==1.26.4 numpy==1.23.5
oauthlib==3.1.0 nvidia-cublas-cu11==11.11.3.6
oauthlib==3.2.2
openpyxl==3.1.2 openpyxl==3.1.2
opt-einsum==3.3.0
optuna==2.10.1
overrides==7.7.0 overrides==7.7.0
packaging==24.0 packaging==24.2
pandas==2.2.2 pandas==1.5.3
pandocfilters==1.5.1 pandocfilters==1.5.1
parso==0.8.4 parso==0.8.4
pathspec==0.12.1 patsy==0.5.6
pexpect==4.6.0 pbr==6.0.0
pickleshare==0.7.5 pexpect==4.9.0
pillow==10.3.0 pillow==10.3.0
pip-chill==1.0.3 pip==24.3.1
pipenv==2023.12.1 pipdeptree==2.24.0
pipreqs==0.5.0
platformdirs==4.2.2 platformdirs==4.2.2
plotly==5.22.0
prettytable==3.10.2
prometheus_client==0.20.0 prometheus_client==0.20.0
prompt-toolkit==3.0.43 prompt_toolkit==3.0.47
psutil==5.9.8 protobuf==3.19.6
psycopg2-binary==2.9.10 psutil==6.0.0
ptyprocess==0.7.0 ptyprocess==0.7.0
pure-eval==0.2.2 pure-eval==0.2.2
pycairo==1.16.2 pyasn1==0.6.0
pycodestyle==2.11.1 pyasn1_modules==0.4.0
pycparser==2.22 pycparser==2.22
pyecharts-jupyter-installer==0.0.3
pyexcel==0.7.0
pyexcel-ezodf==0.3.4
pyexcel-handsontable==0.0.2
pyexcel-io==0.6.6
pyexcel-ods3==0.6.1
pyexcel-pygal==0.0.2
pyexcel-webio==0.1.4
pyexcel-xls==0.7.0
pyexcel-xlsx==0.6.0
pyflakes==3.2.0
pygal==3.0.4
Pygments==2.18.0 Pygments==2.18.0
PyGObject==3.36.0 pyOpenSSL==24.1.0
PyJWT==1.7.1
pyOpenSSL==19.0.0
pyparsing==3.1.2 pyparsing==3.1.2
pyrsistent==0.15.5 pyperclip==1.9.0
pyserial==3.4
python-apt==2.0.1+ubuntu0.20.4.1
python-dateutil==2.9.0.post0 python-dateutil==2.9.0.post0
python-dotenv==1.0.1 python-dotenv==1.0.1
python-json-logger==2.0.7 python-json-logger==2.0.7
pytz==2024.1 pytz==2024.1
PyYAML==5.3.1 PyWavelets==1.6.0
PyYAML==6.0.1
pyzmq==26.0.3 pyzmq==26.0.3
qtconsole==5.5.2
QtPy==2.4.1
raiutils==0.4.2
redis==5.0.6
referencing==0.35.1 referencing==0.35.1
requests==2.32.3 requests==2.32.3
requests-oauthlib==2.0.0
rfc3339-validator==0.1.4 rfc3339-validator==0.1.4
rfc3986-validator==0.1.1 rfc3986-validator==0.1.1
rpds-py==0.18.1 rpds-py==0.18.1
scikit-learn==1.5.0 rsa==4.9
scipy==1.13.1 scikit-base==0.8.2
scikit-learn==1.5.1
scipy==1.13.0
seaborn==0.13.2
Send2Trash==1.8.3 Send2Trash==1.8.3
six==1.14.0 service-identity==24.1.0
setuptools==65.5.0
six==1.16.0
sktime==0.31.0
sniffio==1.3.1 sniffio==1.3.1
sos==4.7.2
soupsieve==2.5 soupsieve==2.5
SQLAlchemy==2.0.31
sqlparse==0.5.0 sqlparse==0.5.0
ssh-import-id==5.10
stack-data==0.6.3 stack-data==0.6.3
statsmodels==0.14.2
stevedore==5.2.0
stumpy==1.13.0 stumpy==1.13.0
tablib==3.5.0
tenacity==8.3.0
tensorboard==2.9.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorflow==2.9.1
tensorflow-estimator==2.9.0
tensorflow-io-gcs-filesystem==0.37.1
termcolor==2.4.0
terminado==0.18.1 terminado==0.18.1
texttable==1.6.2 tfts==0.0.5
threadpoolctl==3.5.0 threadpoolctl==3.5.0
tinycss2==1.3.0 tinycss2==1.3.0
tomli==2.0.1 tomli==2.0.1
tornado==6.4 tornado==6.4.1
tqdm==4.66.4
traitlets==5.14.3 traitlets==5.14.3
Twisted==24.3.0
txaio==23.1.1
types-python-dateutil==2.9.0.20240316 types-python-dateutil==2.9.0.20240316
typing_extensions==4.11.0 typing_extensions==4.11.0
tzdata==2024.1
ufw==0.36
uri-template==1.3.0 uri-template==1.3.0
urllib3==1.25.8 urllib3==2.2.1
virtualenv==20.26.2 uWSGI==2.0.28
virtualenv-clone==0.5.7
wcwidth==0.2.13 wcwidth==0.2.13
webcolors==24.6.0 webcolors==24.8.0
webencodings==0.5.1 webencodings==0.5.1
websocket-client==1.8.0 websocket-client==1.8.0
Werkzeug==3.0.3
wheel==0.44.0
whitenoise==6.8.2
widgetsnbextension==4.0.11
wildboar==1.2.0 wildboar==1.2.0
xlrd==2.0.1 wrapt==1.16.0
xlwt==1.3.0 xgboost==2.0.3
yarg==0.1.9 XlsxWriter==3.2.0
zipp==1.0.0 zope.interface==6.4.post2

10
scripts/entrypoint.sh Normal file

@ -0,0 +1,10 @@
#!/bin/sh
set -e
python manage.py collectstatic --soinput
uwsgi --socket :8000 --master --enable-threads --module extremum.wsgi #TCP
# Start Apache
exec apachectl -D FOREGROUND