feat: initialize deployment governance
This commit is contained in:
26
infra/backend-entrypoint.sh
Normal file
26
infra/backend-entrypoint.sh
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
python - <<'PY'
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
|
||||
host = os.environ.get("POSTGRES_HOST", "postgres")
|
||||
port = int(os.environ.get("POSTGRES_PORT", "5432"))
|
||||
deadline = time.time() + int(os.environ.get("POSTGRES_WAIT_TIMEOUT", "60"))
|
||||
|
||||
while True:
|
||||
try:
|
||||
with socket.create_connection((host, port), timeout=2):
|
||||
break
|
||||
except OSError:
|
||||
if time.time() > deadline:
|
||||
raise SystemExit(f"Timed out waiting for PostgreSQL at {host}:{port}")
|
||||
time.sleep(1)
|
||||
PY
|
||||
|
||||
python manage.py migrate --noinput
|
||||
python manage.py bootstrap_governance
|
||||
|
||||
exec "$@"
|
||||
@@ -9,5 +9,7 @@ COPY backend/pyproject.toml /app/pyproject.toml
|
||||
RUN pip install --no-cache-dir -e ".[dev]"
|
||||
|
||||
COPY backend /app
|
||||
COPY infra/backend-entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||
|
||||
@@ -31,7 +31,11 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: infra/backend.Dockerfile
|
||||
entrypoint: ["/entrypoint.sh"]
|
||||
command: ["python", "manage.py", "runserver", "0.0.0.0:8000"]
|
||||
env_file:
|
||||
- path: ../.env.example
|
||||
required: true
|
||||
- path: ../.env
|
||||
required: false
|
||||
ports:
|
||||
@@ -46,10 +50,12 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: infra/backend.Dockerfile
|
||||
command: celery -A config.celery worker -l info
|
||||
env_file:
|
||||
- path: ../.env.example
|
||||
required: true
|
||||
- path: ../.env
|
||||
required: false
|
||||
command: celery -A config.celery worker -l info
|
||||
depends_on:
|
||||
- backend
|
||||
- redis
|
||||
@@ -60,6 +66,11 @@ services:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: infra/frontend.Dockerfile
|
||||
env_file:
|
||||
- path: ../.env.example
|
||||
required: true
|
||||
- path: ../.env
|
||||
required: false
|
||||
ports:
|
||||
- "5173:5173"
|
||||
volumes:
|
||||
|
||||
Reference in New Issue
Block a user