mirror of
https://gitlab.w-hs.de/an14051/backerup-website.git
synced 2026-07-27 17:35:29 +00:00
40 lines
1.1 KiB
Bash
Executable File
40 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# deploy.sh — Build the image locally and start (or restart) the stack.
|
|
#
|
|
# Usage:
|
|
# ./docker/deploy.sh # rebuild & restart, keep existing data
|
|
# ./docker/deploy.sh --fresh # rebuild & restart, wipe all data volumes first
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
FRESH=false
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--fresh) FRESH=true ;;
|
|
*) echo "Unknown argument: $arg" >&2; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# Stop and remove existing containers
|
|
echo "==> Stopping existing containers…"
|
|
docker compose \
|
|
--file "$SCRIPT_DIR/docker-compose.yml" \
|
|
down --remove-orphans 2>/dev/null || true
|
|
|
|
# Optionally wipe data volumes
|
|
if [ "$FRESH" = true ]; then
|
|
echo "==> --fresh: removing data volumes…"
|
|
docker compose \
|
|
--file "$SCRIPT_DIR/docker-compose.yml" \
|
|
down --volumes 2>/dev/null || true
|
|
fi
|
|
|
|
# Build image and bring the stack up
|
|
echo "==> Building and starting stack via docker compose…"
|
|
docker compose \
|
|
--file "$SCRIPT_DIR/docker-compose.yml" \
|
|
up --build --detach --remove-orphans
|
|
|
|
echo "==> Backerup website is running at http://localhost:3000"
|