-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·54 lines (46 loc) · 1.56 KB
/
Copy pathbuild
File metadata and controls
executable file
·54 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -eo pipefail
echo "---> Ruby Buildpack"
# 1. GET ARGS
layers_dir=$1
plan_path=$3
# shellcheck source=/dev/null
. generate-project.sh "${layers_dir}"
# 2. Install build deps
# shellcheck source=/dev/null
. generate-layers.sh "${layers_dir}"
generate_deps_layer build-deps
generate_deps_layer run-deps
# 3. install ruby
generate_stack_layer ruby "${plan_path}" true
# Compares previous Gemfile.lock checksum to the current Gemfile.lock
bundler_layer_dir="${layers_dir}/bundler"
local_bundler_checksum=$(sha256sum Gemfile.lock | cut -d ' ' -f 1 || echo 'not found')
remote_bundler_checksum="not found"
if [[ -f "${bundler_layer_dir}.toml" ]]; then
remote_bundler_checksum=$(yj <"${bundler_layer_dir}.toml" -t | jq -r .metadata.version 2>/dev/null || echo 'not found')
fi
mkdir -p "${bundler_layer_dir}/profile.d"
echo "export BUNDLE_APP_CONFIG=${bundler_layer_dir}" > "${bundler_layer_dir}/profile.d/bundle.sh"
# shellcheck source=/dev/null
. init-stack
mkdir -p "${bundler_layer_dir}/bin"
bundle config --local path "${bundler_layer_dir}" >/dev/null
bundle config --local bin "${bundler_layer_dir}/bin" >/dev/null
if [[ -f Gemfile.lock && "${local_bundler_checksum}" == "${remote_bundler_checksum}" ]]; then
echo "---> Reusing gems"
else
echo "---> Installing gems"
bundle install
scanelp "${bundler_layer_dir}" > "${BASE_LAYER}"/deps/.auto-deps
generate_deps_layer auto-deps
fi
cat >"${bundler_layer_dir}.toml" <<EOL
[types]
cache = true
build = true
launch = true
[metadata]
version = "${local_bundler_checksum}"
EOL
generate-launch.sh "${layers_dir}"