fix(install): skip d3v-net in compose when Forgejo is not installed

generate_docker_compose now only adds the d3v-net network section if the
network actually exists on the host. Servers without Forgejo no longer
fail with "network declared as external, but could not be found".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
xtcnet 2026-03-17 22:31:13 +07:00
parent 04a22dcc7d
commit 2e9ed07708

View file

@ -155,6 +155,18 @@ generate_docker_compose() {
done < ".custom_ports" done < ".custom_ports"
fi fi
# Only include d3v-net if the network already exists (i.e. Forgejo is installed)
local network_block=""
if docker network ls --format '{{.Name}}' 2>/dev/null | grep -q "^${DOCKER_NETWORK}$"; then
network_block=" networks:
- d3v-net
networks:
d3v-net:
external: true
name: ${DOCKER_NETWORK}"
fi
cat > "$COMPOSE_FILE" <<YAML cat > "$COMPOSE_FILE" <<YAML
services: services:
d3v-npmwg: d3v-npmwg:
@ -178,13 +190,7 @@ $(echo -e "$custom_ports_block" | sed '/^$/d') volumes:
- ./wireguard:/etc/wireguard - ./wireguard:/etc/wireguard
environment: environment:
WG_HOST: "${host}" WG_HOST: "${host}"
networks: ${network_block}
- d3v-net
networks:
d3v-net:
external: true
name: ${DOCKER_NETWORK}
YAML YAML
log_ok "docker-compose.yml created/updated." log_ok "docker-compose.yml created/updated."
} }