Skip to content
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
20 changes: 19 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# ADD DOCKERFILE CONTENT HERE
FROM python:3.12-slim

WORKDIR /app

COPY requirements.txt .

RUN apt-get update && apt-get install -y \
build-essential \
libpq-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*

RUN python -m venv /venv && /venv/bin/pip install --upgrade pip
RUN /venv/bin/pip install -r requirements.txt

COPY . .


EXPOSE 8000
11 changes: 6 additions & 5 deletions app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
SECRET_KEY = env('SECRET_KEY', default='django-insecure-change-this-key')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env('DEBUG')
DEBUG = True
#env('DEBUG')

ALLOWED_HOSTS = env.list('ALLOWED_HOSTS', default=['localhost', '127.0.0.1'])
ALLOWED_HOSTS = ['localhost', '127.0.0.1', '*']

# Application definition
INSTALLED_APPS = [
Expand All @@ -29,9 +30,9 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',

# Third party apps

# Local apps
'core',
]
Expand Down Expand Up @@ -137,4 +138,4 @@
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

# Default primary key field type
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
67 changes: 66 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1 +1,66 @@
# ADD Docker Compose CONTENT HERE
version: '3.9'

services:

redis:
image: docker.arvancloud.ir/redis:alpine3.22
restart: on-failure
container_name: redis
ports:
- "6379:6379"
volumes:
- redis_data:/data

db:
image: docker.arvancloud.ir/postgres:16.10-alpine
container_name: django_postgresql
environment:
POSTGRES_DB: djangodb
POSTGRES_USER: djangouser
POSTGRES_PASSWORD: djangopass
POSTGRES_HOST: db
POSTGRES_PORT: 5432
volumes:
- db_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -h localhost -U $POSTGRES_USER || exit 1"]
interval: 10s
timeout: 5s
retries: 5

django:
build: .
container_name: django_project
command: sh -c "cd /app/app &&
/venv/bin/gunicorn --bind 0.0.0.0:8000 config.wsgi:application &&
celery -A MediCaseBack worker -l info -P solo"
volumes:
- .:/app
- static_volume:/app/staticfiles
- media_volume:/app/media
ports:
- "8000:8000"
depends_on:
redis:
condition: service_started
db:
condition: service_started

nginx:
container_name: web-server
image: nginx:stable-perl
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
restart: on-failure
depends_on:
- django

volumes:
db_data:
redis_data:
static_volume:
media_volume:
29 changes: 28 additions & 1 deletion nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1 +1,28 @@
# ADD NGINX CONTENT HERE
user nginx;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 2048;
}

http{
upstream django_project {
server django:8000;
}

server{
listen 80 default_server;
server_name _;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

location / {
proxy_pass http://django_project;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_redirect off;
}
}
}