diff --git a/packages/playwright-common/Dockerfile b/packages/playwright-common/Dockerfile index 20bb7713a3..093d9dcf82 100644 --- a/packages/playwright-common/Dockerfile +++ b/packages/playwright-common/Dockerfile @@ -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"] diff --git a/packages/playwright-common/docker-entrypoint.sh b/packages/playwright-common/docker-entrypoint.sh index 66a71fcd58..b615bf24d6 100755 --- a/packages/playwright-common/docker-entrypoint.sh +++ b/packages/playwright-common/docker-entrypoint.sh @@ -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