50 lines
No EOL
1.3 KiB
Bash
50 lines
No EOL
1.3 KiB
Bash
#!/bin/bash
|
|
# =============================================================================
|
|
# Gremlin Stack — Deploy Script
|
|
# Usage: ./deploy.sh
|
|
# Run from: services/swarm/stack/Gremlin/
|
|
# =============================================================================
|
|
|
|
set -euo pipefail
|
|
|
|
STACK_NAME="gremlin"
|
|
COMPOSE_FILE="gremlin-stack.yml"
|
|
ENV_FILE=".env"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
cd "$SCRIPT_DIR"
|
|
|
|
if [ ! -f "$ENV_FILE" ]; then
|
|
echo "ERROR: $ENV_FILE not found in $SCRIPT_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$COMPOSE_FILE" ]; then
|
|
echo "ERROR: $COMPOSE_FILE not found in $SCRIPT_DIR"
|
|
exit 1
|
|
fi
|
|
|
|
RESOLVED_FILE="${COMPOSE_FILE%.yml}.resolved.yml"
|
|
|
|
# Load env vars into shell so docker stack config can resolve them
|
|
echo "Loading environment from $ENV_FILE..."
|
|
set -a
|
|
source "$ENV_FILE"
|
|
set +a
|
|
|
|
# Preprocess — resolves all ${VAR} substitutions natively
|
|
echo "Preprocessing stack file..."
|
|
docker stack config --compose-file "$COMPOSE_FILE" > "$RESOLVED_FILE"
|
|
|
|
# Deploy from the resolved file
|
|
echo "Deploying stack: $STACK_NAME"
|
|
docker stack deploy --compose-file "$RESOLVED_FILE" "$STACK_NAME"
|
|
|
|
# Remove resolved file — contains plaintext secrets
|
|
rm -f "$RESOLVED_FILE"
|
|
echo "Cleaned up resolved file."
|
|
|
|
echo ""
|
|
echo "Deploy complete. Checking services..."
|
|
sleep 3
|
|
docker stack services "$STACK_NAME" |