From a5195d2fe99e8dd85cac449a73e2e96d5ab98043 Mon Sep 17 00:00:00 2001 From: rlacko <rlacko@sch.bme.hu> Date: Tue, 4 Feb 2020 17:44:20 +0100 Subject: [PATCH] added Dockerfile --- Dockerfile | 21 +++++++++++++++++++++ requirements/development.in | 2 +- requirements/production.in | 9 ++++++++- src/kszkepzes/settings/base.py | 7 ++++--- src/kszkepzes/settings/local.py | 2 ++ src/kszkepzes/settings/production.py | 2 +- 6 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f2d46d5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# pull official base image +FROM python:3.8.0 + +# set work directory +WORKDIR /usr/src/app + +# set environment variables +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +# install dependencies +RUN apt-get -y update +RUN apt-get install -y python python-pip python-dev python-django-extensions +RUN pip install --upgrade pip +COPY ./requirements/development.txt /usr/src/app/requirements.txt +RUN pip install -r requirements.txt + +RUN apt-get -y update && apt-get -y autoremove + +# copy project +COPY ./src /usr/src/app/ \ No newline at end of file diff --git a/requirements/development.in b/requirements/development.in index 0ca557c..e38b674 100644 --- a/requirements/development.in +++ b/requirements/development.in @@ -5,4 +5,4 @@ django-extensions==2.2.1 python-language-server==0.28.2 drf-yasg==1.16.1 packaging==19.1 -Pillow \ No newline at end of file +Pillow==7.0.0 \ No newline at end of file diff --git a/requirements/production.in b/requirements/production.in index 725c782..71c1587 100644 --- a/requirements/production.in +++ b/requirements/production.in @@ -1,3 +1,10 @@ -r base.in +psycopg2-binary gunicorn==19.7.1 -Pillow +flake8==3.7.8 +pip-tools==4.1.0 +django-extensions==2.2.1 +python-language-server==0.28.2 +drf-yasg==1.16.1 +packaging==19.1 +Pillow==7.0.0 diff --git a/src/kszkepzes/settings/base.py b/src/kszkepzes/settings/base.py index 5fdbd69..79bb090 100644 --- a/src/kszkepzes/settings/base.py +++ b/src/kszkepzes/settings/base.py @@ -156,7 +156,8 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ -STATIC_URL = '/django-static/' +STATIC_URL = '/staticfiles/' +STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") -MEDIA_ROOT = os.getenv('MEDIA_ROOT', '/tmp') -MEDIA_URL = '/media/' +MEDIA_URL = "/mediafiles/" +MEDIA_ROOT = os.path.join(BASE_DIR, "mediafiles") diff --git a/src/kszkepzes/settings/local.py b/src/kszkepzes/settings/local.py index caa2719..1c4e0b5 100644 --- a/src/kszkepzes/settings/local.py +++ b/src/kszkepzes/settings/local.py @@ -1,5 +1,7 @@ from .base import * +DEBUG = int(os.environ.get("DEBUG", default=1)) + SESSION_COOKIE_SECURE = False EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' diff --git a/src/kszkepzes/settings/production.py b/src/kszkepzes/settings/production.py index cbd8659..7c121b5 100644 --- a/src/kszkepzes/settings/production.py +++ b/src/kszkepzes/settings/production.py @@ -1,6 +1,6 @@ from .base import * -DEBUG = False +DEBUG = int(os.environ.get("DEBUG", default=0)) ALLOWED_HOSTS = ['*'] -- GitLab