fix(staging): fix Traefik service linking with explicit service labels

This commit is contained in:
2026-03-01 00:23:52 +01:00
committed by Clawd Agent
parent 4b39f39e3e
commit 22750bfa06
2 changed files with 19 additions and 76 deletions
+7 -56
View File
@@ -1,61 +1,12 @@
#!/bin/bash
# Create staging environment for a branch
BRANCH_NAME=${1:-}
if [ -z "$BRANCH_NAME" ]; then
echo "Usage: $0 <branch-name>"
echo "Example: $0 03-design-polish"
exit 1
fi
echo "Creating staging for branch: $BRANCH_NAME"
# Create temp directory
BRANCH_NAME=$1
if [ -z "$BRANCH_NAME" ]; then echo "Usage: $0 <branch-name>"; exit 1; fi
STAGING_DIR=/tmp/staging-$BRANCH_NAME-$(date +%s)
mkdir -p $STAGING_DIR
# Clone repo
git clone --branch feature/$BRANCH_NAME /workspace/gravl "$STAGING_DIR" 2>/dev/null || {
echo "Failed to clone branch feature/$BRANCH_NAME"
exit 1
}
git clone --branch feature/$BRANCH_NAME /workspace/gravl "$STAGING_DIR"
cd "$STAGING_DIR"
# Replace placeholder with actual branch name
sed -i "s/BRANCH_NAME/$BRANCH_NAME/g" docker-compose.yml
cat docker-compose.staging.yml | sed "s/BRANCH_NAME/$BRANCH_NAME/g" > docker-compose.staging-override.yml
# Create staging DB volume
sed -i "s/PLACEHOLDER/$BRANCH_NAME/g" docker-compose.staging.yml
mkdir -p .staging
# Start services
echo "Starting staging containers..."
docker compose -f docker-compose.yml -f docker-compose.staging-override.yml up -d
# Register metadata
cat > ".staging/$BRANCH_NAME.json" << EOF
{
"branch": "$BRANCH_NAME",
"featureBranch": "feature/$BRANCH_NAME",
"stagingUrl": "https://$BRANCH_NAME.gravl.homelab.local",
"apiUrl": "https://$BRANCH_NAME.api.gravl.homelab.local",
"created": "$(date -Iseconds)",
"status": "active",
"containers": {
"frontend": "staging-gravl-frontend-$BRANCH_NAME",
"backend": "staging-gravl-backend-$BRANCH_NAME",
"db": "staging-gravl-db-$BRANCH_NAME"
}
}
EOF
echo ""
echo "✅ Staging environment ready!"
echo ""
echo "🌐 URL: https://$BRANCH_NAME.gravl.homelab.local"
echo "📡 API: https://$BRANCH_NAME.api.gravl.homelab.local"
echo ""
echo "Make sure to add to your /etc/hosts:"
echo " 192.168.1.XXX $BRANCH_NAME.gravl.homelab.local $BRANCH_NAME.api.gravl.homelab.local"
echo ""
docker compose -f docker-compose.yml -f docker-compose.staging.yml up -d --build
echo "{\"branch\":\"$BRANCH_NAME\",\"url\":\"https://$BRANCH_NAME.gravl.homelab.local\"}" > .staging/$BRANCH_NAME.json
echo "✅ Staging: https://$BRANCH_NAME.gravl.homelab.local"