From d60738188fa8209a6d68907d569401a664944165 Mon Sep 17 00:00:00 2001 From: Yuvraj Rathva Date: Fri, 13 Oct 2023 19:25:39 +0530 Subject: [PATCH] containerize the project --- .dockerignore | 16 ++++++++++++++ Dockerfile | 5 +++++ backend/settings.py | 12 +++++----- docker-compose.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c3dcf7f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,16 @@ +**/*.pyc +**/*.pyo +**/*.log +**/*.egg-info +**/__pycache__ +.venv/ + +**/node_modules/ +.travis.yml +# .env +.env.example +.git/ +.gitignore +.idea/ +.gitmodules +db.sqlite3 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6c0abef --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM devlup/django-base:latest + +WORKDIR /app + +COPY . . diff --git a/backend/settings.py b/backend/settings.py index 4d85dd8..3004251 100644 --- a/backend/settings.py +++ b/backend/settings.py @@ -146,12 +146,12 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -# Rest Framework -REST_FRAMEWORK = { - 'DEFAULT_AUTHENTICATION_CLASSES': [ - 'registration.authenticate.CustomAuthentication', - ], -} +# # Rest Framework +# REST_FRAMEWORK = { +# 'DEFAULT_AUTHENTICATION_CLASSES': [ +# 'registration.authenticate.CustomAuthentication', +# ], +# } # Simple JWT SIMPLE_JWT = { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..549595b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,54 @@ +version: '3' +services: + django: + build: + context: . + dockerfile: Dockerfile + image: ufb + container_name: ufb-django-backend + restart: unless-stopped + env_file: .env + environment: + - DB_HOST=postgresqldb + - CHOKIDAR_USEPOLLING=true + ports: + - 8000:8000 + volumes: + - .:/app + depends_on: + - postgresqldb + networks: + - app-network + command: + - /bin/sh + - -c + - | + python manage.py makemigrations + python manage.py migrate + python manage.py runserver 0.0.0.0:8000 + postgresqldb: + image: 'bitnami/postgresql:latest' + container_name: ufb-postgresql-db + restart: unless-stopped + env_file: .env + environment: + - POSTGRESQL_USERNAME=$POSTGRES_DB_USER + - POSTGRESQL_PASSWORD=$POSTGRES_DB_PASSWORD + - POSTGRESQL_DATABASE=$POSTGRES_DB_NAME + healthcheck: + test: ["CMD-SHELL", "pg_isready -U $POSTGRES_DB_USER"] + interval: 10s + timeout: 5s + retries: 5 + volumes: + - dbdata:/bitnami/postgresql + networks: + - app-network + +networks: + app-network: + driver: bridge + +volumes: + dbdata: + \ No newline at end of file