67 lines
2.4 KiB
Bash
Executable File
67 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ships what scripts/dev.sh already built and you've tested locally:
|
|
# rebuilds both images for the real production target (linux/amd64, via
|
|
# each build.sh's own registry-path branch) and pushes them, runs the
|
|
# backend test suite as the one gate before any of that happens, then
|
|
# pushes this branch to main so Dokploy's existing AutoDeploy (triggered
|
|
# by the git push itself, not by this script) pulls the new images.
|
|
#
|
|
# Requires:
|
|
# - Currently checked out on main, with no uncommitted changes — this
|
|
# ships exactly what's committed, never a locally-dirty tree.
|
|
# - backend/tests/ passing — the one gate between this and production;
|
|
# see playbook/ENTERPRISE_STANDARDS.md's coverage rules for
|
|
# stripe_webhook.py/billing.py specifically.
|
|
# - scripts/.env.prod (gitignored, copy from scripts/.env.prod.example)
|
|
# with the real registry image paths. Deliberately does NOT set
|
|
# DOKPLOY_URL/DOKPLOY_API_TOKEN/DOKPLOY_COMPOSE_ID — this script
|
|
# relies on the one already-proven trigger (git push to main, which
|
|
# Dokploy's webhook picks up) rather than also firing backend/build.sh's
|
|
# own direct-API trigger, which would otherwise redeploy twice for one
|
|
# prod.sh run. Add those three to .env.prod yourself if you'd rather
|
|
# switch entirely to the direct-API trigger instead.
|
|
#
|
|
# Usage: ./scripts/prod.sh
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
cd "$ROOT_DIR"
|
|
|
|
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
|
if [ "$BRANCH" != "main" ]; then
|
|
echo "Not on main (currently on '${BRANCH}') — merge/checkout main first." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
echo "Uncommitted changes present — commit or stash before shipping." >&2
|
|
exit 1
|
|
fi
|
|
|
|
PROD_ENV="${SCRIPT_DIR}/.env.prod"
|
|
if [ ! -f "$PROD_ENV" ]; then
|
|
echo "Missing ${PROD_ENV} — copy scripts/.env.prod.example and fill in the real registry paths first." >&2
|
|
exit 1
|
|
fi
|
|
set -a
|
|
# shellcheck disable=SC1090
|
|
source "$PROD_ENV"
|
|
set +a
|
|
|
|
echo "Running backend test suite..."
|
|
( cd backend && .venv/bin/pytest tests/ -q )
|
|
|
|
echo
|
|
echo "Building and pushing for linux/amd64..."
|
|
./erpnext-image/build.sh
|
|
./backend/build.sh
|
|
|
|
echo
|
|
echo "Pushing to main (triggers Dokploy's AutoDeploy)..."
|
|
git push origin main
|
|
|
|
echo
|
|
echo "Shipped. Watch Dokploy's Deployments tab for the result."
|