From f2878398cf3d7d9149062f9d26278e510a606b39 Mon Sep 17 00:00:00 2001 From: shymanskyi Date: Thu, 16 Nov 2023 17:48:30 +0200 Subject: [PATCH 1/4] #3 Create Docker File --- Dockerfile | 4 ++-- docker-compose.yml | 43 ++++++++++++++++++++++++++++++++++++++++++- sample.env | 8 ++++---- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 34102ed..0078c20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM python:3.9-alpine -WORKDIR /Forum +WORKDIR /Forum-Sandbox ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 @@ -13,4 +13,4 @@ RUN pip install --upgrade pip COPY ./requirements.txt . RUN pip3 install -r requirements.txt -COPY . /Forum +COPY . /Forum-Sandbox diff --git a/docker-compose.yml b/docker-compose.yml index 026d2f7..b5de4c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1 +1,42 @@ -version: '' +version: '3.9' + +services: + web: + build: . + command: gunicorn forum.wsgi:application --bind 0.0.0.0:8000 + volumes: + - ./:/Forum + ports: + - 8000:8000 + env_file: + - sample.env + depends_on: + - db + db: + image: postgres:14 + restart: always + volumes: + - db_data:/var/lib/postgresql/data + environment: + POSTGRES_USER: ${PG_USER} + POSTGRES_PASSWORD: ${PG_PASSWORD} + POSTGRES_DB: db + PGDATABASE: db + PGPASSWORD: ${PG_PASSWORD} + PGUSER: ${PG_USER} + ports: + - ${BD_PORT}:5432 + pgadmin4: + container_name: forum_pgadmin4 + image: dpage/pgadmin4 + restart: always + environment: + PGADMIN_DEFAULT_EMAIL: admin@admin.com # your email to login at http://localhost:5050/ + PGADMIN_DEFAULT_PASSWORD: 1 # your password to login at http://localhost:5050/ + ports: + - "5050:80" + volumes: + - pgadmin-data:/var/lib/pgadmin/data +volumes: + db_data: + pgadmin-data: diff --git a/sample.env b/sample.env index d42fcc1..3e49ba1 100644 --- a/sample.env +++ b/sample.env @@ -1,8 +1,8 @@ #db details -SECRET_KEY= -PG_DB= -PG_USER= -PG_PASSWORD= +SECRET_KEY= 1111 +PG_DB= Forum-Sandbox +PG_USER= user +PG_PASSWORD= postgres DB_HOST= DB_PORT= From 6dc29eb905d16fd7527d555f605f699bfc5b14ed Mon Sep 17 00:00:00 2001 From: shymanskyi Date: Thu, 16 Nov 2023 20:31:12 +0200 Subject: [PATCH 2/4] Update Dockerfile --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index b5de4c2..d8fc739 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,8 @@ services: environment: POSTGRES_USER: ${PG_USER} POSTGRES_PASSWORD: ${PG_PASSWORD} - POSTGRES_DB: db - PGDATABASE: db + POSTGRES_DB: ${PG_DB} + PGDATABASE: ${PG_DB} PGPASSWORD: ${PG_PASSWORD} PGUSER: ${PG_USER} ports: From 7c08a5aeed7a17a766da4ab50e65da117c40bcb0 Mon Sep 17 00:00:00 2001 From: shymanskyi Date: Thu, 16 Nov 2023 21:06:20 +0200 Subject: [PATCH 3/4] Fix naming issue in docker-compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d8fc739..2df7a86 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,7 +25,7 @@ services: PGPASSWORD: ${PG_PASSWORD} PGUSER: ${PG_USER} ports: - - ${BD_PORT}:5432 + - ${DB_PORT}:5432 pgadmin4: container_name: forum_pgadmin4 image: dpage/pgadmin4 From dd8968f4fdcc80640946cf5ed8c3cc9667b99e1b Mon Sep 17 00:00:00 2001 From: shymanskyi Date: Thu, 16 Nov 2023 23:49:33 +0200 Subject: [PATCH 4/4] Update sample.env --- sample.env | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sample.env b/sample.env index 3e49ba1..f11d28d 100644 --- a/sample.env +++ b/sample.env @@ -3,16 +3,16 @@ SECRET_KEY= 1111 PG_DB= Forum-Sandbox PG_USER= user PG_PASSWORD= postgres -DB_HOST= -DB_PORT= +DB_HOST= db +DB_PORT= 5432 #SMTP EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend -EMAIL_HOST= -EMAIL_PORT= -EMAIL_USE_TLS= -EMAIL_HOST_USER= -EMAIL_HOST_PASSWORD= +EMAIL_HOST= someuser@gmail.com +EMAIL_PORT= 587 +EMAIL_USE_TLS= 1 +EMAIL_HOST_USER= test@test.com +EMAIL_HOST_PASSWORD= test-password #origin hostnames allowed to make cross-site HTTP requests CORS_ORIGIN_WHITELIST=