-
-
Notifications
You must be signed in to change notification settings - Fork 365
Fix: Fix for ports #1286
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
Fix: Fix for ports #1286
Conversation
WalkthroughRefactors nginx configuration management by replacing Changes
Sequence Diagram(s)sequenceDiagram
participant OldFlow as Old Flow
participant NewFlow as New Flow
rect rgb(240, 248, 255)
Note over OldFlow: Devcontainer Flow
OldFlow->>OldFlow: setup.sh creates conf.active symlink<br/>to active-config
OldFlow->>OldFlow: generate-configs.sh processes<br/>SYSTEM_NGINX_CONFIG_FILE template
OldFlow->>OldFlow: deploy static nginx.conf
end
rect rgb(240, 250, 240)
Note over NewFlow: New Flow
NewFlow->>NewFlow: setup.sh skips symlink creation<br/>manages temp dirs directly
NewFlow->>NewFlow: generate-configs.sh skipped<br/>(devcontainer)
NewFlow->>NewFlow: start-nginx.sh generates config<br/>to SYSTEM_SERVICES_ACTIVE_CONFIG_FILE
end
rect rgb(255, 250, 240)
Note over NewFlow: Production Flow
NewFlow->>NewFlow: SYSTEM_NGINX_CONFIG_TEMPLATE<br/>sourced for envsubst
NewFlow->>NewFlow: Output → SYSTEM_SERVICES_ACTIVE_CONFIG_FILE<br/>(/tmp/nginx/active-config/nginx.conf)
NewFlow->>NewFlow: nginx -c parameter uses<br/>active-config path
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.devcontainer/Dockerfile(2 hunks).devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template(0 hunks).devcontainer/scripts/generate-configs.sh(0 hunks).devcontainer/scripts/setup.sh(1 hunks)Dockerfile(1 hunks)install/production-filesystem/build/init-php-fpm.sh(0 hunks)install/production-filesystem/services/config/nginx/conf.active(0 hunks)install/production-filesystem/services/start-nginx.sh(2 hunks)test/docker_tests/test_docker_compose_scenarios.py(7 hunks)
💤 Files with no reviewable changes (4)
- .devcontainer/scripts/generate-configs.sh
- install/production-filesystem/build/init-php-fpm.sh
- install/production-filesystem/services/config/nginx/conf.active
- .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template:1-2
Timestamp: 2025-10-19T01:40:57.095Z
Learning: In the NetAlertX repository, .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template is an auto-generated file that is intentionally committed to source control. It cannot be regenerated automatically outside the devcontainer environment and is required for the devcontainer to start, creating a bootstrap dependency.
📚 Learning: 2025-10-19T01:40:57.095Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1230
File: .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template:1-2
Timestamp: 2025-10-19T01:40:57.095Z
Learning: In the NetAlertX repository, .devcontainer/resources/devcontainer-overlay/services/config/nginx/netalertx.conf.template is an auto-generated file that is intentionally committed to source control. It cannot be regenerated automatically outside the devcontainer environment and is required for the devcontainer to start, creating a bootstrap dependency.
Applied to files:
install/production-filesystem/services/start-nginx.shDockerfile.devcontainer/Dockerfile.devcontainer/scripts/setup.sh
📚 Learning: 2025-09-20T14:09:29.159Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:103-116
Timestamp: 2025-09-20T14:09:29.159Z
Learning: In NetAlertX devcontainer setup, the netalertx user has write permissions to /var/log/nginx/ directory as it's explicitly chowned to netalertx:www-data in the Dockerfile, so setup.sh can write to nginx log files without sudo.
Applied to files:
install/production-filesystem/services/start-nginx.shDockerfile.devcontainer/Dockerfile.devcontainer/scripts/setup.sh
📚 Learning: 2025-09-20T03:01:19.912Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/Dockerfile:18-19
Timestamp: 2025-09-20T03:01:19.912Z
Learning: In the NetAlertX repository, .devcontainer/Dockerfile is auto-generated and should not be reviewed directly. Review comments about dependencies and build steps should be directed at the root Dockerfile where the actual source commands are located.
Applied to files:
Dockerfile.devcontainer/Dockerfile
📚 Learning: 2025-09-20T02:56:24.501Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/devcontainer.json:5-8
Timestamp: 2025-09-20T02:56:24.501Z
Learning: In the NetAlertX devcontainer setup, the final .devcontainer/Dockerfile is generated by combining the root Dockerfile with .devcontainer/resources/devcontainer-Dockerfile using the generate-dockerfile.sh script. The devcontainer.json should reference the generated file, not the root Dockerfile.
Applied to files:
Dockerfile.devcontainer/Dockerfile
📚 Learning: 2025-09-20T14:08:48.256Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1184
File: .devcontainer/scripts/setup.sh:90-96
Timestamp: 2025-09-20T14:08:48.256Z
Learning: In the NetAlertX devcontainer setup, the setup.sh script intentionally removes user_notifications.json from the API directory during development environment initialization to prevent notification clutter that accumulates during container launches and development work.
Applied to files:
.devcontainer/Dockerfile
📚 Learning: 2025-10-26T17:09:18.621Z
Learnt from: adamoutler
Repo: jokob-sk/NetAlertX PR: 1235
File: .devcontainer/scripts/setup.sh:146-148
Timestamp: 2025-10-26T17:09:18.621Z
Learning: In `.devcontainer/scripts/setup.sh` and other devcontainer setup scripts for NetAlertX, chmod 666 on /var/run/docker.sock is acceptable because devcontainer environments are single-user development contexts where convenience can take priority over strict permission hardening.
Applied to files:
.devcontainer/scripts/setup.sh
🪛 Ruff (0.14.4)
test/docker_tests/test_docker_compose_scenarios.py
57-57: subprocess call: check for execution of untrusted input
(S603)
270-270: Avoid specifying long messages outside the exception class
(TRY003)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: docker_dev
Fixes the ability to customize HTTP and GraphQL ports in both devcontainer and production environments. Previously, port configuration via environment variables was broken due to static nginx config symlinks. Now ports are dynamically rendered at runtime.
Dockerfile & start-nginx.sh)
SYSTEM_NGINX_CONFIG_FILE→SYSTEM_NGINX_CONFIG_TEMPLATEfor claritySYSTEM_SERVICES_ACTIVE_CONFIG_FILEenv var pointing to runtime config locationenvsubst, substituting${LISTEN_ADDR}and${PORT}into the templateDevcontainer Setup
conf.activesymlinkUnit Tests
Added comprehensive port availability & readiness infrastructure:
_port_is_free()— checks if TCP port is available_wait_for_ports()— polls until ports accept connections_discover_host_addresses()— handles multiple IP candidates (127.0.0.1, gateway, env-configured)_select_custom_ports()— dynamically picks free ephemeral ports_make_port_check_hook()— post-up callback to verify ports are listeningEnhanced
test_normal_startup_no_warnings_compose()to validate both:PORTandGRAPHQL_PORTenv vars)Testing
Breaking Changes
None. Existing configurations continue to work unchanged.
Summary by CodeRabbit
Infrastructure
Chores