diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d2a9984 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM python:3.11-alpine + +RUN apk add bash + +COPY requirements.txt requirements.txt + +RUN pip install -r requirements.txt + +COPY . . + +ARG HAT_DEBUG='False' +ARG HAT_STATIC_ROOT='/static-root' +ARG HAT_ALLOWED_HOSTS='0.0.0.0' +ARG HAT_SQLITE3_PATH='/db.sqlite3' + + +ENV HAT_DEBUG=${HAT_DEBUG} +ENV HAT_SECRET_KEY=${HAT_SECRET_KEY} +ENV HAT_STATIC_ROOT=${HAT_STATIC_ROOT} +ENV HAT_ALLOWED_HOSTS=${HAT_ALLOWED_HOSTS} +ENV HAT_SQLITE3_PATH=${HAT_SQLITE3_PATH} + +EXPOSE 8000/ + +ENTRYPOINT python manage.py migrate \ + && python manage.py collectstatic --no-input \ + && honcho start \ No newline at end of file diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..9e4ffdc --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: python -m gunicorn agenda_hat.asgi:application -k uvicorn.workers.UvicornWorker \ No newline at end of file diff --git a/agenda_hat/settings.py b/agenda_hat/settings.py index e0075aa..96de4ca 100644 --- a/agenda_hat/settings.py +++ b/agenda_hat/settings.py @@ -12,6 +12,8 @@ from pathlib import Path +import os + # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent @@ -20,13 +22,15 @@ # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-4=nvn+3!^^#3489hot0brrx-!m+efx_^+x@^mwq^)c-$#u^^_m' - +# SECRET_KEY = 'django-insecure-4=nvn+3!^^#3489hot0brrx-!m+efx_^+x@^mwq^)c-$#u^^_m' +SECRET_KEY = os.environ['HAT_SECRET_KEY'] # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = {'False': False, 'True': True}[os.environ['HAT_DEBUG']] -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = os.environ['HAT_ALLOWED_HOSTS'].split(',') +CSRF_TRUSTED_ORIGINS = ['https://'+host for host in ALLOWED_HOSTS] +STATIC_ROOT = Path(os.environ['HAT_STATIC_ROOT']) # Application definition diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5c4df08 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +django +honcho +uvicorn +gunicorn \ No newline at end of file