forked from slowfound/one-traefik-multiple-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-production.sh
More file actions
60 lines (50 loc) · 1.97 KB
/
Copy pathdeploy-production.sh
File metadata and controls
60 lines (50 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Production deployment script for Traefik multi-project setup
# Set up environment
echo "Setting up environment for production deployment..."
# Create traefik-public network if it doesn't exist
if ! docker network ls | grep -q traefik-public; then
echo "Creating traefik-public network..."
docker network create traefik-public
fi
# Ask if user wants to generate a new password
read -p "Do you want to generate a new password for Traefik dashboard? (y/n): " generate_password
if [[ $generate_password == "y" || $generate_password == "Y" ]]; then
read -s -p "Enter new password: " new_password
echo ""
hashed_password=$(openssl passwd -apr1 "$new_password")
echo "Generated hashed password. Updating .env.production file..."
# Use sed to replace the HASHED_PASSWORD line in .env.production
sed -i "s|HASHED_PASSWORD=.*|HASHED_PASSWORD=$hashed_password|" traefik/.env.production
fi
# Copy production environment files
echo "Copying production environment files..."
cp traefik/.env.production traefik/.env
cp portfolio/.env.production portfolio/.env
# Authenticate with Google Artifact Registry
echo "Authenticating with Google Artifact Registry..."
echo "Note: You need to have gcloud CLI installed and be logged in"
gcloud auth configure-docker asia-southeast2-docker.pkg.dev
# Start Traefik
echo "Starting Traefik..."
cd traefik
docker-compose down
docker-compose up -d
cd ..
# Wait for Traefik to start
echo "Waiting for Traefik to initialize..."
sleep 10
# Start Portfolio
echo "Starting Portfolio service..."
cd portfolio
docker-compose down
docker-compose up -d
cd ..
echo "Deployment completed successfully!"
echo "Please ensure your DNS records are properly configured in Cloudflare:"
echo "- A record for yourdomain.com pointing to your server IP"
echo "- A record for traefik.yourdomain.com pointing to your server IP"
echo ""
echo "Your services should be available at:"
echo "- Portfolio: https://yourdomain.com"
echo "- Traefik Dashboard: https://traefik.yourdomain.com"