Magento pipeline deployment: why teams split build from production
If every Magento Open Source release compiles code and deploys static assets inside the maintenance window, the store is offline for longer than it needs to be. Separating build from production moves compilation and static content generation onto a build system, so production only runs the import and upgrade steps. The result is a shorter window and fewer surprises when the release reaches live traffic.
The Magento docs support this split. setup:upgrade applies schema and data changes, setup:static-content:deploy generates the static view files, and the generated code and var/ output can be produced ahead of time and then moved with the release. The --keep-generated option in setup:upgrade is the other lever: it avoids regenerating code on production when the build already did that work. Your team should confirm these options and their behavior against the exact release it runs, using the Adobe Commerce release notes for Magento Open Source 2.4.9 as the starting point for its version.
Teams need this pattern when compilation is slow enough to matter, when several nodes must receive identical artifacts, or when release windows are contractually or commercially tight. A single-node store with a small catalog and a generous maintenance window can often build in place without harm, provided the team runs the same steps in the same order every time. Before choosing, measure how long a full compile and static deploy take on a copy of production, then decide whether that time justifies a build server and a release artifact process.
How artifacts move from build server to production
The build server runs composer install, deploys static content and compiles code from the source repository, then hands a built artifact to production. Production never compiles. It enters maintenance mode, runs setup:upgrade --keep-generated against the shared config.php committed to Git, flushes caches and runs a smoke test before leaving maintenance mode. The env.php file and production secrets stay on production only, so confirm that the handoff excludes them and that your team can rebuild the artifact from the same commit.
Build work moves off production; only import and upgrade steps run there.
What runs on the build server and what runs on production
The build server does everything that can run without touching live customer traffic or the production database. It resolves Composer dependencies from the locked file, compiles dependency injection configuration and generated code, and deploys static view and locale files for the target locales and themes. Its output is a complete, versioned release artifact that production can receive without recompiling anything. Because this work is CPU and I/O heavy, moving it off production keeps the live store responsive while the build runs.
- Composer dependencies: Install from the committed
composer.lockwith the exact PHP and extension versions your production nodes run. - Code generation: Run
setup:di:compileso proxies, factories and interceptors are generated against the same code version. - Static content: Run
setup:static-content:deployfor each required locale and theme, so no storefront request triggers on-demand generation. - Artifact packaging: Store the generated code, static files and vendor tree as one versioned release directory or image.
- Build parity: Use the same PHP, Composer and Node versions on the build server that the production web nodes run.
Confirm the exact flags and deploy commands for your Magento Open Source version in the official documentation before you script them.
Production should only run the steps that must touch live state: putting the store into maintenance mode, applying schema and data changes to the database, flushing and warming caches, reindexing where needed, and switching the web root to the new release. Each of these steps depends on the database or running processes, so they cannot be produced ahead of time. Keeping the list short is what makes the window predictable, and it also makes rollback easier to reason about.
- Maintenance mode: Enable it only for the window and allow staff IP addresses through so the team can verify the release.
- Schema and data upgrade: Run
setup:upgradeagainst the new code, which applies declarative schema and data patches. - Cache and index steps: Clean caches and run the required reindex and cron jobs after the upgrade completes.
- Release switch: Point the web server at the new release directory in one atomic change, keeping the previous release for rollback.
- Verification: Check storefront, admin and checkout paths before disabling maintenance mode.
Ask your team to document the exact production step list and time each step on a staging copy of the production database.
Generated code, compiled dependency injection files and static assets are derived from a specific version of the source code and configuration. If production serves static files from one build and PHP code from another, the storefront can request assets that do not exist or run classes that no longer match their proxies. The result is often intermittent errors that appear only after a partial deploy. Treating each build as an immutable unit avoids this class of fault.
- Version pinning: Tie every generated file to the commit hash and Composer lock that produced it.
- No mixed releases: Never copy only the
pub/staticdirectory or onlygeneratedinto a live release. - Shared media and state: Keep uploaded media, logs and session data outside the release directory so every release can reference them.
- Rollback path: Reactivate the previous release directory, which already contains matching generated and static files.
- Hotfix discipline: Route even small template fixes through a new build rather than editing files on production.
Check that your release tooling refuses to switch when the artifact version and the code version disagree.
Configuration splits into two groups. Shared settings describe the store's behavior and belong in version control, typically in app/etc/config.php after exporting with app:config:dump. System-specific settings describe a particular environment, such as database hosts, cache backends, session storage and encryption keys, and belong in app/etc/env.php or the environment itself. Mixing the two causes configuration drift that the release pipeline cannot detect.
- Shared in Git: Module enablement, locked configuration values and store-wide settings exported with
app:config:dump. - System-specific outside Git: Database credentials, Redis and OpenSearch hosts, cache and session backends, and the encryption key.
- Sensitive values: Set secrets from the command line or a secret store at deploy time instead of committing them.
- Consistency check: Compare
config:showoutput between build and production before each release. - Shared file layout: Keep
env.phpin a shared location and link it into each release during the switch.
Confirm with your platform team which values your secret management approach can inject without writing them to disk in plain text. The shared file layout is covered in more detail in the sibling topic on managing configuration across environments.
Which pipeline layout fits which store
This table compares three ways to split building from production for a Magento Open Source store: a copied build artifact, a promoted container image, and a build on the production node with compile skipped. Read each row against your team size, PHP and extension control, and tolerance for drift, because the failure modes differ more than the tooling does.
| Layout | When it fits | What it requires from the team | Failure modes to plan for |
|---|---|---|---|
| Single build artifact copied to production | Teams with one or two stores, a stable extension set and a build host that matches production OS and PHP | A build host with the same PHP extensions, Composer 2 and Node tooling as production, plus a deploy step that unpacks the artifact and runs only import and upgrade steps | Drift between build and production PHP minor versions or extension builds; generated code and static assets built against the wrong configuration; artifacts that include files that must stay per-node |
| Container image promoted across environments | Teams already running containers, with several environments and a need to test the exact image before release | Image build pipeline, a registry the production nodes can reach, image signing or digest pinning, and a rule that secrets stay out of the image | Images built with stale base layers; config baked in that should come from env.php or the environment; larger images and slower rollback if the database schema has already moved forward |
| Build on the production node with compile skipped | Small stores with one production node and a team that cannot yet run a separate build host | Strict discipline on maintenance mode, running setup:upgrade with --keep-generated, and a documented rollback path; careful use of the static content and DI compile steps | Compile or static deploy running during peak traffic; partial code tree during a deploy; drift between the node and the expected release because nothing checks the build output |
| Build host version parity | Any layout that compiles off production | Matching PHP minor version, PHP extensions and Composer version to the requirements for the release line in use | Compiled output built on a different PHP minor than production; installed extensions missing on one side; the mismatch often appears only after cutover |
| Shared configuration handling | Any layout with more than one environment | Committing config.php and the shared configuration pattern, keeping env.php and secrets out of Git, and checking the locked values on each target | Config changes made directly on production and lost on the next release; sensitive values committed by mistake; differences between development and production that only surface at cutover |
| Rollback and schema ordering | Any layout where a release changes database schema | A written rollback plan for code and database, and an agreed order for deploying code, running setup:upgrade and clearing caches | Old code running against a new schema after a partial deploy; caches holding compiled output from the previous release; rollback that restores code but not data changes |
| Extension version pinning | Stores with third-party extensions or custom modules | Composer lock files committed and reviewed, a list of extension versions checked against the release line before each build | Extension updates pulled in at build time but not tested; a module that works on the build host and fails on production because its dependencies differ |
How to set up a build and release sequence
This sequence moves compilation, static asset generation and Composer authentication off production so the release window only covers database import and upgrade steps. The result is a tested artifact, a rehearsed production runbook and a rollback path that the operations team can run without the build team present.
Pin the supported stack for your release line
Choose the 2.4.x release you will run, then pin PHP, MySQL or MariaDB, OpenSearch, Redis or Valkey, RabbitMQ, Composer and nginx to the combination Adobe lists for that release. Adobe supports only the listed combinations, so the same versions must exist on the build server, staging and production. For example, the 2.4.9 requirements list PHP 8.5, OpenSearch 3, RabbitMQ 4.3 and Composer 2.10, while 2.4.8-p5 lists PHP 8.4 or 8.3. Verification: a version matrix, signed off by the platform owner, that compares each host's installed versions against the requirements page for the chosen release.
Keep Composer credentials out of Git
Store the Adobe Marketplace access keys in an auth.json file that is excluded from version control and injected into the build job from the CI secret store. The build job writes the file at runtime and removes it when the job ends. Confirm with your security team where the keys are held and who can read them. Verification: a repository scan finds no auth.json, env.php or key material in the committed tree, and a build log shows the credentials were consumed without being echoed.
Run the build and static deploy on the build server
On a dedicated build host with the pinned toolchain, run composer install from the locked dependency file, compile dependencies, and generate static view files for each store view and locale. Keep the generated code and static content in a versioned release directory, not in the live docroot. The build should not write to production paths. Verification: the build completes from a clean workspace, and the output directory contains generated code and static assets for every configured locale.
Package shared configuration separately from the artifact
Commit config.php and the approved environment-specific settings through your configuration process, and keep secrets such as database passwords and encryption keys in env.php on each target system. Package the application code and generated output as one artifact with a manifest that records the Git commit, PHP version and Composer lock hash. Verification: deploying the artifact to a clean host with only the environment file added produces a store that starts without manual edits.
Verify the artifact on a staging copy
Deploy the artifact to a staging system built from a recent production database copy, with the same stack versions and the same search, cache and queue services. Run the production import and upgrade commands there exactly as written in the runbook, then time each step and record any errors or warnings. Verification: the staging run completes without errors, the recorded step timings are kept with the release record, and any compile or permission issues are fixed in the build, not on production.
Write the production import and upgrade runbook
Document the ordered production steps: enable maintenance mode with the approved staff IP exceptions, switch the release symlink, run the database schema and data upgrade, reindex and flush caches, then disable maintenance mode. Name the operator for each step and the log files to check. Keep the database backup and the previous release directory available before the window opens. Verification: a dry run of the runbook on staging is signed off, and each step has a recorded expected result.
Define rollback and run smoke checks
Set the rollback trigger conditions in advance, such as failed upgrade commands or checkout errors, and document how to repoint the release symlink to the previous artifact and restore the database if the upgrade changed data irreversibly. After go-live, run smoke checks on the storefront, admin login, search, cart, checkout test transaction and cron heartbeat. Verification: rollback has been rehearsed on staging, and the smoke checklist is recorded as passed or failed with timestamps.
What belongs in the build and what must never be committed
The rule that holds a pipeline together is simple: shared configuration goes into Git, and anything that describes a specific environment stays out of it. Commit the code, custom modules and themes, the composer.json and composer.lock files, and the shared settings you can export with app:config:dump into config.php. Keep database credentials, the encryption key in env.php, SMTP and search passwords, payment gateway secrets, the production base URLs, and the admin path and admin user details out of the repository. Those values belong in the production app/etc/env.php (and in secret stores on the build side only where the pipeline needs them), and each environment sets them from its own source. Before the first pipeline run, check that .gitignore excludes app/etc/env.php, auth.json and any local media or var directories, and confirm the same list with your security team.
A pipeline that compiles on a build host and deploys to a separate production host creates one specific risk: the artifact can carry the wrong environment file. If the build host has a working env.php, copying the whole application directory into the release package moves its credentials into a location that is less controlled than production. Build from a clean checkout, write the artifact without env.php and auth.json, and let the production host supply its own copy during deployment. The generated directory (generated/, including code and metadata) and the static view files (pub/static/) must be produced from the same commit that ships in the artifact, and they must match the theme and locale settings in config.php on production. Mixed output is a common cause of broken storefronts after a release, so have the pipeline record the commit hash and confirm that production runs the same hash after deployment.
Security risks of a split build and release pipeline
Splitting builds from production moves artifacts, credentials and configuration across a boundary that attackers and mistakes both cross. The cards below pair each risk with the control to apply and the check to run before every release.
Repository credentials in artifacts or logs
Composer repository keys and Magento marketplace access keys are needed to build, so they tend to end up in auth.json, build logs or the packaged artifact. Keep build credentials on the build server only, use scoped, read-only keys where the provider allows them, and scan the artifact and CI logs for key patterns before it is published. Rotate any key that appears outside the build host.
Build server with write access to production
A build server that can write directly into production web roots gives any compromise of the build host a path to the live store. Use a dedicated deploy identity that can only copy a versioned release into a new directory and switch a symlink, with no shell access and no rights over env.php or the database. Ask who holds the deploy key and how it is revoked.
Unreviewed artifacts reaching production
When the pipeline builds and deploys without a gate, code that nobody reviewed can reach customers. Require a passing test run and a human approval before the production job, and record a checksum for each release archive so the production host verifies the exact file that was built. Keep the release identifier in the artifact name so rollbacks point to a known build.
Drift between staging and production configuration
If staging and production store configuration differ, a release that passed staging can behave differently in production. Keep shared settings in config.php under version control, lock values that must not change in the admin, and compare the configuration dump from each environment before the release. Settings that differ by environment belong in env.php on each host, not in the repository.
Maintenance-mode exposure during imports
While maintenance mode is on, the storefront is down, but the admin and any allowed IP addresses can still reach the store, and a forgotten allowance can stay open after the window. Allow only the staff IP addresses needed for verification, remove them as soon as the release is confirmed, and confirm the store leaves maintenance mode. Limit who can run setup:upgrade on production to the release operator.
Patch cadence and PCI exposure
Adobe recommends upgrading every patch cycle to stay secure and PCI compliant, so a pipeline that makes releases slow or manual tends to fall behind. Build the pipeline so a patch release is a routine run of the same job, and track which 2.4.x line the store is on against Adobe's support dates. Ask your team to confirm the patch schedule before the pipeline is signed off.
- Current release line
- 2.4.9
Questions teams ask before splitting build from production
What drives the effort of a Magento build and production pipeline?
The effort is set mostly by how many moving parts the store has and how much of its code and configuration is custom. A pipeline has to produce the same compiled code, static assets and generated files every time, run them on a build system, and move them to production without rebuilding there. Teams with a few custom modules, one theme and a clean config.php take less effort than teams with many third-party extensions, a custom front end build, several store views and secrets spread across servers. Extension count and coding practices also matter, because each one adds compile and deploy steps that must be tested. Ask for a written list of build steps, artifacts and rollback steps in any quote, since those lines show where the work sits.
Can a small in-house team build this pipeline themselves?
Yes, a small team can build it if at least one engineer knows Magento's deployment commands, Composer, and the CI system they already run. The hard parts are not the scripts but the discipline around them: keeping shared configuration in Git, making sure the build server and production run the same PHP, Composer and Magento versions, and testing each release on staging before it reaches production. The cost is mostly internal engineer time, both to build the pipeline and to maintain it through each patch cycle. A partner is worth comparing when the team lacks Magento experience, has no staging environment, or cannot spare an engineer for several weeks of setup and testing.
What does our team need to provide before the work starts?
Plan to supply four things: a Git repository for code and shared configuration, a staging environment that matches production in PHP, database, search and cache versions, role-based access to the build server, production hosts and the CI system, and test data that resembles real catalog and order volumes without exposing customer personal data. Access should be scoped to named people, and secrets such as the admin credentials and payment keys should stay out of the repository. Confirm early who can approve a release, who owns the maintenance window, and where the Magento and Composer authentication keys are stored, because delays usually come from missing access rather than from build problems.
How long does adoption take, and what sets that duration?
The duration depends on the current release process, the number of environments and how much the team has to standardize before automation can work. Adoption usually includes mapping the current steps, moving configuration into version control, building the artifact on a build server, rehearsing the import and upgrade steps on staging, and repeating the cycle until a release runs without manual fixes. Teams with a documented release routine and a staging copy that matches production finish sooner. Teams that discover undocumented server edits, drift between nodes or extensions that break during compilation need more time. Ask any provider for a phased plan with exit criteria for each phase, and confirm the duration against your own environment rather than a generic figure.
Does a build and production split work on a single node?
Yes. The split is useful on one server because the expensive work, dependency installation, dependency compilation and static content deployment, can run on a separate build system, while production only receives the built code and runs the import and upgrade steps. Production still needs its own PHP-FPM, web server, database, search and cache services, so a single node reduces the number of hosts to keep in sync but not the number of services. The pipeline also makes sense on several web nodes, where the same artifact must reach every node in the same order. Confirm that the build system runs the same PHP and Composer versions as production before relying on its output.
How does this change patch cycles for Magento Open Source?
It makes each patch faster to apply and easier to roll back, because the build is made and tested before the maintenance window starts. Adobe recommends upgrading every patch cycle to stay secure and PCI compliant, so patches arrive regularly, and a pipeline turns each one into a repeatable release rather than a fresh manual job. The pipeline does not remove the testing work: each patch still needs regression checks on your custom modules, themes and integrations, and major upgrades still need the Upgrade Compatibility Tool and a fuller test plan. Adobe's lifecycle policy sets the support dates that should drive your release calendar.
When an outside partner helps with this pipeline
An outside partner adds the most value when the release process has to survive conditions that a small in-house team rarely has time to test: an existing store with many extensions and customizations, a multi-node layout where the build artifact must reach every web node the same way, or a compliance review that asks how code reaches production and who can change it. In those cases the question is less about whether a build server can run setup:di:compile and setup:static-content:deploy and more about whether the split between build and production is documented, repeatable and reviewed. Before engaging anyone, confirm your current upgrade effort drivers with your own inventory of extensions, third-party integrations and custom code, since Adobe's upgrade guide names these as the main factors in effort.
Ask any partner for a written scope before work starts. The scope should list the build host and its tooling, the artifact that moves between systems (and what it excludes, such as app/etc/env.php), the shared configuration approach, the exact setup:upgrade --keep-generated and maintenance mode steps on production, and the environments covered. Ask for pipeline diagrams that show every handoff, including who approves a release and where the file system owner and web server user are set on each host. Confirm that the partner's runbooks cover the Magento version you run, because Adobe's Magento Open Source release schedule sets the patch cadence that the pipeline must absorb.
Ask for a tested rollback as a deliverable, not a description. A rollback test should restore the previous code and generated artifacts on production, re-run the import and upgrade steps in reverse order where possible, and confirm that the database backup restore has been timed on a copy of production. Ask the partner to record which steps were run in a staging rehearsal, which ones failed, and what changed afterward. Use this record to decide whether your own team can run the pipeline after handover, and agree in the quote whether training, runbook updates or a retainer for later patch cycles are included or billed separately.
How DeployOpen works on this
DeployOpen plans and builds the release pipeline for a self-hosted Magento Open Source store inside your own infrastructure, with build and production systems kept separate. The written scope fixes which servers, shared configuration and release steps are covered before any work starts.
How we scope
- Inventory the build server, production nodes, shared storage and the Git repository that holds custom code and configuration.
- Agree in writing which Magento versions, PHP and database combinations and release steps the pipeline must support.
- Record who approves each release, which maintenance window applies and how rollback is handled before work starts.
How we build
- Create build jobs that run Composer installs, static content deployment and compilation on the build server, not on production.
- Separate shared configuration from environment-specific values so production runs only import and upgrade steps.
- Test each pipeline run in a non-production environment that mirrors the production layout before any release is promoted.
How we hand over
- Deliver the pipeline definition, build scripts, deployment runbook and rollback procedure as versioned files in your repository.
- Document the artifact contents, the release checklist and the commands operators run on production during a window.
- Walk your operations and engineering staff through a supervised release so they can run the next one themselves.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover, with scope agreed in writing.
- Plan pipeline updates alongside each Magento patch cycle, including changes to PHP, OpenSearch and cache services.
- Retest the pipeline after changes to the build image, dependencies or production topology to confirm releases still deploy cleanly.

