Skip to content

[DRAFT] Add universal dev base image for zero-build dev setup#609

Draft
ishakuta wants to merge 1 commit intomasterfrom
feature/universal-dev-base-image
Draft

[DRAFT] Add universal dev base image for zero-build dev setup#609
ishakuta wants to merge 1 commit intomasterfrom
feature/universal-dev-base-image

Conversation

@ishakuta
Copy link

@ishakuta ishakuta commented Mar 6, 2026

Pre-builds a universal base image (spryker/dev-base:phpX.Y-nodeZ) with all common components (PHP runtime, Node.js, Linux packages, Blackfire client, supervisor, spryker user setup, SSH relay).

Projects opt in via deploy.yml docker.dev-base-image.enabled: true. When enabled, the SDK pulls the pre-built image instead of running the 6-step docker build chain. Project-specific config (PHP extensions, PHP ini, SSL certs, UID matching) moves to runtime via an entrypoint script and volume mounts.

The existing build chain is fully preserved as the default when the flag is not set.

Description

Summary

  • Adds a universal pre-built dev base image (spryker/dev-base:phpX.Y-nodeZ) that consolidates the 6-step docker build chain (application-basic,
    cli-basic, application-local, application-development, debug) into a single pull-able image
  • When enabled, docker/sdk up skips all application image builds and instead pulls the universal image, with project-specific config (PHP extensions,
    PHP ini, SSL certs, UID matching) handled at container start via an entrypoint script and volume mounts
  • Fully backward-compatible: existing build chain is unchanged when the flag is not set

Motivation

Every Spryker project runs 6+ sequential docker build steps during bootstrap in dev (mount) mode, even though most of what's built is identical across projects: PHP runtime, Node.js, Linux packages, Blackfire client, spryker user setup, SSH relay, supervisor, etc. The only project-specific parts are env vars, PHP extension selection, PHP ini overrides, SSL certs, and UID matching.

This feature eliminates that redundant build time by pre-baking the common components into a universal image that projects simply pull.

How it works

Opt-in via deploy.yml

  docker:
      dev-base-image:
          enabled: true
          # image: spryker/dev-base:php8.4-node24  # optional override

What stays the same

  • deploy.dev.yml still defines all project config
  • docker/sdk boot still runs the Twig generator to produce docker-compose.yml
  • All infrastructure services (DB, Redis, RabbitMQ, etc.) unchanged
  • Volume mounting of source code (/data) unchanged
  • Baked (production) build flow completely unchanged
  • Setting enabled: false (or omitting the key) uses the old build chain

Change log

Previously (build-time) Now (runtime)
Twig-templated mv of PHP extension .ini files in Dockerfile Entrypoint reads SPRYKER_PHP_EXTENSIONS env var, copies .ini files
usermod -u $UID spryker in mount/application/Dockerfile Entrypoint reads SPRYKER_USER_UID env var
COPY ca.crt && update-ca-certificates in application-local/Dockerfile SSL cert volume-mounted, entrypoint runs update-ca-certificates
PHP ini baked via COPY in Dockerfile Volume-mounted as read-only bind mount

New files

  • images/universal/Dockerfile — Universal base image consolidating all common build stages
  • images/universal/docker-entrypoint.sh — Runtime config handler (PHP extensions, UID, SSL, known hosts)
  • images/universal/context/php/ — Generic PHP config files (worker.conf, php.ini, opcache inis)

Modified files

  • generator/index.php — Parses docker.dev-base-image config, computes universal image tag and PHP extensions string
  • generator/src/templates/deploy.bash.twig — Exports SPRYKER_USE_UNIVERSAL_BASE_IMAGE and SPRYKER_UNIVERSAL_BASE_IMAGE shell vars
  • generator/src/templates/docker-compose.yml.twig — CLI service conditionally uses universal image with config volume mounts
  • generator/src/templates/application/*.yml.twig (7 files) — All app service templates conditionally use universal image
  • bin/sdk/images/common.sh — Added Images::pullUniversalBase() function
  • bin/sdk/images/mount.sh — Images::buildApplication() pulls instead of builds when universal mode active

Checklist

  • I agree with the Code Contribution License Agreement in CONTRIBUTING.md

Test plan

  • Build the universal base image locally: docker build -t spryker/dev-base:php8.4-node24 docker/images/universal/
  • Set docker.dev-base-image.enabled: true in deploy.dev.yml
  • Run docker/sdk boot deploy.dev.yml — verify compose uses image refs instead of build refs
  • Run docker/sdk up — verify it pulls base image, no docker build for application
  • Verify docker/sdk cli works (PHP extensions loaded, correct UID, SSL trusted, env vars set)
  • Run docker/sdk cli console cache:clear to validate full stack
  • Set enabled: false, verify the old build chain still works unchanged

Pre-builds a universal base image (spryker/dev-base:phpX.Y-nodeZ)
with all common components (PHP runtime, Node.js, Linux packages,
Blackfire client, supervisor, spryker user setup, SSH relay).

Projects opt in via deploy.yml `docker.dev-base-image.enabled: true`.
When enabled, the SDK pulls the pre-built image instead of running
the 6-step docker build chain. Project-specific config (PHP
extensions, PHP ini, SSL certs, UID matching) moves to runtime
via an entrypoint script and volume mounts.

The existing build chain is fully preserved as the default when
the flag is not set.
@ishakuta ishakuta self-assigned this Mar 6, 2026
@ishakuta ishakuta added improvement Improvement or new feature experiment labels Mar 6, 2026
@ishakuta ishakuta changed the title Add universal dev base image for zero-build dev setup [DRAFT] Add universal dev base image for zero-build dev setup Mar 6, 2026
@ishakuta ishakuta marked this pull request as draft March 6, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experiment improvement Improvement or new feature

Development

Successfully merging this pull request may close these issues.

1 participant