https://github.com/reenhanced/buildpack-chrome-with-chromedriver
Cloud Native Buildpack (CNB) to install Chrome and Chromedriver
https://github.com/reenhanced/buildpack-chrome-with-chromedriver
Last synced: 26 days ago
JSON representation
Cloud Native Buildpack (CNB) to install Chrome and Chromedriver
- Host: GitHub
- URL: https://github.com/reenhanced/buildpack-chrome-with-chromedriver
- Owner: reenhanced
- Created: 2023-11-15T16:16:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-16T16:16:38.000Z (over 1 year ago)
- Last Synced: 2025-02-25T07:14:24.208Z (over 1 year ago)
- Language: Shell
- Size: 30.3 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Support: support/test.sh
Awesome Lists containing this project
README
# buildpack-chrome-with-chromedriver
This buildpack downloads and installs (headless) Google Chrome from your choice
of release channels. It also installs chromedriver.
Installation is performed in the /layers directory in the image so you can mount your rails app
overtop of /workspace for development.
## Channels
You can choose your release channel by specifying `GOOGLE_CHROME_CHANNEL` as
a config var for your app, in your app.json (for Heroku CI and Review Apps),
or in your pipeline settings (for Heroku CI).
Valid values are `stable`, `beta`, and `unstable`. If unspecified, the `stable`
channel will be used.
## Shims and Command Line Flags
This buildpack installs shims that always add `--headless`, `--disable-gpu`,
`--no-sandbox`, and `--remote-debugging-port=9222` to any `google-chrome`
command as you'll have trouble running Chrome on a Heroku dyno otherwise.
You'll have two of these shims on your path: `google-chrome` and
`google-chrome-$GOOGLE_CHROME_CHANNEL`. They both point to the binary of
the selected channel.
## Selenium
To use Selenium with this buildpack, you'll also need Chrome's webdriver.
This buildpack includes it.
Additionally, chromedriver expects Chrome to be installed at `/usr/bin/google-chrome`,
but that's a read-only filesystem in a Heroku slug. You'll need to tell Selenium/chromedriver
that the chrome binary is at `$GOOGLE_CHROME_SHIM` instead.
To make that easier, this buildpack makes `$GOOGLE_CHROME_BIN`, and
`$GOOGLE_CHROME_SHIM` available as environment variables. With them, you can
use the standard location locally and the custom location on Heroku. An example
configuration for Ruby's Capybara:
```
chrome_bin = ENV.fetch('GOOGLE_CHROME_BIN', nil)
Capybara.register_driver :chrome do |app|
options = Selenium::WebDriver::Chrome::Options.new
options.binary = chrome_bin if chrome_bin
Capybara::Selenium::Driver.new(
app,
browser: :chrome,
options: options
)
end
Capybara.javascript_driver = :chrome
```
## Publishing a new release
(For maintainers)
You can publish a new release to the buildpack registry by running the following commands:
```sh
pack buildpack package --publish reenhanced/buildpack-chrome-with-chromedriver
```