Skip to content

Cache playwright install step on code changes#64

Merged
lewispb merged 1 commit intobasecamp:mainfrom
ttilberg:63-dockerfile-caches-playwright
Apr 17, 2026
Merged

Cache playwright install step on code changes#64
lewispb merged 1 commit intobasecamp:mainfrom
ttilberg:63-dockerfile-caches-playwright

Conversation

@ttilberg
Copy link
Copy Markdown
Contributor

@ttilberg ttilberg commented Apr 16, 2026

The Playwright install requires loading a small part of our application to sync the version with the ruby driver.

Since this doesn't require the host app's rails code, and instead only this gem's code, we could theoretically just separate the two "copy from build" lines, reorganize the dockerfile to:

COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
RUN PLAYWRIGHT # install
COPY --from=build /rails /rails

This prevents common code changes from requiring a new playwright install. However, we also need to copy the gemfile for bundle exec to work:

COPY --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}"
COPY --from=build /rails/Gemfile /rails/Gemfile.lock ./
RUN PLAYWRIGHT # install
COPY --from=build /rails /rails

However, there's still a situation where the Gemfile might have changes that invalidate the playwright build, and the playwright version is very rarely going to change.

Instead, this PR prints a simple version file to rely on during the build step. Docker's build cache uses the content of that file to fingerprint, so the cache now only gets busted if the Playwright version actually changes.

Closes #63

Copilot AI review requested due to automatic review settings April 16, 2026 14:26
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves Docker build caching by decoupling the Playwright install layer from application code (and most dependency) changes, so Playwright is only reinstalled when the pinned Playwright version changes.

Changes:

  • Persist the pinned Upright::PLAYWRIGHT_VERSION into /tmp/playwright_version during the build stage.
  • Install Playwright in the final stage based on the copied version file (instead of running Ruby/Bundler there).
  • Reorder final-stage layers so Playwright install happens before copying gems/app artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lewispb
Copy link
Copy Markdown
Member

lewispb commented Apr 17, 2026

Good idea! Thanks @ttilberg

@lewispb lewispb merged commit 74a173f into basecamp:main Apr 17, 2026
7 of 8 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.

Docker doesn't cache playwright install on code change after new dockerfile template includes local playwright

3 participants