-
-
Notifications
You must be signed in to change notification settings - Fork 103
[fix] Made OpenVPN container optional #490 #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ x-celery-depends-on: &celery-depends-on | |
| dashboard: | ||
| condition: service_started | ||
| openvpn: | ||
| required: false | ||
| condition: service_healthy | ||
|
|
||
| services: | ||
|
|
@@ -81,7 +82,7 @@ services: | |
| env_file: | ||
| - .env | ||
| <<: *celery-depends-on | ||
| network_mode: "service:openvpn" | ||
| network_mode: "${CELERY_SERVICE_NETWORK_MODE}" | ||
|
|
||
| celery_monitoring: | ||
| image: openwisp/openwisp-dashboard:latest | ||
|
|
@@ -95,7 +96,7 @@ services: | |
| env_file: | ||
| - .env | ||
| <<: *celery-depends-on | ||
| network_mode: "service:openvpn" | ||
| network_mode: "${CELERY_SERVICE_NETWORK_MODE}" | ||
|
|
||
| celerybeat: | ||
| image: openwisp/openwisp-dashboard:latest | ||
|
|
@@ -167,7 +168,7 @@ services: | |
|
|
||
| openvpn: | ||
| image: openwisp/openwisp-openvpn:latest | ||
| restart: always | ||
| restart: on-failure | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Restart policy change doesn't prevent container from starting. Changing the restart policy from Consider using Docker Compose profiles to conditionally include/exclude the openvpn service entirely when VPN is disabled: 🔎 Proposed approach using profilesIn docker-compose.yml: openvpn:
image: openwisp/openwisp-openvpn:latest
- restart: on-failure
+ restart: always
+ profiles:
+ - vpnThen conditionally enable the profile in the startup command based on whether VPN is enabled.
🤖 Prompt for AI Agents |
||
| build: | ||
| context: images | ||
| dockerfile: openwisp_openvpn/Dockerfile | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 88
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 92
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 99
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 1055
🏁 Script executed:
grep -n "CELERY_SERVICE_NETWORK_MODE" ./deploy/auto-install.sh -A 2 -B 2Repository: openwisp/docker-openwisp
Length of output: 245
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 288
🏁 Script executed:
Repository: openwisp/docker-openwisp
Length of output: 1091
🌐 Web query:
Docker Compose empty environment variable network_mode behavior💡 Result:
Short answer: Docker Compose variable interpolation replaces an unset variable with an empty string. For options like network_mode that are set in an earlier file, an empty-string substitution does NOT clear the key — Compose/YAML either treats the empty value as no effective override (so the previous value remains) or the empty value is invalid. In practice this means using ${VAR} where VAR is unset will not reliably "unset" network_mode. See Docker docs on variable interpolation and discussion/workarounds on Stack Overflow/GitHub. [1][2]
Practical options:
Sources:
🌐 Web query:
Docker Compose network_mode empty string value validation💡 Result:
Short answer: Docker Compose requires network_mode to be a string (one of the allowed values like "bridge", "host", "none", "service:NAME", "container:ID"). An empty string is not treated as a valid string by the YAML/Compose parser (empty scalar → null), so Compose will reject it. Use either remove/omit network_mode (so Compose uses the default network), set networks: [default], or set a valid network_mode value (for no networking use "none"). [1][2]
Sources:
Fix invalid network_mode configuration when VPN is disabled.
When VPN is disabled,
CELERY_SERVICE_NETWORK_MODEis set to an empty string at lines 85 and 99 in docker-compose.yml, resulting innetwork_mode: "". Docker Compose treats empty YAML scalars as null and rejects empty string values for network_mode, which will cause container startup failures.Use Docker Compose conditional syntax to omit the network_mode key entirely when VPN is disabled, or explicitly set it to a valid value like
"bridge".🤖 Prompt for AI Agents