97 lines
2.8 KiB
Bash
Executable file
97 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
echo "Setting up Traefik Multi-Environment Stack"
|
|
echo "=============================================="
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
echo "Checking prerequisites..."
|
|
|
|
command -v docker >/dev/null 2>&1 || {
|
|
echo -e "${RED}Docker is not installed${NC}"
|
|
exit 1
|
|
}
|
|
|
|
command -v docker compose >/dev/null 2>&1 || {
|
|
echo -e "${RED}Docker Compose is not installed${NC}"
|
|
exit 1
|
|
}
|
|
|
|
echo -e "${GREEN}Docker and Docker Compose are installed${NC}"
|
|
|
|
echo "Creating directory structure..."
|
|
mkdir -p traefik/{config,logs}
|
|
|
|
echo "Setting up SSL certificate storage..."
|
|
touch traefik/acme.json
|
|
chmod 600 traefik/acme.json
|
|
|
|
chmod +x init-databases.sh
|
|
|
|
echo "Creating Docker network..."
|
|
docker network create web 2>/dev/null || echo -e "${YELLOW}Network 'web' already exists${NC}"
|
|
|
|
if [ ! -f .env ]; then
|
|
echo "Creating .env file..."
|
|
cp .env.example .env
|
|
echo -e "${YELLOW}Please edit .env file with your actual values!${NC}"
|
|
else
|
|
echo -e "${GREEN}.env file already exists${NC}"
|
|
fi
|
|
|
|
SERVER_IP=$(curl -s ifconfig.me 2>/dev/null || echo "YOUR_SERVER_IP")
|
|
echo ""
|
|
echo "Cloudflare DNS Configuration Check"
|
|
echo "===================================="
|
|
echo "Make sure these DNS records are configured in Cloudflare:"
|
|
echo " - quest.vorteq.wulf.cloud -> ${SERVER_IP}"
|
|
echo " - dev.quest.vorteq.wulf.cloud -> ${SERVER_IP}"
|
|
echo " - testing.vorteq.wulf.cloud -> ${SERVER_IP}"
|
|
echo " - traefik.vorteq.wulf.cloud -> ${SERVER_IP}"
|
|
echo ""
|
|
echo "Important: Set DNS records to 'DNS only' (grey cloud)"
|
|
echo ""
|
|
|
|
# Generate auth secrets if needed
|
|
if grep -q "your-.*-secret-here" .env 2>/dev/null; then
|
|
echo -e "${YELLOW}Generating Better-Auth secrets...${NC}"
|
|
DEV_SECRET=$(openssl rand -base64 32)
|
|
TEST_SECRET=$(openssl rand -base64 32)
|
|
PROD_SECRET=$(openssl rand -base64 32)
|
|
|
|
sed -i "s/your-dev-secret-here/$DEV_SECRET/" .env
|
|
sed -i "s/your-test-secret-here/$TEST_SECRET/" .env
|
|
sed -i "s/your-prod-secret-here/$PROD_SECRET/" .env
|
|
echo -e "${GREEN}Generated and saved auth secrets${NC}"
|
|
else
|
|
echo -e "${GREEN}Auth secrets already configured${NC}"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Pre-flight Checklist"
|
|
echo "======================"
|
|
echo "Before running docker compose up, ensure:"
|
|
echo " - DNS records are configured"
|
|
echo " - Firewall allows ports 80 and 443"
|
|
echo " - .env file is configured"
|
|
echo " - Docker images are built (or registry is accessible)"
|
|
echo ""
|
|
|
|
read -p "Do you want to start the stack now? (y/N): " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Starting services..."
|
|
docker compose up -d
|
|
echo ""
|
|
echo -e "${GREEN}Stack is starting!${NC}"
|
|
echo ""
|
|
echo "View logs with: docker compose logs -f"
|
|
echo "SSL certificates may take a few minutes to provision"
|
|
else
|
|
echo ""
|
|
echo "Setup complete! Run 'docker compose up -d' when ready."
|
|
fi
|