Skip to content

POC: rootless php#58

Draft
USA-RedDragon wants to merge 4 commits intomainfrom
rootless
Draft

POC: rootless php#58
USA-RedDragon wants to merge 4 commits intomainfrom
rootless

Conversation

@USA-RedDragon
Copy link
Copy Markdown

@USA-RedDragon USA-RedDragon commented Oct 3, 2025

POC for rootless PHP containers

The containers run as nobody:nogroup.
nginx and php-fpm are removed in favor of Laravel Octane and RoadRunner.

The existing images are adjusted in some minor ways:

  • A s6-svscan-rootless utility is added that uses /tmp to provide a place for the .s6-svscan file to live. Other than the worker for some apps needing to run both cron and php /app/artisan queue:work, we don't have a strong dependency on s6 for this image anymore.
  • The RoadRunner config will live in the app repo at .rr.yaml, eliminating the need for Laravel-specific code in this repo and simplifying config from envs to a yaml file in the project.
  • The base image is changed from php:*-fpm-alpine to php:*-cli-alpine because php-fpm is no longer needed.
  • The health check is rewritten to use RoadRunner's status endpoint (/health?plugin=http) via wget instead of the old cgi-fcgi ping to php-fpm. This does require the RoadRunner config to have
status:
  address: "127.0.0.1:${RR_STATUS_PORT:-2114}"
  • gettext is dropped as we no longer have to do configuration templating
  • INSTALL_SOCKETS=true is added as a default build arg since it's required by spiral/roadrunner-cli / spiral/roadrunner-http.
  • The onbuild stage uses a USER root / USER nobody:nogroup sandwich so that clevyr-build can install extensions as root, then drops back to nobody.

I have a draft PR 1291 in another repo that I won't link due to the name of it being a privacy concern that shows how this might look on the application side

@USA-RedDragon USA-RedDragon force-pushed the rootless branch 4 times, most recently from f422269 to efb140b Compare October 3, 2025 21:44
@USA-RedDragon USA-RedDragon marked this pull request as ready for review October 3, 2025 21:49
@USA-RedDragon USA-RedDragon requested a review from gabe565 October 3, 2025 21:50
@USA-RedDragon USA-RedDragon force-pushed the rootless branch 3 times, most recently from 2f8aa68 to 1452f9e Compare October 3, 2025 22:46
@USA-RedDragon USA-RedDragon marked this pull request as draft October 3, 2025 23:08
@gabe565
Copy link
Copy Markdown
Member

gabe565 commented Apr 15, 2026

@USA-RedDragon This is a good idea. Should nginx tmp files be moved to /tmp similarly to https://hub.docker.com/r/nginxinc/nginx-unprivileged?

Comment thread rootfs/usr/bin/clevyr-php-pre-stop Outdated
Copy link
Copy Markdown
Author

@USA-RedDragon USA-RedDragon Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we no longer need this as RoadRunner should gracefully handle SIGTERM for shutdown: https://docs.roadrunner.dev/docs/app-server/cli#stopping-the-server.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit dumb, there might be a better way

Comment thread rootfs/health-check
cgi-fcgi -bind -connect \
"${HEALTH_CHECK_IP:-127.0.0.1}:${HEALTH_CHECK_PORT:-9000}" \
| grep -e pong >/dev/null
wget -qO /dev/null "http://${HEALTH_CHECK_HOST}:${HEALTH_CHECK_PORT}/health?plugin=http"
Copy link
Copy Markdown
Author

@USA-RedDragon USA-RedDragon Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app's .rr.yaml needs

status:
  address: "127.0.0.1:${RR_STATUS_PORT:-2114}"

Comment thread Dockerfile
ONBUILD ARG INSTALL_IMAGICK
ONBUILD ARG INSTALL_MOSQUITTO
ONBUILD ARG INSTALL_MYSQL
ONBUILD ARG INSTALL_SOCKETS=true
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

laravel/octane needs spiral/roadrunner-cli and spiral/roadrunner-http which one or both depend on ext-sockets

@USA-RedDragon USA-RedDragon changed the title rootless php POC: rootless php Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants