Skip to content

Keep the composer cache in a named volume and add portsHost - #338

Merged
AydinHassan merged 2 commits into
masterfrom
docker-groundwork
Oct 27, 2026
Merged

AydinHassan merged 2 commits into
masterfrom
docker-groundwork

Conversation

@AydinHassan

@AydinHassan AydinHassan commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Second task of #336 (Docker groundwork).

  • The composer cache is now the php-school-composer-cache named volume mounted at /composer, so it lives on the docker host, even a remote one. The composerCacheDir constructor argument is gone.
  • New portsHost option: the address published ports listen on, 127.0.0.1 by default.
  • Exercises get the sandbox host from the context: $context->getSandboxHost() has getAddress() (where to connect to published ports) and getFreePort(). Sandbox gains getHost(), and ExerciseDispatcher takes the sandbox to fill it in. For now getFreePort() asks this machine, so the Fly task needs to change it.
  • Workshop runtime images need RUN mkdir -m 1777 /solution /composer (added to learn-you-php#117 and php8-appreciate#49). Docker gives a new volume the permissions of the image directory, so any user can write to the cache.

Tried with a real container: composer install as a non-root user writes to the cache volume. learn-you-php's TimeServer passes on Docker and host using the sandbox host.

Once this is merged: phpschool.io drops its composer cache dir, and learn-you-php's TimeServer moves to getSandboxHost().

The cache now lives on the docker host, so it works when that host is remote. portsHost is the address published ports listen on, 127.0.0.1 by default. Workshop images need RUN mkdir -m 1777 /solution /composer.
SandboxHost has the address to connect to published ports on and picks free ports, so exercises no longer assume the code runs on this machine.
@AydinHassan
AydinHassan merged commit 8a8ade5 into master Oct 27, 2026
4 checks passed
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.

1 participant