|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +BUILD_DIR=$1 |
| 6 | +CACHE_DIR=$2 |
| 7 | +ENV_DIR=$3 |
| 8 | +BP_DIR=`cd $(dirname $0); cd ..; pwd` |
| 9 | + |
| 10 | +error() { |
| 11 | +echo " ! $*" >&2 |
| 12 | +exit 1 |
| 13 | +} |
| 14 | + |
| 15 | +topic() { |
| 16 | +echo "-----> $*" |
| 17 | +} |
| 18 | + |
| 19 | +install_system_deps() { |
| 20 | +topic "Installing System Dependencies" |
| 21 | + |
| 22 | +APT_BUILDPACK="https://github.com/heroku/heroku-buildpack-apt" |
| 23 | +local buildpack_tmpdir=$(mktemp -d) |
| 24 | +cd $buildpack_tmpdir && git clone $APT_BUILDPACK . |
| 25 | + |
| 26 | +local build_tmpdir=$(mktemp -d) |
| 27 | +mkdir -p $build_tmpdir |
| 28 | +cat << EOF >$build_tmpdir/Aptfile |
| 29 | +# WebKit dependencies |
| 30 | +#libwoff1 |
| 31 | +#libopus0 |
| 32 | +#libwebp6 |
| 33 | +#libwebpdemux2 |
| 34 | +#libenchant1c2a |
| 35 | +#libgudev-1.0-0 |
| 36 | +#libsecret-1-0 |
| 37 | +#libhyphen0 |
| 38 | +libgdk-pixbuf2.0-0 |
| 39 | +#libegl1 |
| 40 | +libnotify4 |
| 41 | +#libxslt1.1 |
| 42 | +#libevent-2.1-6 |
| 43 | +#libgles2 |
| 44 | +#libvpx5 |
| 45 | +# gstreamer and plugins to support video playback in WebKit |
| 46 | +#gstreamer1.0-gl |
| 47 | +#gstreamer1.0-plugins-base |
| 48 | +#gstreamer1.0-plugins-good |
| 49 | +#gstreamer1.0-plugins-bad |
| 50 | +# Chromium dependencies |
| 51 | +libnss3 |
| 52 | +libxss1 |
| 53 | +libasound2 |
| 54 | +fonts-noto-color-emoji |
| 55 | +libcairo-gobject2 |
| 56 | +# Firefox dependencies |
| 57 | +libdbus-glib-1-2 |
| 58 | +libxt6 |
| 59 | +libsm6 |
| 60 | +libice6 |
| 61 | +# FFmpeg to bring in audio and video codecs necessary for playing videos in Firefox |
| 62 | +ffmpeg |
| 63 | +# (Optional) XVFB if there's a need to run browsers in headful mode |
| 64 | +xvfb |
| 65 | +EOF |
| 66 | + |
| 67 | +local cache_tmpdir=$(mktemp -d) |
| 68 | + |
| 69 | +HOME=/app $buildpack_tmpdir/bin/compile $build_tmpdir $cache_tmpdir |
| 70 | +if [ $? -ne 0 ]; then |
| 71 | +rm -rf $buildpack_tmpdir $build_tmpdir $cache_tmpdir |
| 72 | +error "Could not install dependencies" |
| 73 | +fi |
| 74 | +mv $build_tmpdir/.apt $BUILD_DIR |
| 75 | +# mv file in case user is using .profile.d |
| 76 | +mkdir -p $BUILD_DIR/.profile.d/ |
| 77 | +mv $build_tmpdir/.profile.d/000_apt.sh $BUILD_DIR/.profile.d/ |
| 78 | + |
| 79 | +rm -rf $buildpack_tmpdir $build_tmpdir $cache_tmpdir |
| 80 | +} |
| 81 | + |
| 82 | +configure_export_env() { |
| 83 | + topic "Writing profile script" |
| 84 | + mkdir -p $BUILD_DIR/.profile.d |
| 85 | + cat << EOF >$BUILD_DIR/.profile.d/001_playwright.sh |
| 86 | +export PLAYWRIGHT_BROWSERS_PATH=0 |
| 87 | +EOF |
| 88 | + |
| 89 | + # Give environment variable to other buildpacks |
| 90 | + echo "export PLAYWRIGHT_BROWSERS_PATH=0" >> "$BP_DIR/export" |
| 91 | + |
| 92 | + export PLAYWRIGHT_BROWSERS_PATH=0 |
| 93 | +} |
| 94 | + |
| 95 | +install_system_deps |
| 96 | +configure_export_env |
0 commit comments