fix: deploy.sh migrate works without .env.docker on production
Some checks failed
Deploy to Production / Build and Deploy (push) Failing after 1m59s

This commit is contained in:
2026-05-31 21:45:55 +02:00
parent 374c605027
commit c7c1fd8436

View File

@@ -66,9 +66,21 @@ warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; } error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
header() { echo ""; echo -e "${BOLD}${CYAN}========================================${NC}"; echo -e "${BOLD}${CYAN} $*${NC}"; echo -e "${BOLD}${CYAN}========================================${NC}"; } header() { echo ""; echo -e "${BOLD}${CYAN}========================================${NC}"; echo -e "${BOLD}${CYAN} $*${NC}"; echo -e "${BOLD}${CYAN}========================================${NC}"; }
# ---- Auto-detect env file if not overridden by --env ----
# Prefer .env.docker (local dev), fall back to .env (production)
if [ ! -f "$ENV_FILE" ]; then
if [ -f ".env" ]; then
ENV_FILE=".env"
fi
fi
# Run docker compose with the right file and env # Run docker compose with the right file and env
dc() { dc() {
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" "$@" if [ -f "$ENV_FILE" ]; then
docker compose -f "$COMPOSE_FILE" --env-file "$ENV_FILE" "$@"
else
docker compose -f "$COMPOSE_FILE" "$@"
fi
} }
# ---- Parse Arguments ---- # ---- Parse Arguments ----
@@ -401,7 +413,8 @@ cmd_shell() {
cmd_migrate() { cmd_migrate() {
header "Running Database Migrations" header "Running Database Migrations"
info "Running alembic upgrade head..." info "Running alembic upgrade head..."
dc exec backend alembic upgrade head # Run directly inside the backend container — no env file needed
docker compose -f "$COMPOSE_FILE" exec backend alembic upgrade head
success "Migrations complete" success "Migrations complete"
} }