You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-14Lines changed: 32 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,26 +11,39 @@ Follow the steps below.
11
11
12
12
This buildpack relies on the CLI command `playwright install`. This requires [`playwright`](https://pypi.org/project/playwright/) to be installed. Do this by specifying a `requirements.txt` or any other methods accepted by the Heroku Python buildpacks.
13
13
14
+
Example `requirements.txt`:
15
+
```
16
+
environs==10.3.0
17
+
exceptiongroup==1.2.0
18
+
greenlet==3.0.1
19
+
gunicorn==21.2.0
20
+
idna==3.6
21
+
iniconfig==2.0.0
22
+
marshmallow==3.20.2
23
+
packaging==23.2
24
+
playwright==1.40.0
25
+
pluggy==1.3.0
26
+
```
27
+
14
28
## Buildpack ordering
15
29
16
30
Order matters for this buildpack to work. Here's the run order that you should should have:
17
31
18
32

19
33
20
34
1. The official [Python buildpack](https://elements.heroku.com/buildpacks/heroku/heroku-buildpack-python).
21
-
- Runs first so that Playwright is available as a CLI tool after the package installation is done
22
-
1. This build pack. [Here's how to add this buildpack to your app](https://devcenter.heroku.com/articles/buildpacks#using-a-third-party-buildpack) by using its Git URL.
23
-
2. The [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack)
24
-
-**Why?** This buildpack CANNOT install system requirements (i.e. `playwright install --with-deps`) due to restrictions from Heroku. It's only able to install the browser executables. Thus, we rely on [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack) to get the needed system packages.
35
+
- Runs first so that Playwright is available as a CLI tool after the package installation is done
36
+
2. This build pack. [Here's how to add this buildpack to your app](https://devcenter.heroku.com/articles/buildpacks#using-a-third-party-buildpack) by using its Git URL.
37
+
3. The [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack)
25
38
26
39
27
40
## Customize the following config variables:
28
41
1.`PLAYWRIGHT_BUILDPACK_BROWSERS` accepts a comma-separated list of the browser names. By default, it's installing executables for `chromium,firefox,webkit`.
29
-
- E.g. To only install Chromium dependencies, set the variable to `chromium`. This will reduce the slug size in the end too.
30
-
-**NOTE**: this is what the author uses, usage with the other 2 browsers are unknown. Feel free to test them out and let me know if they work and I'll update the docs.
31
-
- This config variable is intended to be shared with [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack).
42
+
- E.g. To only install Chromium dependencies, set the variable to `chromium`. This will reduce the slug size in the end too.
43
+
-**NOTE**: this is what the author uses, usage with the other 2 browsers are unknown. Feel free to test them out and let me know if they work and I'll update the docs.
44
+
- This config variable is intended to be shared with another variable with the same name from[heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack).
32
45
2.`BUILDPACK_BROWSERS_INSTALL_PATH` is the path where the browsers will be installed. Its default value is `browsers` and it's a relative path starting from the [`BUILD_DIR`](https://devcenter.heroku.com/articles/buildpack-api#bin-compile) (the starting directory of the compiled slug to be used by Heroku). It's necessary to have the installed browsers within the `BUILD_DIR` to have the file included by the time Heroku starts the dyno.
33
-
- E.g. To install in the directory `utils/browsers`, set the variable to `utils/browsers`.
46
+
- E.g. To install in the directory `utils/browsers`, set the variable to `utils/browsers`.
34
47
35
48
## Modify your browser creation script
36
49
@@ -63,13 +76,18 @@ The command to install the system packages along with the browser is `playwright
63
76
Here are a few things to consider:
64
77
- This buildpack is meant for Python Playwright and was developed with Chromium in mind. Any other browser/Playwright distro is not tested by me so I offer no guarantees there
65
78
- Verify that the installation is successful. Look at the build logs, you should see progress bar for the executable installations
66
-
- Verify that the executable paths are properly set. Look through the logs for something like this
67
-
```
68
-
```
69
-
- You can also `heroku run bash` into the dyno and search for the installation folder to verify that the exe are downloaded.
79
+
- Verify that the executable paths are properly set. Look through the logs (the app's log, not the buildpack) for something like this
80
+
```
81
+
2024-02-07T21:57:03.415283+00:00 app[release.8706]: ----> CHROMIUM_EXECUTABLE_PATH is /app/browsers/chromium-1091/chrome-linux/chrome
82
+
2024-02-07T21:57:03.555317+00:00 app[release.8706]: ----> FIREFOX_EXECUTABLE_PATH is /app/browsers/firefox-1429/firefox/firefox
83
+
2024-02-07T21:57:03.690086+00:00 app[release.8706]: ----> WEBKIT_EXECUTABLE_PATH is /app/browsers/webkit-1944/pw_run.sh
84
+
```
85
+
- You can also `heroku run bash` into the dyno and search for the installation folder to:
86
+
- Verify that the exe are downloaded by going into `BUILDPACK_BROWSERS_INSTALL_PATH`
87
+
- Verify that the env variables like `CHROMIUM_EXECUTABLE_PATH` are set properly
70
88
71
89
# Credits
72
-
A lot of code and patterns were borrowed from [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack).
90
+
A lot of code and patterns were taken from [heroku-playwright-buildpack](https://github.com/playwright-community/heroku-playwright-buildpack).
73
91
74
-
Idea for the buildpack were borrowed from [playwright-python-heroku-buildpack](https://github.com/binoche9/playwright-python-heroku-buildpack).
92
+
Idea for the buildpack was inspired by [playwright-python-heroku-buildpack](https://github.com/binoche9/playwright-python-heroku-buildpack).
echo"-----> BUILDPACK_BROWSERS_INSTALL_PATH is $BUILDPACK_BROWSERS_INSTALL_PATH"
31
31
echo"-----> Browsers will be installed in $PLAYWRIGHT_BROWSERS_PATH"
32
32
echo"-----> Installing Playwright executables (env: PLAYWRIGHT_BUILDPACK_BROWSERS) for ${PLAYWRIGHT_BUILDPACK_BROWSERS} (formatted value for command line is '${PLAYWRIGHT_BUILDPACK_BROWSERS//,/ }')."
0 commit comments