Skip to content

Commit e1031cf

Browse files
committed
add docker-compose
1 parent ca6e07e commit e1031cf

7 files changed

Lines changed: 53 additions & 35 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,7 @@ cython_debug/
172172

173173
# PyPI configuration file
174174
.pypirc
175+
176+
177+
# vscode
178+
.vscode

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dockerfile
22

3-
FROM python:3.13-slim
3+
FROM python:3.12-slim
44

55
ENV PYTHONDONTWRITEBYTECODE 1
66
ENV PYTHONUNBUFFERED 1

docker-compose.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
version: '3.9'
2-
31
services:
42
web:
53
build: .
@@ -21,7 +19,7 @@ services:
2119
- POSTGRES_PORT=5432
2220

2321
db:
24-
image: postgres:16
22+
image: postgres
2523
restart: always
2624
environment:
2725
POSTGRES_DB: taskflow
@@ -31,7 +29,7 @@ services:
3129
- "5432:5432"
3230

3331
rabbitmq:
34-
image: rabbitmq:3.13-management
32+
image: rabbitmq:management
3533
ports:
3634
- "5672:5672"
37-
- "15672:15672"
35+
- "15672:15672"

requirements.txt

80 Bytes
Binary file not shown.

run_server.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
docker compose down
2+
docker compose build --no-cache
3+
docker compose up

start-dev-services.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
echo "🔍 Checking PostgreSQL container..."
4+
POSTGRES_STATUS=$(docker compose ps --status=running db | grep 'db' || true)
5+
6+
echo "🔍 Checking RabbitMQ container..."
7+
RABBITMQ_STATUS=$(docker compose ps --status=running rabbitmq | grep 'rabbitmq' || true)
8+
9+
if [[ -z "$POSTGRES_STATUS" || -z "$RABBITMQ_STATUS" ]]; then
10+
echo "🚀 Starting db and rabbitmq services..."
11+
docker compose up -d db rabbitmq
12+
else
13+
echo "✅ db and rabbitmq are already running."
14+
fi
15+
16+
echo "🛑 Ensuring web container is stopped..."
17+
docker compose stop web >/dev/null 2>&1 || true
18+
docker compose rm -f web >/dev/null 2>&1 || true
19+
20+
python3 manage.py migrate
21+
22+
echo "✅ Ready for local development. Run: python manage.py runserver"

taskflow_api/settings.py

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from pathlib import Path
3+
from decouple import config, Csv
34

45
# Build paths inside the project like this: BASE_DIR / 'subdir'.
56
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -8,14 +9,6 @@
89
# Quick-start development settings - unsuitable for production
910
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
1011

11-
# SECURITY WARNING: keep the secret key used in production secret!
12-
SECRET_KEY = 'django-insecure-%ih9li)=no$9s=93us((337b-79ya*%psbm)=0(csy^$c*qg%^'
13-
14-
# SECURITY WARNING: don't run with debug turned on in production!
15-
DEBUG = True
16-
17-
ALLOWED_HOSTS = []
18-
1912

2013
# Application definition
2114

@@ -68,27 +61,6 @@
6861
WSGI_APPLICATION = 'taskflow_api.wsgi.application'
6962

7063

71-
# Database
72-
# https://docs.djangoproject.com/en/5.2/ref/settings/#databases
73-
74-
# DATABASES = {
75-
# 'default': {
76-
# 'ENGINE': 'django.db.backends.sqlite3',
77-
# 'NAME': BASE_DIR / 'db.sqlite3',
78-
# }
79-
# }
80-
81-
DATABASES = {
82-
'default': {
83-
'ENGINE': 'django.db.backends.postgresql',
84-
'NAME': os.getenv('POSTGRES_DB'),
85-
'USER': os.getenv('POSTGRES_USER'),
86-
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
87-
'HOST': os.getenv('POSTGRES_HOST', 'localhost'),
88-
'PORT': os.getenv('POSTGRES_PORT', '5432'),
89-
}
90-
}
91-
9264
# Password validation
9365
# https://docs.djangoproject.com/en/5.2/ref/settings/#auth-password-validators
9466

@@ -136,3 +108,22 @@
136108
# MANUALLY ADDED
137109

138110
CORS_ALLOW_ALL_ORIGINS = True
111+
112+
113+
DEBUG = config('DEBUG', default=False, cast=bool)
114+
SECRET_KEY = config('SECRET_KEY', default='unsafe-dev-key')
115+
116+
ALLOWED_HOSTS = config('DJANGO_ALLOWED_HOSTS', cast=Csv(), default='localhost')
117+
118+
DATABASES = {
119+
'default': {
120+
'ENGINE': 'django.db.backends.postgresql',
121+
'NAME': config('POSTGRES_DB', default='taskflow'),
122+
'USER': config('POSTGRES_USER', default='postgres'),
123+
'PASSWORD': config('POSTGRES_PASSWORD', default='postgres'),
124+
'HOST': config('POSTGRES_HOST', default='localhost'),
125+
'PORT': config('POSTGRES_PORT', default='5432'),
126+
}
127+
}
128+
129+
CELERY_BROKER_URL = config('CELERY_BROKER_URL', default='amqp://guest:guest@localhost:5672//')

0 commit comments

Comments
 (0)