Dockerfile recipes for Magento 2, Next.js, GraphCommerce and Laravel projects
on Deployyy. The hosted build of Deployyy
(deployyy-operator internal/build)
builds each project with the recipe of its release line. A team that builds
in its own CI follows deployyy-operator
docs/MANUAL-BUILDS.md.
Your repository holds no Deployyy configuration file. Project settings live in the Deployyy console.
- Release line: read from
composer.json. - Service stack: database, search, queue and cache are project settings.
- PHP version: the release line's default unless you choose another
supported version in the console. Defaults: 2.4.6 uses 8.2, 2.4.7 uses 8.3,
2.4.8, 2.4.9 and Mage-OS 3 use 8.4.
- The environment keeps its current release until the build of the new version exists.
- PHP 8.5 builds on 2.4.9 and Mage-OS 3. The console offers 8.5 after its live trial.
- A repository
Dockerfilereceives the version as build argumentPHP_VERSION.
- Static-content locales: the build locales of the project. Default:
en_US. - Build variables: the platform team keeps them in
build-secrets-<repository>. Every value is in the BuildKit secretbuild-env. A repositoryDockerfilereads it withRUN --mount=type=secret,id=build-env.
These values reach the build only. The running application reads its variables from Deployyy: Environment variables in the console.
To change a setting the console does not offer, contact Deployyy support.
The application can live in a folder, such as src or apps/web. The
project's root directory names that folder.
- If the repository root holds no application, connecting the repository sets the root directory to the subfolder that holds one.
- The build reads
composer.json,composer.lock,package.json,.nvmrc,.node-version,Dockerfile,.platform/, the patch folders and the Varnish VCL files from that folder. - The folder is the Docker build context. Files outside it do not reach the image.
- In this README, "the root of your repository" means the application folder.
The folder must be a relative path inside the repository. It cannot start
with /, contain . or .., or be a symbolic link. It must exist in the
commit being built. Otherwise the build fails with the broken rule. An empty
value means the repository root.
One repository can hold several applications, each in its own folder. An
example: Magento in magento and its GraphCommerce storefront in
storefront. Each application is a separate Deployyy project with its own
folder, and builds and deploys on its own.
- A push builds only changed applications. If a push changes nothing in a folder, the new commit's tags point at the previous release. The folder is the whole build context, so the image is identical.
- Files at the repository root, such as a lockfile or
.github, are outside every folder and trigger no build. An application that needs them must use the repository root as its folder. - A storefront pairs with the Magento application of the same repository, per branch.
The page cache uses the Deployyy VCL. To change it, commit one of these files to the root of your repository:
varnish-snippet.vclis added to the Deployyy VCL. Asub vcl_recv { … }in it runs first, then continues into the Deployyyvcl_recv.varnish.vclreplaces the Deployyy VCL. Use backend hostmagento-web, port8080. The purge ACL must allow10.0.0.0/8,172.16.0.0/12and192.168.0.0/16.
The recipes copy the file into the image. An environment compiles the VCL from the release it runs, with the same Varnish version. A VCL that fails to compile is not used. The previous VCL keeps serving, and the console shows the compile error.
The recipes add no Varnish or GraphQL module to your project. A caching
module, if you need one, goes in your composer.json.
-
Put a file in
.platform/nginx/of your application, for example.platform/nginx/resize.conffor a PHP script next toindex.php:location = /r.php { fastcgi_pass fastcgi_backend; fastcgi_param SCRIPT_FILENAME $document_root/r.php; fastcgi_param HTTPS $fastcgi_https; include fastcgi_params; include /etc/nginx/deployyy/fastcgi*.conf; }
-
Push. The build adds each
.platform/nginx/*.confat the top of theserverblock of the recipe and runsnginx -t. A file that fails the test fails the build.
A regular expression location in your file comes before the locations of the recipe, so nginx matches it first.
-
Release line. The build reads the release line from
composer.json. For example,mage-os/product-community-edition: 3.*maps tomageos-3. The match is on the Mage-OS major version. -
Recipe. The build uses the recipe for that line from
recipes/: a Dockerfile plus.platform/support files. Recipe updates apply to your project on its next build. -
Your own files. A
Dockerfilein your repository replaces the recipe Dockerfile. A file in your.platform/directory replaces only the recipe file with the same name. -
Patches. Put vaimo/composer-patches files in a patch folder:
patches/, or each folder thatextra.patches-searchofcomposer.jsonnames. Declare each one inextra.patchesofcomposer.json:"extra": { "patches": { "mage-os/magento2-base": { "What the patch fixes": "patches/the-fix.patch" } } }
The recipe copies the patch folders, the
extra.patches-filefiles and the localextra.patchessources into the build beforecomposer install, so the plugin applies them. After the install,.platform/check-patches.phpfails the build for every*.patchfile in a patch folder that is not in the installed code.The
extra.patches-searchfolder scan skips a patch whose header names no installed package. It also skips every patch for a branch install such asdev-main, unless the header has@version *.check-patches.phpthen fails the build for those patches. Declare such a patch inextra.patches.Add
@skipto the header of a patch file that must not be applied.
The build builds each container target of the recipe and pushes one image per
role to <image source>/<role>:<sha7>-<key8>. <key8> is the build key of the
build inputs.
| Recipe | Role app |
Other roles |
|---|---|---|
magento, laravel |
target php-fpm, label app.deployyy.php |
nginx: target nginx |
nextjs |
target runtime |
cache-seed: target cache-seed, optional |
When your project installs
graphcommerce/magento-fast-boot,
the recipes switch it on:
- The web container runs
bin/magento fastboot:preparebefore PHP-FPM starts. If it fails, FastBoot fills its caches on the first requests. - PHP-FPM preloads the classes listed in
preload-classes.txtat the root of your repository. Without that file, nothing is preloaded. A dev box never preloads, because its code changes.
To make the list, copy var/cache/preload/classes.txt from a running web
container after it has served real traffic, and commit it as
preload-classes.txt. Refresh it when the classes your shop uses change.
| Line | Directory | PHP | Status |
|---|---|---|---|
mageos-3 |
recipes/magento/ |
8.4, 8.5 not validated | Validated live on 3.2.0 and 3.4.0 with PHP 8.4 |
mageos-4, Magento core 2.4.9 |
recipes/magento/ |
8.4, 8.5 not validated | Not validated live. |
magento-2.4.9 |
recipes/magento/ |
8.4, 8.5 not validated | Image builds and starts. Not validated live. |
magento-2.4.8 |
recipes/magento/ |
8.4 | Image builds and starts. Not validated live. |
magento-2.4.7 |
recipes/magento/ |
8.3 | Image builds and starts. Not validated live. |
magento-2.4.6 |
recipes/magento/ |
8.2 | Image builds and starts. Not validated live. |
| Next.js, GraphCommerce | recipes/nextjs/ |
Node 20, 22, 24 | Validated locally on Next 14, 15 and 16. Not validated live. |
| Laravel | recipes/laravel/ |
8.2 to 8.4 | See Laravel. |
The Magento Open Source and Mage-OS lines share one recipe. The recipe handles these known problems:
- Cache types come from the installed modules, every
etc/cache.xml, not from the Magento version. Magento disables a cache type that is missing fromenv.php, without a warning. queue_poison_pillhas no primary key in core. MySQL Group Replication refuses writes to such a table, andsetup:upgradewrites to it. MariaDB and single-node MySQL accept the table. Build argumentPLATFORM_QUEUE_POISON_PILL_PK=1adds the moduleDeployyy_QueuePoisonPillPk, unless a module in your project declares the key. The nextsetup:upgradethen adds the key. The hosted build does not set this argument.- Patches:
patches/is in the build beforecomposer install. A patch file that is not in the installed code fails the build, see step 4 above. - Minification: the build records whether it deployed minified JS and CSS
in
app/etc/static_build.php.env.phpsets runtime minification to match, so database settings cannot request files missing from the image.
Services. env.php reads each service by its generic name. A service's
variables start with its name. The default services are db, search,
session, cache, queue and media. The recipe reads:
DB_HOST,DB_PORT,DB_NAME,DB_USER,DB_PASSWORDSEARCH_HOST,SEARCH_PORTSESSION_HOST,SESSION_PORTCACHE_HOST,CACHE_PORTQUEUE_HOST,QUEUE_PORT,QUEUE_USER,QUEUE_PASSWORD,QUEUE_VHOSTMEDIA_BUCKET,MEDIA_ENDPOINT,MEDIA_REGION,MEDIA_ACCESS_KEY_ID,MEDIA_SECRET_ACCESS_KEY
The queue and the media bucket are optional. Without QUEUE_HOST, Magento
uses its MySQL queue. Without MEDIA_BUCKET, Magento keeps files on local
storage.
env.php is the platform's. A repository cannot bring its own. The build
installs the recipe's env.php at .platform/env.php, replacing a committed
one with a warning to delete it. A repository with its own Dockerfile must copy
.platform/env.php to /var/www/html/app/etc/env.php; the build fails when the
image's env.php differs. Set shop configuration
that differs per environment as a CONFIG__… variable instead, for example
CONFIG__DEFAULT__SMTP__CONFIGURATION_OPTION__HOST: Magento reads these like an
env.php setting and locks the field in the admin. A changed variable needs no
app:config:import. Configuration that is the same everywhere belongs in
app/etc/config.php.
The platform sets these paths as CONFIG__… variables, and its value replaces
a project variable of the same path: the base URLs of every scope,
web/url/redirect_to_base, the admin URL, the search host and port, the page
cache (system/full_page_cache/caching_application) and, below production, the
cookie domain and the static and media base URLs. A store or website code with
a capital letter or __ cannot be named by a variable; its base URLs stay in
env.php's system section.
Configuration check. The recipes disable a Magento safety check: the
plugin configHash (Magento\Deploy\Model\Plugin\ConfigChangeDetector, on
Magento\Framework\App\FrontControllerInterface in Magento_Deploy's
etc/di.xml). With it, every page, GraphQL and REST request answers 500 "The
configuration file has changed" while the configuration in app/etc differs
from the last app:config:import. The build adds the module
Deployyy_Platform (.platform/platform-module.php), fails when the
plugin still runs in a compiled area, and labels the image
app.deployyy.config-check=off. On that label the platform imports a
release that changes only configuration while the previous release keeps
serving, with no maintenance page. This is safe on the platform because:
- each process reads its own
config.phpandenv.phpsystemvalues and itsCONFIG__variables, which override the database at runtime; - the cache key prefix is a digest of that configuration, so two releases never share cached configuration;
- the platform runs
app:config:importfor every release that changes the configuration, while the previous release serves, and reports a failed import on the deployment.
The remaining gap: a store, website or theme that is new in config.php is
missing from the database until the import has run, and one removed from
config.php is gone from the database for the previous release from then on. Cron, consumers and bin/magento commands never ran this
check. app:config:status and config:set still compare the hashes.
A release line without a recipe fails the build, with the list of supported
lines. Adobe Commerce has no recipe. For Adobe Commerce, add your own Dockerfile.
The Magento, Mage-OS and Laravel images are thecodingmachine/php v5 images. Set these variables of the image as Deployyy variables:
| Variable | Phase | Example |
|---|---|---|
PHP_EXTENSION_<NAME> |
Build, Runtime | PHP_EXTENSION_IMAGICK=1, PHP_EXTENSION_GD=0 |
PHP_INI_<SETTING> |
Build, Runtime | PHP_INI_MAX_EXECUTION_TIME=60, PHP_INI_OPCACHE__ENABLE=1 |
TEMPLATE_PHP_INI |
Runtime | production or development |
LOCALES |
Runtime | nl_NL.UTF-8 de_DE.UTF-8 |
COMPOSER_VERSION |
Build | 2.7.9 or 2.2 |
- Build: each build step that runs PHP or composer reads the
PHP_*andCOMPOSER_VERSIONvariables of the phase Build. - Runtime: each process, release step and shell starts through the image
entrypoint (
php-entrypoint.shon Magento and Mage-OS) and reads the variables of the phase Runtime. - Extensions of
composer.json: the build turns on each extension thatcomposer.jsonor a package incomposer.lockrequires, such asext-imagick, when the image has it. The build log names them on the linePHP extensions turned on for composer.json.PHP_EXTENSION_<NAME>=0turns one off.
Deployyy refuses the variables of the image that a Deployyy feature replaces,
such as CRON_* and PHP_FPM_PM_*: see deployyy-operator
docs/VARIABLES.md.
The module Deployyy_Platform writes each record of Magento's logger as one
JSON line to stderr, in place of the files in var/log: the Logs page shows
it. The level is debug with dev/debug/debug_logging, else info. A
handler of type Magento\Framework\Logger\Handler\Base, such as the
paypal.log of a module, writes to stderr too. A handler class of its own,
such as the cron log of Magento_Cron, keeps its file. A project with
graycore/magento2-stdlogging keeps that module.
Laravel writes to stderr with LOG_CHANNEL=stderr, a value of the recipe.
Each PHP-FPM request of a Magento, Mage-OS or Laravel image on PHP 8.2 or later
is one span, a child of the traceparent of the request. The SDK sends the
spans to OTEL_EXPORTER_OTLP_ENDPOINT, a value of the recipe that names the
collector of the platform. Set the variable to your own OTLP/HTTP endpoint, or
leave it empty to send no spans.
The spans of a request:
- the request, with
url.pathandhttp.response.status_code, named by its method and its route:GET catalog_category_view, orPOST graphql productDetailwithgraphql.operation.name,graphql.operation.typeand an eventgraphql.errorfor each error of the response; - each call of Guzzle or of a PSR-18 client;
- with Laravel, each query, each Eloquent call, each queue job and each
command, and each Redis command of
Illuminate\Redis\Connections\Connection(otel-laravel.php, at most 300); - with Magento (
otel-magento.php): each SQL statement (at most 500), each Redis command ofCredis_Client(at most 300), each OpenSearch call (at most 50), each GraphQL resolver (at most 3 per field and 200 in total), and each event, observer and template that takes 5 ms or longer (at most 100). The request span counts each of them inmagento.<kind>.countand sums their time inmagento.<kind>.duration_ms.
A log line of a PSR-3 logger, such as Monolog, holds trace_id and span_id
in its context.
The image installs .platform/otel-composer.json
in /usr/local/lib/deployyy/otel, and its
otel-bootstrap.php runs before each
request. Its classes load after those of the application, so the application
keeps its own version of each package. The build resolves the bundle against
the open-telemetry/* versions of the application, such as open-telemetry/api
of elastic/transport. An application that requires open-telemetry/sdk gets
no bundle and configures OpenTelemetry itself.
| Variable | Image value |
|---|---|
OTEL_SERVICE_NAME |
magento or laravel |
OTEL_TRACES_SAMPLER |
parentbased_always_off: PHP-FPM records a request with a sampled traceparent, such as each request through the gateway. A health check of the kubelet has none. |
OTEL_EXPORTER_OTLP_TIMEOUT |
1000 (milliseconds) |
OTEL_PHP_DISABLED_INSTRUMENTATIONS |
none; pdo,guzzle turns those off |
Excimer samples the CPU time of each
traced PHP-FPM request every 10 ms. At the end of the request,
otel-bootstrap.php sends the
samples as a process_cpu profile to PYROSCOPE_SERVER_ADDRESS, a value of the
recipe, with the label span_id on each sample and the series labels
service_name (<namespace>/php-requests), namespace, pod and route, the name of
the request span, such as GET graphql ProductPage2. The request
span holds pyroscope.profile.id, so Grafana shows the flame graph of that
request in the details of the span. A request with less than 10 ms of CPU time
has no profile. Leave the variable empty to send no profiles.
A second Excimer profiler samples the call stack of each traced request each
millisecond of the wall clock. A request of 200 ms or longer stores the result
on its span as deployyy.frames: the functions over time, with a block
Waiting for the time that PHP spends in a blocking call, such as a database
query or an HTTP call. The performance view of a request in the console draws
these frames.
Images from recipes/magento and recipes/nextjs run as a non-root user,
without sudo and without extra Linux capabilities. Details:
docs/PSS-RESTRICTED.md.
The build makes two images:
- the app: the Next.js
standalone server,
node server.json port 3000. - the cache seed: the pages
next buildprerendered. They are loaded into the shared page cache before the release serves traffic, so first visitors get cached pages.
Requirements:
- A
buildscript inpackage.json, ornextas a dependency. - A route that returns HTTP 200 on
GET /api/health, or another health path set in the project settings. A release serves traffic only after its health path returns 200. The build logs a warning when/api/healthis missing. - Node 20, 22 or 24, from
.nvmrc,.node-versionorengines.node. Default: 22. The package manager follows your lockfile: npm, Yarn or pnpm.
Every variable and secret is available to next build and, at runtime, to
the server in process.env. As on Vercel, only NEXT_PUBLIC_* values end up
in the browser bundle.
A GraphCommerce storefront paired with a Magento project builds against one Magento environment. The build picks the first that exists:
- The Magento environment of the same branch.
- The environment of the branch your pull request merges into, and so on up to the main branch.
- The Magento project's main branch.
The build sets that environment's endpoint as GC_MAGENTO_ENDPOINT. That
value overrides magentoEndpoint in graphcommerce.config.js. Before
building, the build checks that the endpoint returns a GraphQL response.
Storefront environments of one commit that pair with one Magento environment
run one build. A storefront environment on another Magento environment runs a
build of its own. A GC_* or NEXT_PUBLIC_* variable with another value per
environment also makes a build per environment.
Your project needs no cache code or cache configuration. The build wraps
your next.config (.js, .mjs, .ts or .mts) and adds:
cacheHandler:recipes/nextjs/platform/cache-handler.mjs. ISR pages and fetch results go to the shared cache storage atCACHE_DIR. One revalidation updates every instance. WithoutCACHE_DIR, for example in local development, each process has its own cache.cacheMaxMemorySize: 0, so no instance keeps a stale copy in memory.output: 'standalone', if you set nooutput.- The commit as the build ID, if you set no
generateBuildId.
Images from /_next/image are not in this cache. The content delivery
network caches them.
If your next.config sets its own cacheHandler, the build keeps it and logs
a warning. output: 'export' fails the build, because environments run a
Next.js server.
The shared cache is on or off per project in the console. Switching it needs no
new build: the operator adds or removes CACHE_DIR and the /cache storage and
restarts the environment, and the handler follows CACHE_DIR.
A repository with its own Dockerfile gets none of the above, so the shared
cache stores nothing until the build carries a handler. Add once, then build:
cacheHandlerpointing at a handler that writes toprocess.env.CACHE_DIRwhen it is set. Copyrecipes/nextjs/platform/cache-handler.mjsnext to yournext.configand make sure it is in the standalone output.cacheMaxMemorySize: 0, so no instance serves a stale copy from memory.
A Dockerfile in your repository replaces the recipe. A file in .platform/
replaces the recipe file with the same name.
- PHP: from
require.phpincomposer.json, 8.2 to 8.4. - Images:
recipes/laravelbuilds the targetsphp-fpm(roleapp) andnginx(rolenginx), with your Vite or Mix assets if there is apackage.json. - Own files: a
Dockerfilein your repository replaces the recipe. A file in.platform/replaces the recipe file with the same name. - Configuration: environment variables set
DB_*,REDIS_*,APP_URL,APP_KEY, mail and S3. Do not commit a.envfile. - Migrations:
php artisan migrate --forceruns before a release serves traffic, unless the project declares its own release commands. If a migration fails, the previous release keeps serving. - Schema dumps: the image has the
mysql,mariadbandpsqlclients, sophp artisan migrateloads the dump ofphp artisan schema:dumpinto an empty database. - Web server: nginx has the server block of the
Laravel deployment documentation.
Only
public/index.phpand the scripts of.platform/nginx/*.confrun.robots.txtandfavicon.icoare a file inpublic/or a route.