#!/usr/bin/env bash # Run the app locally using Docker Compose. # Starts postgres + app (no Caddy) and exposes the app at http://localhost:3000 # # Usage: # ./local.sh # build image and start # ./local.sh --no-build # skip rebuild (use cached image) # ./local.sh down # stop and remove containers set -euo pipefail ENV_FILE=".env.local" COMPOSE_FILES="-f docker-compose.yml -f docker-compose.dev.yml" if [[ "${1:-}" == "down" ]]; then docker compose $COMPOSE_FILES --env-file "$ENV_FILE" down echo "Stopped." exit 0 fi # Create .env.local from the example if it doesn't exist yet if [[ ! -f "$ENV_FILE" ]]; then cp .env.example "$ENV_FILE" # Point at the locally built image instead of DockerHub sed -i 's|^DOCKER_IMAGE=.*|DOCKER_IMAGE=at-tracker:local|' "$ENV_FILE" echo "Created $ENV_FILE — review it before continuing." echo " (DOCKER_IMAGE is already set to at-tracker:local for local builds)" echo "" fi # Build the image unless --no-build was passed if [[ "${1:-}" != "--no-build" ]]; then echo "Building image..." docker build -t at-tracker:local . fi echo "Starting postgres + app (http://localhost:3000)..." docker compose $COMPOSE_FILES --env-file "$ENV_FILE" up postgres app