FossilRepo
| 4ce269c… | ragelink | 1 | #!/usr/bin/env bash |
| 4ce269c… | ragelink | 2 | set -euo pipefail |
| 4ce269c… | ragelink | 3 | |
| 4ce269c… | ragelink | 4 | # Fossilrepo — Django HTMX |
| 4ce269c… | ragelink | 5 | # Usage: ./run.sh [command] |
| 4ce269c… | ragelink | 6 | |
| 4ce269c… | ragelink | 7 | COMPOSE_FILE="" |
| 4ce269c… | ragelink | 8 | |
| 4ce269c… | ragelink | 9 | if [ -f "docker-compose.yml" ]; then |
| 4ce269c… | ragelink | 10 | COMPOSE_FILE="docker-compose.yml" |
| 4ce269c… | ragelink | 11 | elif [ -f "docker-compose.yaml" ]; then |
| 4ce269c… | ragelink | 12 | COMPOSE_FILE="docker-compose.yaml" |
| 4ce269c… | ragelink | 13 | fi |
| 4ce269c… | ragelink | 14 | |
| 4ce269c… | ragelink | 15 | compose() { |
| 4ce269c… | ragelink | 16 | if [ -n "$COMPOSE_FILE" ]; then |
| 4ce269c… | ragelink | 17 | docker compose -f "$COMPOSE_FILE" "$@" |
| 4ce269c… | ragelink | 18 | else |
| 4ce269c… | ragelink | 19 | echo "No docker-compose file found" |
| 4ce269c… | ragelink | 20 | exit 1 |
| 4ce269c… | ragelink | 21 | fi |
| 4ce269c… | ragelink | 22 | } |
| 4ce269c… | ragelink | 23 | |
| 4ce269c… | ragelink | 24 | case "${1:-help}" in |
| 4ce269c… | ragelink | 25 | up|start) |
| 4ce269c… | ragelink | 26 | compose up -d --build |
| 4ce269c… | ragelink | 27 | echo "Waiting for services..." |
| 4ce269c… | ragelink | 28 | sleep 5 |
| 4ce269c… | ragelink | 29 | compose exec -T backend python manage.py migrate --noinput 2>&1 | tail -3 |
| 4ce269c… | ragelink | 30 | echo "" |
| 4ce269c… | ragelink | 31 | echo "Services running. Check status with: ./run.sh status" |
| 4ce269c… | ragelink | 32 | ;; |
| 4ce269c… | ragelink | 33 | down|stop) |
| 4ce269c… | ragelink | 34 | compose down |
| 4ce269c… | ragelink | 35 | ;; |
| 4ce269c… | ragelink | 36 | restart) |
| 4ce269c… | ragelink | 37 | compose down |
| 4ce269c… | ragelink | 38 | compose up -d --build |
| 4ce269c… | ragelink | 39 | ;; |
| 4ce269c… | ragelink | 40 | status|ps) |
| 4ce269c… | ragelink | 41 | compose ps |
| 4ce269c… | ragelink | 42 | ;; |
| 4ce269c… | ragelink | 43 | logs) |
| 4ce269c… | ragelink | 44 | compose logs -f "${2:-}" |
| 4ce269c… | ragelink | 45 | ;; |
| 4ce269c… | ragelink | 46 | seed) |
| 4ce269c… | ragelink | 47 | compose exec -T backend python manage.py migrate --noinput 2>&1 | tail -3 |
| 4ce269c… | ragelink | 48 | compose exec -T backend python manage.py seed |
| 4ce269c… | ragelink | 49 | ;; |
| 4ce269c… | ragelink | 50 | test) |
| 4ce269c… | ragelink | 51 | compose exec backend python -m pytest --cov --cov-report=term-missing -v |
| 4ce269c… | ragelink | 52 | ;; |
| 4ce269c… | ragelink | 53 | lint) |
| 4ce269c… | ragelink | 54 | compose exec backend python -m ruff check . && compose exec backend python -m ruff format --check . |
| 4ce269c… | ragelink | 55 | ;; |
| 4ce269c… | ragelink | 56 | shell) |
| 4ce269c… | ragelink | 57 | compose exec backend bash |
| 4ce269c… | ragelink | 58 | ;; |
| 4ce269c… | ragelink | 59 | migrate) |
| 4ce269c… | ragelink | 60 | compose exec backend python manage.py migrate |
| 4ce269c… | ragelink | 61 | ;; |
| 4ce269c… | ragelink | 62 | help|*) |
| 4ce269c… | ragelink | 63 | echo "Usage: ./run.sh <command>" |
| 4ce269c… | ragelink | 64 | echo "" |
| 4ce269c… | ragelink | 65 | echo "Commands:" |
| 4ce269c… | ragelink | 66 | echo " up, start Start all services" |
| 4ce269c… | ragelink | 67 | echo " down, stop Stop all services" |
| 4ce269c… | ragelink | 68 | echo " restart Restart all services" |
| 4ce269c… | ragelink | 69 | echo " status, ps Show service status" |
| 4ce269c… | ragelink | 70 | echo " logs [svc] Tail logs (optionally for one service)" |
| 4ce269c… | ragelink | 71 | echo " seed Seed the database" |
| 4ce269c… | ragelink | 72 | echo " test Run tests" |
| 4ce269c… | ragelink | 73 | echo " lint Run linters" |
| 4ce269c… | ragelink | 74 | echo " shell Open a shell in the backend" |
| 4ce269c… | ragelink | 75 | echo " migrate Run database migrations" |
| 4ce269c… | ragelink | 76 | echo " help Show this help" |
| 4ce269c… | ragelink | 77 | ;; |
| 4ce269c… | ragelink | 78 | esac |