Fix playwright-server docker image not exiting (#33099)

* Fix playwright-server docker image not exiting

... by wrapping with tini

* Remove redundant `npm exec`

* Update packages/playwright-common/Dockerfile

* missing comma
This commit is contained in:
Richard van der Hoff 2026-04-10 13:31:03 +01:00 committed by GitHub
parent b860a3864d
commit a132b9167d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 4 deletions

View File

@ -12,4 +12,13 @@ RUN npm i -g playwright@${PLAYWRIGHT_VERSION}
COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
# We use `docker-init` as PID 1, which means that the container shuts down correctly on SIGTERM.
#
# (The problem is that PID 1 doesn't get default signal handlers, and
# playwright server doesn't register a SIGTERM handler, so if that ends up as
# PID 1, then it ignores SIGTERM. Likewise bash doesn't set a SIGTERM handler by default.
#
# The easiest solution is to use docker-init, which is in fact `tini` (https://github.com/krallin/tini).
#
# See https://github.com/krallin/tini/issues/8#issuecomment-146135930 for a good explanation of all this.)
ENTRYPOINT ["/usr/bin/docker-init", "/docker-entrypoint.sh"]

View File

@ -1,4 +1,2 @@
#!/bin/bash
# We use npm here as we used `npm i -g` to install playwright in the Dockerfile
npm exec -- playwright run-server --port "$PORT" --host 0.0.0.0
exec /usr/bin/playwright run-server --port "$PORT" --host 0.0.0.0