-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-build
More file actions
executable file
·89 lines (68 loc) · 1.63 KB
/
docker-build
File metadata and controls
executable file
·89 lines (68 loc) · 1.63 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# vim: ft=bash
# Build SOL RPC inside docker. This outputs sol_rpc_canister.wasm.gz.
set -euo pipefail
# Make sure we always run from the root
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPTS_DIR/.."
function title() {
echo "Build SOL RPC canister inside Docker"
}
function usage() {
cat << EOF
Usage:
$0
EOF
}
function help() {
cat << EOF
This will create (and override) "./sol_rpc_canister.wasm.gz".
EOF
}
## Building
function build() {
local canister="$1"
# image name and build args, made global because they're used in
# check_feature()
image_name="sol-rpc-docker-build"
docker_build_args=( --target "scratch_$canister" )
docker_build_args+=(--tag "$image_name" .)
echo "The following image name will be used: $image_name"
tmp_outdir=$(mktemp -d)
set -x
DOCKER_BUILDKIT=1 docker build \
"${docker_build_args[@]}" \
--output "$tmp_outdir"
set +x
echo "Copying build output from $tmp_outdir to $PWD/wasms"
cp "$tmp_outdir/$canister.wasm.gz" ./wasms/
echo "Removing $tmp_outdir"
rm -rf "$tmp_outdir"
}
# ARGUMENT PARSING
CANISTERS=()
while [[ $# -gt 0 ]]
do
case $1 in
-h|--help)
title
usage
help
exit 0
;;
*)
echo "ERROR: unknown argument $1"
usage
echo
echo "Use '$0 --help' for more information"
exit 1
;;
esac
done
if [ ${#CANISTERS[@]} -eq 0 ]; then
CANISTERS=("sol_rpc_canister")
fi
for canister in "${CANISTERS[@]}"
do
build "$canister"
done