#!/bin/bash
set -e
set -x

# 1. Shut down existing containers
docker compose down --remove-orphans

# 2. Build and start containers in the background
# The Dockerfile's CMD will handle migrations and runserver automatically.
docker compose up -d --build

# 3. (Optional) Check the logs to ensure the migrations finished successfully
docker compose logs -f
