Skip to content

Commit

Permalink
containerize the project
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvrajrathva committed Oct 13, 2023
1 parent b0911ea commit d607381
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 6 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**/*.pyc
**/*.pyo
**/*.log
**/*.egg-info
**/__pycache__
.venv/

**/node_modules/
.travis.yml
# .env
.env.example
.git/
.gitignore
.idea/
.gitmodules
db.sqlite3
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM devlup/django-base:latest

WORKDIR /app

COPY . .
12 changes: 6 additions & 6 deletions backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
54 changes: 54 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit d607381

Please sign in to comment.