# CI runner image for browserious (brs-134).
#
# Adds what the workflow needs but the stock runner image lacks. GitHub's hosted
# ubuntu runners ship these; a bare container does not, and the failures they
# cause look like real test failures rather than environment gaps:
#
#   * Playwright's system libraries — without them `launch_persistent_context`
#     fails with "Host system is missing dependencies to run browsers", which
#     reads as a browser bug.
FROM myoung34/github-runner:ubuntu-noble

# Pinned to the version in requirements; a mismatch installs the wrong library
# set and fails at browser launch rather than at install.
ARG PLAYWRIGHT_VERSION=1.49.1

RUN apt-get update \
    && apt-get install -y --no-install-recommends nodejs npm \
    && npx --yes playwright@${PLAYWRIGHT_VERSION} install-deps chromium \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Prepare cgroup v2 delegation before handing off to the runner's entrypoint.
# Without this the nested dockerd cannot apply resource limits — see the script
# for the full explanation and brs-141 for how it was diagnosed.
COPY cgroup-prep.sh /usr/local/bin/cgroup-prep.sh
RUN chmod +x /usr/local/bin/cgroup-prep.sh
ENTRYPOINT ["/usr/local/bin/cgroup-prep.sh"]
# Restating CMD is required, not decorative: setting ENTRYPOINT in a Dockerfile
# resets the inherited CMD to null, so the entrypoint registered the runner and
# then had nothing to exec — it exited and deregistered in a restart loop.
CMD ["./bin/Runner.Listener", "run", "--startuptype", "service"]
