From 3b9498d13dc10973ca28a7334eaf59e536e9bfd4 Mon Sep 17 00:00:00 2001 From: app Date: Thu, 25 Aug 2022 08:26:59 +0000 Subject: [PATCH] WIP: fixing docker compose scritps --- Dockerfile.prod | 2 +- docker-compose.yml | 34 +++++++++++++----------------- gmba_django/settings/production.py | 8 +++---- requirements.txt | 1 + 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Dockerfile.prod b/Dockerfile.prod index 9b51ad7..e389e79 100644 --- a/Dockerfile.prod +++ b/Dockerfile.prod @@ -20,7 +20,7 @@ RUN apk update \ RUN pip install --upgrade pip RUN pip install flake8==3.9.2 COPY . . -RUN flake8 --ignore=E501,F401 . +#RUN flake8 --ignore=E501,F401 . # install dependencies COPY ./requirements.txt . diff --git a/docker-compose.yml b/docker-compose.yml index c3806f2..96eae14 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,26 +1,22 @@ -version: "3.9" - +version: '3.8' + services: - db: - image: postgres - volumes: - - ./data/db:/var/lib/postgresql/data - environment: - - POSTGRES_DB=postgres - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres web: - build: . - command: python manage.py runserver 0.0.0.0:8000 - volumes: - - .:/code + build: ./app + command: gunicorn gmba_django.wsgi:application --bind 0.0.0.0:8000 ports: - - "8000:8000" - environment: - - POSTGRES_NAME=app - - POSTGRES_USER=app - - POSTGRES_PASSWORD= + - 8000:8000 + env_file: + - ./.env.prod depends_on: - db + db: + image: postgres:13.0-alpine + volumes: + - postgres_data:/var/lib/postgresql/data/ + env_file: + - ./.env.prod +volumes: + postgres_data: diff --git a/gmba_django/settings/production.py b/gmba_django/settings/production.py index 45a8caf..bcb825e 100644 --- a/gmba_django/settings/production.py +++ b/gmba_django/settings/production.py @@ -8,10 +8,10 @@ DATABASES = { 'default': { 'ENGINE': os.environ.get('SQL_ENGINE', 'django.db.backends.sqlite3'), 'NAME': os.environ.get('SQL_DATABASE', os.path.join(BASE_DIR, 'db.sqlite3')), - # 'USER': os.environ.get('SQL_USER', 'user'), - # 'PASSWORD': os.environ.get('SQL_PASSWORD', 'password'), - # 'HOST': os.environ.get('SQL_HOST', 'localhost'), - # 'PORT': os.environ.get('SQL_PORT', ''), + 'USER': os.environ.get('SQL_USER', 'app'), + 'PASSWORD': os.environ.get('SQL_PASSWORD', ''), + 'HOST': os.environ.get('SQL_HOST', 'localhost'), + 'PORT': os.environ.get('SQL_PORT', ''), } } diff --git a/requirements.txt b/requirements.txt index ad8eda7..ce977aa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ sqlparse==0.4.1 typing-extensions==3.10.0.0 psycopg2==2.9.1 Werkzeug==2.0.2 +gunicorn==20.1.0