Fix/extend docker tar1090#14
Conversation
Fixes circular dependency causing 5-7s timeouts - proxy now reads from /run/readsb/aircraft.json file instead of HTTP fetch. Changes: - Extend ghcr.io/sdr-enthusiasts/docker-tar1090 instead of building from scratch - Add 08-inject-proxy-config to inject nginx proxy_pass at runtime (build-time sed doesn't persist because tar1090 regenerates nginx config) - Disable binCraft via nginx sub_filter so frontend uses JSON format - Remove redundant readsb service (docker-tar1090 has readsb built-in) - Remove shared volumes (single container, no inter-container sharing) - Use #!/command/with-contenv bash shebang to inherit environment vars - Fall back to adsb.lol when local data has 0 aircraft (not just on error)
Pull Request Review: Fix/extend docker tar1090OverviewThis PR makes significant architectural improvements by consolidating the container setup, fixing the circular dependency issue, and switching from lighttpd to nginx. ✅ Strengths
🔴 Critical Issues1. Race Condition in Process Management (docker/01-start-proxy:4)Starting Node.js with & in a cont-init script creates an orphaned background process not managed by s6-overlay. If proxy crashes it won't restart. Recommendation: Create proper s6 service at /etc/services.d/proxy/run with exec node /opt/proxy/server.js 2. Missing Error Handling in JSON Parsing (proxy/server.js:103)If file contains malformed JSON this will throw unhandled exception crashing the proxy. Recommendation: Wrap JSON.parse in try-catch block 3. Unsafe sed Command (docker/08-inject-proxy-config:8-9)If pattern not found sed silently succeeds but doesn't inject config. Verification only checks if proxy_pass exists anywhere in file. Recommendation: Validate injection anchor exists first and verify specific locations were added
|
|
Is my review blocking anything? I'll be afk for another ~1 week or so, if it's important I can find a way to take a look sooner though |
Pull Request Review: Fix/extend docker tar1090SummaryThis PR makes significant architectural improvements by addressing a circular dependency issue and consolidating the container setup. The changes are well-motivated and solve real problems with the previous implementation. Positive Aspects✅ Eliminates circular dependency - Reading from file instead of HTTP eliminates 5-7s timeouts Issues & Recommendations🔴 Critical: Proxy Service ManagementIssue: node /opt/proxy/server.js &Problem: If the Node.js process crashes, it won't restart. Using Recommendation: Use s6-overlay services properly:
#!/command/with-contenv bash
exec node /opt/proxy/server.js
This ensures s6 supervises the proxy and restarts it on failure. 🟡 Code Quality Issues1. Error Handling in
|
No rush! |
|
A couple of small questions but looks great overall! |
a152a03 to
688d77e
Compare
- Enable network_mode: host for Debian deployment - Return empty aircraft array (200) instead of error when no data sources available
688d77e to
d612d91
Compare
Pull Request Review: Fix/extend docker tar1090SummaryThis PR successfully addresses critical architectural issues with the tar1090 Docker container setup. The changes eliminate a circular dependency, consolidate containers, and implement proper nginx configuration injection. Overall, this is a well-executed refactor with clear improvements to the system architecture. StrengthsArchitecture Improvements
Code Quality
Issues and Recommendations1. Process Management Issue (High Priority)Location: docker/01-start-proxy:4 The proxy is started as a background process without proper process supervision. If it crashes, it will not restart. Recommendation: Use s6-overlay service management by creating /etc/services.d/proxy/run instead of starting with ampersand in cont-init.d. This ensures the proxy is properly supervised and will be restarted if it crashes. 2. Fragile sed Commands (Medium Priority)Location: docker/08-inject-proxy-config:8,13 Problems: The sed commands rely on finding an exact string that upstream could change. Complex quoting makes maintenance difficult. The verification only checks if proxy_pass exists anywhere in the file. Recommendations: Add validation that the anchor line exists before attempting injection. Improve verification to check for the specific location blocks. Consider creating a separate nginx config snippet for more stability. 3. Missing Error Recovery (Medium Priority)Location: proxy/server.js:92-95 When fetching from adsb.lol, if the write to LOCAL_DATA_PATH fails, it only logs a warning. However, this means tar1090 backend will not see the fallback data. Consider treating this as a more serious error. 4. Security: No Input Validation on Environment VariablesLocation: proxy/server.js:7-10 Latitude and longitude values are parsed without validation. Malformed env vars could cause NaN values in the API URL. Add coordinate validation with proper min/max bounds (-90 to 90 for lat, -180 to 180 for lon). 5. Missing HealthcheckLocation: docker-compose.yml The proxy implements a /health endpoint but there is no Docker healthcheck configured. Add a healthcheck directive to the compose file using curl or similar. 6. Port Configuration InconsistencyLocation: docker-compose.yml:31 The port is hardcoded as PROXY_PORT=3005 instead of using variable substitution like other variables. This prevents easy override. 7. Race Condition Risk (Low Priority)Location: docker/01-start-proxy:4 The proxy starts in cont-init.d but nginx configuration injection happens in startup.d. There is a timing window where nginx has not been reconfigured yet. Documenting this dependency would help future maintainers. 8. JSON Parsing Without Validation (Low Priority)Location: proxy/server.js:103 If the file contains valid JSON but in an unexpected format, it could cause issues downstream. Add basic schema validation to check that parsed data is an object. Test CoverageCritical Gap: No automated tests are present in the repository. Recommendations:
Security AssessmentOverall: Good Positive findings:
Minor concerns:
Performance ConsiderationsImprovements:
Potential Optimizations:
DocumentationGood: PR description is comprehensive and well-structured. Inline comments explain complex logic. Clear rationale for changes. Could be improved: Document the new environment variables (especially PROXY_PORT). Add troubleshooting guide for common issues. Consider adding migration notes for existing deployments. Recommendations PriorityMust Fix (Before Merge):
Should Fix (This PR or Next):
Nice to Have (Future PRs):
Final VerdictRecommendation: Approve with Changes This PR makes significant architectural improvements and solves real problems. The core changes are sound and well-implemented. The issues identified are mostly around robustness and edge cases rather than fundamental problems. Suggested path forward:
Great work on identifying and fixing the circular dependency issue! The file-based approach is elegant and much more reliable. |
Pull Request Review: Fix/extend docker tar1090OverviewThis PR successfully addresses significant architectural issues with the tar1090 container setup by eliminating the circular dependency, consolidating containers, and switching from file-based to direct reading. The changes are well-motivated and represent a meaningful improvement. StrengthsArchitecture Improvements
Code Quality
Issues and Concerns1. CRITICAL: Process Management Issue (proxy/server.js + docker/01-start-proxy)Severity: High The proxy is started with Recommendation: Use s6-overlay service management instead of backgrounding. Create /etc/services.d/proxy/run instead of using cont-init.d. This ensures s6-overlay monitors and restarts the proxy if it crashes. 2. Security: Unvalidated sed Injection (docker/08-inject-proxy-config)Severity: Medium Lines 8 and 13 use sed -i to inject nginx config, but there is no validation that the target pattern exists before injection. If the upstream docker-tar1090 changes the nginx config format, the sed command will silently fail or inject in the wrong location. Issues:
Recommendations: Add idempotency checks before injection, validate the target pattern exists, and consider running nginx -t to validate the config after injection. 3. Error Handling: Silent Failures (proxy/server.js)Severity: Medium Lines 91-95: Writing to LOCAL_DATA_PATH fails silently when fetching from adsb.lol. This means tar1090 backend will not get adsb.lol data if the write fails. Consider making this a hard error if it is critical for tar1090, or documenting why it is acceptable to fail silently. Lines 100-106: readLocalFile() returns null for all errors (missing file, permission denied, corrupt JSON, etc.). Consider logging errors for debugging, except for ENOENT which is expected. 4. Race Condition: Proxy Start Timing (docker/01-start-proxy)Severity: Low-Medium The proxy starts in cont-init.d (runs during container initialization) but is backgrounded with &. There is no guarantee it is ready when nginx starts trying to proxy to it. Impact: First few requests to /data/aircraft.json after container start might fail with 502 Bad Gateway. Recommendation: Use s6-overlay service dependencies to ensure proper startup order, or add a readiness check in the nginx config with retry. 5. Type Safety: Unsafe parseInt (proxy/server.js:9-10)Severity: Low If ADSBLOL_RADIUS is set to a non-numeric string, parseInt() returns NaN, which will break the API URL. Recommendation: Use parseInt with radix 10 and add fallback for NaN cases 6. Performance: No Caching (proxy/server.js)Severity: Low Every request to /data/aircraft.json reads from disk. For high-traffic scenarios, consider caching with a short TTL (1-2 seconds) to reduce disk I/O. 7. Docker Best Practices (Dockerfile:4)Severity: Low Installing npm pulls in many dependencies that are not needed at runtime (only nodejs is used). Consider installing Node.js without npm if no build step is needed, or using a multi-stage build. Test CoverageStatus: No tests found Recommendation: Add basic tests for:
Security Considerations
DocumentationStrengths:
Missing:
Recommendations Before MergeMust Fix:
Should Fix:
Nice to Have:
Final VerdictRecommendation: Approve with changes This PR represents a significant architectural improvement that addresses real production issues. The core changes are well-designed and properly motivated. However, the process management issue should be addressed before merge to ensure reliability in production. The sed injection concerns are less critical but should be addressed to prevent future breakage when docker-tar1090 updates. Great work on identifying and fixing the circular dependency issue! |
Pull Request Review: Fix/extend docker tar1090I've completed a thorough review of this PR. Overall, this is a well-architected solution that addresses significant architectural issues in the previous implementation. The changes are logical and well-documented. ✅ StrengthsArchitecture & Design
Code Quality
|
| Category | Rating | Notes |
|---|---|---|
| Architecture | ⭐⭐⭐⭐⭐ | Excellent solution to circular dependency |
| Code Quality | ⭐⭐⭐⭐ | Clean, well-documented code |
| Security | ⭐⭐⭐⭐ | No major concerns, minor hardening possible |
| Testing | ⭐ | Critical gap - no tests |
| Performance | ⭐⭐⭐⭐ | Significant improvement over previous version |
| Documentation | ⭐⭐⭐⭐ | Good PR docs, could use more architecture docs |
Verdict: Approve with Recommendations
This PR solves real problems and is well-executed. The critical issues (process management, race conditions) should be addressed, but they don't block merging since they're improvements over the previous implementation. The lack of tests is the biggest concern for long-term maintainability.
Priority Actions:
- High: Convert proxy to s6 service (process supervision)
- Medium: Add basic smoke tests
- Medium: Remove unused npm from Dockerfile
- Low: Improve error logging in readLocalFile()
- Low: Add HEALTHCHECK to Dockerfile
Great work on this refactor! 🚀
- Replace background process (&) with proper s6 service at /etc/services.d/proxy - Enables automatic restarts, logging integration, and graceful shutdown
Pull Request Review: Fix/extend docker tar1090SummaryThis PR makes significant architectural improvements to fix circular dependencies and simplify the container setup. The changes are well-motivated and address real issues. Overall, this is a solid refactor with good technical decisions. ✅ StrengthsArchitecture & Design
Code Quality
|
Great, thank you for looking over! |
jonnyspicer
left a comment
There was a problem hiding this comment.
Looks great, ship iiiiiiiittttt 😁
This PR patches a few issues with the tar1090 node container, mainly addressing the incorrectly configured lighttpd proxy in a container that actually runs nginx.
Key Changes
/run/readsb/aircraft.json) instead of HTTP, eliminating 5-7s timeoutsWhy These Changes
The previous setup had a few issues worth addressing:
Dockerfile.tar1090copied lighttpd config into an nginx-based container (which was ignored)http://127.0.0.1:80/data/aircraft.json, creating a circular dependency and 5-7s timeoutsdocker-readsb-protobufhas been archived (April 2025)Files Changed
Dockerfile- extend docker-tar1090, add Node.js proxydocker/01-start-proxy- s6-overlay cont-init scriptdocker/08-inject-proxy-config- runtime nginx config injectionproxy/server.js- file-based reading instead of HTTP fetchdocker-compose.yml- simplified single container setup.github/workflows/docker_build.yml- use correct DockerfileDeleted (no longer needed)
Dockerfile.tar1090- replaced byDockerfiledocker/lighttpd-*.conf- we use nginx nowdocker/entrypoint.sh- replaced by s6-overlay scriptsTesting
Tested locally with adsb.lol. Would be good to test with an actual ADSB receiver (dev software stack containing these changes is retina-node v0.3.0-rc2, can be deployed via mender.
Discussion: Next Steps
This patch injects the nginx proxy and readsb config into the pre-built docker-tar1090 image. Going forward we could:
Option 1: Keep extending docker-tar1090 (current approach)
Pros: Easy updates from upstream, minimal maintenance
Cons: Have to inject our changes at runtime
Option 2: Fork docker-tar1090 from SDR Enthusiasts
Pros: Clean repo with only our files, can bake in proxy permanently
Cons: Maintenance burden, need to track upstream updates
Files that could be deleted (if staying with extend approach)
These are upstream tar1090 files we don't use since we're now using the pre-built sdr-enthusiasts image:
88-tar1090.conf,nginx.conf,nginx-readsb-api.conf(lighttpd/nginx configs)install.sh,uninstall.sh,tar1090.sh,tar1090.service(bare-metal install)cachebust.sh,cachebust.list,concat-example.sh,tag.sh(build scripts)toCSV.py,getupintheair.sh,version(utilities)html/directory (docker-tar1090 has these)