helper scripts

This commit is contained in:
2026-02-03 14:18:03 -03:00
parent 3db8c0c453
commit ffbbf87873
4 changed files with 69 additions and 9 deletions

View File

@@ -7,12 +7,12 @@ POSTGRES_USER=mpr_user
POSTGRES_PASSWORD=mpr_pass
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
DATABASE_URL=postgresql://mpr_user:mpr_pass@postgres:5432/mpr
# Redis
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_URL=redis://${REDIS_HOST}:${REDIS_PORT}/0
REDIS_URL=redis://redis:6379/0
# Django
DEBUG=1

View File

@@ -23,7 +23,7 @@ services:
POSTGRES_USER: mpr_user
POSTGRES_PASSWORD: mpr_pass
ports:
- "5433:5432"
- "5435:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
@@ -150,3 +150,5 @@ volumes:
networks:
default:
name: mpr
name: mpr

View File

@@ -1,12 +1,16 @@
#!/bin/bash
# Run MPR stack locally
# Usage: ./ctrl/run.sh [docker-compose args]
# Usage: ./run.sh [OPTIONS] [docker-compose args]
#
# Options:
# -f, --foreground Run in foreground (don't detach)
# --build Rebuild images before starting
#
# Examples:
# ./ctrl/run.sh # Start all services
# ./ctrl/run.sh --build # Rebuild and start
# ./ctrl/run.sh -d # Detached mode
# ./ctrl/run.sh down # Stop all
# ./run.sh # Start detached
# ./run.sh -f # Start in foreground (see logs)
# ./run.sh --build # Rebuild and start
# ./run.sh logs -f # Follow logs
set -e
@@ -30,4 +34,27 @@ if ! grep -q "mpr.local.ar" /etc/hosts 2>/dev/null; then
echo ""
fi
docker compose "$@"
# Parse options
DETACH="-d"
BUILD=""
while [[ $# -gt 0 ]]; do
case $1 in
-f|--foreground)
DETACH=""
shift
;;
--build)
BUILD="--build"
shift
;;
*)
# Pass remaining args to docker compose
docker compose "$@"
exit $?
;;
esac
done
# Default: up with options
docker compose up $DETACH $BUILD

31
ctrl/stop.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
# Stop MPR stack
# Usage: ./stop.sh [OPTIONS]
#
# Options:
# -v, --volumes Also remove volumes (database data)
#
# Examples:
# ./stop.sh # Stop containers
# ./stop.sh -v # Stop and remove volumes
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
VOLUMES=""
while [[ $# -gt 0 ]]; do
case $1 in
-v|--volumes)
VOLUMES="-v"
shift
;;
*)
shift
;;
esac
done
docker compose down $VOLUMES