Existing issue
- I have searched the existing issues and found no duplicate.
Problem or use case
Some applications call system tools at runtime, not only at build time. A Laravel application, for example, may need:
- the PostgreSQL client:
pg_dumpfor scheduled database backups (spatie/laravel-backup calls it fromphp artisan backup:run), andpsqlto restore them, - ImageMagick for image handling,
- a Node-based CLI for document text extraction.
The generated recipes give no way to add them to the deployed image. This issue uses the PHP recipe as the example. References are at 8cddb2675.
- The runtime stage installs PHP extensions only (
packages/adapters/src/runtime/docker-recipes/php.ts:135). installCommandruns in the builder stage, andbuildCommandruns in the Node asset stage. The runtime stage copies only the application directory and the built document root (php.ts:142,php.ts:146). System packages installed in the builder or asset stage never reach the running containers.- The containers run as
www-data(php.ts:168), so a start command cannot install them either. - Runtime roles and release commands use the same image, so workers and migrations have no route to these tools.
Inside the generated recipe, the only route today is a custom runtimeImage. It must provide FrankenPHP, install-php-extensions and www-data (php.ts:131), and its PHP must match the selected version. In practice, each application then needs a private base image to maintain and rebuild. That loses most of the benefit of the generated recipe.
Proposed solution
Add an optional runtime install step to generated builds. It runs as root in the runtime stage, after the extension install (php.ts:135) and before the application copy. That placement keeps the layer cached across commits. The deployment snapshot stores the setting like the other build settings. Web, role and release containers then all get the tools, because they share the image.
Two possible shapes:
- A package list, installed with
apt-getlike the Ruby recipe's fixed runtime packages (docker-recipes/ruby.ts:27-41). This is easy to validate. - A command string, for example
runtimeInstallCommand. This also covers packages that need a third-party repository.
The list may not be enough on its own. The bookworm base ships PostgreSQL client 15. pg_dump refuses to dump a server newer than its own major version. A PostgreSQL 18 database therefore needs a newer client, for example from the PGDG repository.
Should the step see project environment values? Keeping it free of the build secret mount seems safer, since it only installs packages.
Could the same setting serve the other generated recipes too?
Alternatives considered
- A custom
runtimeImage: works, but adds a private base image to build, patch and keep at the same PHP version. - The application's own Dockerfile: works, but gives up the generated recipe, its platform checks and its asset stage.
- Openship's database backups: they back up a database service. They do not give the application its own PostgreSQL client, ImageMagick or document CLI.
- A separate service container for each tool: needs application changes, and does not fit tools that read local files such as
storage/.
Additional context
My case is a Laravel 13 application on PostgreSQL 18. Its scheduler and queue workers need the PostgreSQL 18 client tools, ImageMagick and the @llamaindex/liteparse CLI (Node 18 or newer).
Activity
0No activity yet.