From d3a01fe93dd834a08955cd7b1211c7be2b09207e Mon Sep 17 00:00:00 2001 From: bartool Date: Sun, 24 Nov 2024 17:58:43 +0000 Subject: [PATCH] setup docker image --- .gitignore | 3 ++- Dockerfile | 13 +++++++++++++ app/bartool_ovh/settings.py | 10 +++++++--- docker-compose.yml | 10 ++++++++++ requirements.txt | 2 ++ 5 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 5909789..01773fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .venv __pycache__ -db.sqlite3 \ No newline at end of file +db.sqlite3 +env.* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..86535de --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3-slim + +# set work directory +WORKDIR /usr/src/app + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +RUN pip install --upgrade pip +COPY ./requirements.txt . +RUN pip install -r requirements.txt diff --git a/app/bartool_ovh/settings.py b/app/bartool_ovh/settings.py index 5e2a46b..e133d6e 100644 --- a/app/bartool_ovh/settings.py +++ b/app/bartool_ovh/settings.py @@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path +import os from django.core.management.commands.runserver import Command as runserver runserver.default_port = "7100" @@ -24,12 +25,15 @@ BASE_DIR = Path(__file__).resolve().parent.parent # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-snqnsca90!r=^iu6yyhpxy^+mjm%7dvrg(lb!6fr3(!9yh(c30' +# SECRET_KEY = 'django-insecure-snqnsca90!r=^iu6yyhpxy^+mjm%7dvrg(lb!6fr3(!9yh(c30' +SECRET_KEY = os.environ.get("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +# DEBUG = True +DEBUG = bool(os.environ.get("DEBUG", default=0)) -ALLOWED_HOSTS = ['192.168.1.146'] +# ALLOWED_HOSTS = ['192.168.1.146'] +ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") # Application definition diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..27f3544 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + web: + build: . + command: gunicorn bartool_ovh.wsgi:application --bind 0.0.0.0:8000 + volumes: + - ./app/:/usr/src/app/ + ports: + - 8100:8000 + env_file: + - ./env.dev diff --git a/requirements.txt b/requirements.txt index c9c8336..106a6bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,8 @@ asgiref==3.8.1 Django==5.1.3 +gunicorn==23.0.0 holidays==0.61 +packaging==24.2 python-dateutil==2.9.0.post0 six==1.16.0 sqlparse==0.5.2