Skip to content

Copy files into one container per solution, docker exec each run - #341

Closed
AydinHassan wants to merge 4 commits into
masterfrom
exec-per-request
Closed

AydinHassan wants to merge 4 commits into
masterfrom
exec-per-request

Conversation

@AydinHassan

Copy link
Copy Markdown
Member

Task 5 of #336.

  • Files go into the container with tar instead of a bind mount, so DOCKER_HOST can point at another machine.
  • Runs of the same folder share one container (create + start + tar once, then docker exec per run). It is removed when the sandbox is.
  • Composer and runs with exposed ports still get their own container, as they need network / -p. After composer, composer.lock comes back (and vendor/ when there is no vendor volume).
  • /solution is an anonymous volume, so it is writable under --read-only and a new vendor volume still takes the image's 1777 permissions.

learn-you-php dependency-heaven verify, docker, locally: 6.0s → 2.5s.

Nothing is mounted from this machine any more, so the docker host can be another one. Runs of a folder share a container, removed with the sandbox. Composer and runs with exposed ports get their own, composer copies composer.lock (and vendor when there is no volume) back.
@AydinHassan
AydinHassan marked this pull request as draft November 1, 2026 07:36
@AydinHassan AydinHassan mentioned this pull request Nov 1, 2026
3 of 5 tasks
@AydinHassan

Copy link
Copy Markdown
Member Author

Superseded: being rewritten on the new Sandbox classes, see #336

@AydinHassan AydinHassan closed this Nov 1, 2026
AydinHassan added a commit that referenced this pull request Nov 1, 2026
Part of #336, replaces
#341.

- `DockerSandboxFactory::create()` starts the solution's container
(`docker run -d --rm ... sleep 300`, same isolation flags) and copies
the directory in with `docker cp`. Nothing is mounted, so the docker
host can be remote.
- `DockerSandbox::execute()` is a `docker exec` with `timeout -s KILL
30`.
- `DockerSandbox::finish()` copies back the context's solution files
(eg. `db.sqlite`) with `docker cp`, removes the container and releases
the port. The port lock lasts 300s, as long as a container lives.
- Tests use `test/res/fake-docker`, which logs its args.

Tried with real Docker: learn-you-php Database Read (pass, and a broken
solution fails the database check), Time Server, php8-appreciate All
Mixed Up (`param.log` comes back, File Comparison passes). No containers
left behind.
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