#!/bin/bash ######################################################### # --- APPLICATION --- # Starting, stopping, compiling a web application. # ######################################################### set -e cd "$(dirname "$0")/.." MODE=${1:-"*"} case $MODE in # Start the app in background and show status --start) echo "" echo "Starting app..." docker compose up -d --remove-orphans docker compose ps --format "table {{.Service}}\t{{.State}}\t{{.Ports}}" echo "The app is available at http://localhost:8000" echo "" ;; # Stop all running containers --stop) echo "" echo "Stoping app..." docker compose down echo "" ;; # Build images and start the app --build) echo "" echo "Build app..." docker compose up -d --build --remove-orphans docker compose ps --format "table {{.Service}}\t{{.State}}\t{{.Ports}}" echo "" ;; # Stream live logs from all containers --logs) echo "" echo "Logs of app (Ctrl+C to exit):" docker compose logs -f --tail=50 echo "" ;; # Remove all Docker cache and compose volumes --clean) echo "" echo "Cleaning Docker cache and volumes..." docker compose down --volumes docker system prune -f echo "" ;; # Show available flags --help) echo "" echo "Usage: ./appctl.sh [FLAGS]" echo "" echo "Flags:" echo " --start Start app" echo " --stop Stop app" echo " --build Build and start app" echo " --logs Show live logs" echo " --clean Clean Docker cache" echo " --help Show this help" echo "" exit 1 ;; # Unknown flag — show hint *) echo "" echo "No flag provided or unknown flag." echo "Run ./appctl.sh --help for usage." echo "" exit 1 ;; esac