Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

containerized the project #6

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: