65 lines
1.7 KiB
Bash
Executable File
65 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Load parameters
|
|
ACTION=$1
|
|
ENV_FILE=".env"
|
|
|
|
# Detect docker compose command (cross-platform compatibility)
|
|
if command -v docker-compose >/dev/null 2>&1; then
|
|
DOCKER_COMPOSE="docker-compose"
|
|
elif command -v docker >/dev/null 2>&1 && docker compose version >/dev/null 2>&1; then
|
|
DOCKER_COMPOSE="docker compose"
|
|
else
|
|
echo "Error: Neither docker-compose nor docker compose found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if .env file exists
|
|
if [[ ! -f $ENV_FILE ]]; then
|
|
echo "Error: $ENV_FILE file not found!"
|
|
echo "Please create $ENV_FILE file with the following variables:"
|
|
echo "DEV_URL=your.domain.com"
|
|
echo "EXTERNAL_NETWORK=your_network_name"
|
|
echo "FORCE_HTTPS_REDIRECT=true # Set to 'false' to disable HTTPS redirect"
|
|
exit 1
|
|
fi
|
|
|
|
# Load environment variables
|
|
source $ENV_FILE
|
|
|
|
case "$ACTION" in
|
|
"up")
|
|
# Create network if it doesn't exist (cross-platform)
|
|
if ! docker network ls | grep -q "${EXTERNAL_NETWORK}"; then
|
|
docker network create "${EXTERNAL_NETWORK}" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# Check HTTPS redirect setting
|
|
if [[ "${FORCE_HTTPS_REDIRECT}" == "true" ]]; then
|
|
MSG="Starting with HTTPS redirect enabled..."
|
|
${DOCKER_COMPOSE} -f docker-compose.yml -f docker-compose.https-redirect.yml up -d
|
|
else
|
|
MSG="Starting without HTTPS redirect..."
|
|
${DOCKER_COMPOSE} up -d
|
|
fi
|
|
|
|
echo ""
|
|
echo "${MSG}"
|
|
sleep 2
|
|
echo ""
|
|
echo "Available services:"
|
|
echo "Traefik: https://traefik.${DEV_URL}"
|
|
echo "Portainer: https://portainer.${DEV_URL}"
|
|
;;
|
|
"restart")
|
|
${DOCKER_COMPOSE} restart
|
|
;;
|
|
"down")
|
|
${DOCKER_COMPOSE} down
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [up|restart|down]"
|
|
exit 1
|
|
;;
|
|
esac
|