fix: use docker run to write Traefik config from host volume
All checks were successful
Deploy / deploy (push) Successful in 4m39s
All checks were successful
Deploy / deploy (push) Successful in 4m39s
This commit is contained in:
42
.github/workflows/deploy.yml
vendored
42
.github/workflows/deploy.yml
vendored
@@ -39,38 +39,18 @@ jobs:
|
||||
docker compose -f docker-compose.production.yml up -d
|
||||
|
||||
- name: Register Traefik route
|
||||
env:
|
||||
TRAEFIK_RULE: "Host(`api-ubigeo.darkcodex.dev`)"
|
||||
run: |
|
||||
TRAEFIK_DIR=/etc/easypanel/traefik/config
|
||||
ROUTE_FILE=$TRAEFIK_DIR/api-ubigeo.yaml
|
||||
|
||||
# Check if we can write there
|
||||
if [ ! -w "$TRAEFIK_DIR" ]; then
|
||||
echo "Cannot write to $TRAEFIK_DIR — skipping Traefik config"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Only add if not already present
|
||||
if [ ! -f "$ROUTE_FILE" ]; then
|
||||
cat > "$ROUTE_FILE" << 'EOF'
|
||||
http:
|
||||
routers:
|
||||
ubigeo-api:
|
||||
rule: "Host(`api-ubigeo.darkcodex.dev`)"
|
||||
service: ubigeo-api
|
||||
entryPoints:
|
||||
- websecure
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
services:
|
||||
ubigeo-api:
|
||||
loadBalancer:
|
||||
servers:
|
||||
- url: "http://ubigeo-api:3200"
|
||||
EOF
|
||||
echo "Traefik route created at $ROUTE_FILE"
|
||||
else
|
||||
echo "Traefik route already exists"
|
||||
fi
|
||||
docker run --rm \
|
||||
-e TRAEFIK_RULE \
|
||||
-v /etc/easypanel/traefik/config:/traefik-config \
|
||||
alpine sh -c '
|
||||
OUT=/traefik-config/api-ubigeo.yaml
|
||||
[ -f "$OUT" ] && echo "route already exists" && exit 0
|
||||
printf "http:\n routers:\n ubigeo-api:\n rule: \"%s\"\n service: ubigeo-api\n entryPoints:\n - websecure\n tls:\n certResolver: letsencrypt\n services:\n ubigeo-api:\n loadBalancer:\n servers:\n - url: \"http://ubigeo-api:3200\"\n" "$TRAEFIK_RULE" > "$OUT"
|
||||
echo "Traefik route created"
|
||||
'
|
||||
|
||||
- name: Health check
|
||||
run: |
|
||||
|
||||
Reference in New Issue
Block a user