mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-22 07:41:14 +00:00
allow redis and postgres to run in docker compose
This commit is contained in:
parent
baebc0b690
commit
aae6733e4b
@ -16,6 +16,7 @@
|
||||
from django.conf import settings
|
||||
from django.core.management import call_command
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.db import connection
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
@ -29,7 +30,7 @@ class Command(BaseCommand):
|
||||
if not data_dir.is_dir():
|
||||
data_dir.mkdir()
|
||||
db_path = settings.BASE_DIR / "db.sqlite3"
|
||||
if db_path.exists():
|
||||
if db_path.exists() or connection.vendor != "sqlite":
|
||||
call_command("flush", "--noinput")
|
||||
self.stdout.write("Existing database reset")
|
||||
call_command("migrate")
|
||||
|
36
docker-compose.yml
Normal file
36
docker-compose.yml
Normal file
@ -0,0 +1,36 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres:16.6
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
ports:
|
||||
- "5431:5432"
|
||||
environment:
|
||||
POSTGRES_USER: sith
|
||||
POSTGRES_PASSWORD: sith
|
||||
POSTGRES_DB: sith
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.5'
|
||||
memory: 512M
|
||||
ports:
|
||||
- "6378:6379"
|
||||
command: redis-server
|
||||
volumes:
|
||||
- redis_data:/var/lib/redis/data/
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
redis_data:
|
||||
driver: local
|
||||
|
Loading…
Reference in New Issue
Block a user