-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·45 lines (36 loc) · 1015 Bytes
/
build
File metadata and controls
executable file
·45 lines (36 loc) · 1015 Bytes
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
#!/usr/bin/env bash
set -eo pipefail
echo "---> Go Buildpack"
# 1. GET ARGS
layers_dir=$1
plan_path=$3
# shellcheck source=/dev/null
. generate-project.sh "${layers_dir}"
# shellcheck source=/dev/null
. generate-layers.sh "${layers_dir}"
generate_deps_layer build-deps
generate_deps_layer run-deps
# 2. DOWNLOAD go
generate_stack_layer go "${plan_path}" false
# shellcheck source=/dev/null
. init-stack
# 3 build target
target_layer_dir="${layers_dir}"/target
mkdir -p "${target_layer_dir}"/{bin,profile.d}
echo "---> Start building ${DRYCC_APP} version"
cp -rf "$(pwd)" "${target_layer_dir}"/source \
&& cd "${target_layer_dir}"/source \
&& go mod vendor \
&& go build -o "${target_layer_dir}/bin/${DRYCC_APP}" -v . \
&& cd - \
&& rm -rf "${target_layer_dir}"/source
cat >"${target_layer_dir}.toml" <<EOL
[types]
cache = true
build = true
launch = true
EOL
cat >"${target_layer_dir}/profile.d/target.sh" <<EOL
export PATH="${target_layer_dir}/bin:${PATH}"
EOL
generate-launch.sh "${layers_dir}"