Docker image as non-root user #243
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR will closes #213, #234, #225 (probably, waiting for user feedback on it)
Port 80 Preserved: Using
setcapon Apache to allow binding to port 80 without root privileges, avoiding breaking changes for existing deployments as explained in the next section (I'll be inclined to do a dedicated PR with that breaking change).Process Management:
- Implemented Supervisord to manage services (handling auto restart of them, inspired on Symfony Messenger).
- Replaced system
cronwith a lightweight PHP worker (cron-worker.sh) managed by Supervisord.PHP Configuration: Enabled native PHP session garbage collection (
session.gc_probability = 1) in glpi.ini since the system cron is no longer available.Updated startup scripts to check for writable permissions on volume directories instead of attempting to
chownthem.Switching from port 80 to port 8080 (AI beautified)
This is open to debate and should probably be done in a separate PR.
Current Implementation: Port 80 with
setcapHow:
We use the Linux capability
CAP_NET_BIND_SERVICEto allow the non-root user (www-data) to bind to a privileged port (ports < 1024).RUN setcap cap_net_bind_service=+ep /usr/sbin/apache2Pros:
docker-compose.ymlordocker run -p 80:80continue to work without modification.Cons:
libcap2-bin.Alternative Considered: Port 8080 (High Ports)
Proposal: Change standard Apache listener to Port 8080.
How:
Configure Apache to Listen on 8080 instead of 80.
Pros:
setcap) required. The process is completely unprivileged standard application.libcap2-bin.Cons:
docker-compose.yml: