-
Notifications
You must be signed in to change notification settings - Fork 5
/
docker-build
executable file
·81 lines (62 loc) · 1.57 KB
/
docker-build
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
#!/usr/bin/env bash
# vim: ft=bash
# Build cycles-ledger.wasm.gz inside docker. This outputs a single
# file, cycles-ledger.wasm.gz, in the top-level directory.
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 cycles-ledger Ledger inside Docker"
}
function usage() {
cat << EOF
Usage:
$0 [<output_dir>]
<output_dir>: (optional) the directory where cycles-ledger.wasm.gz will be put. If unset then the root of the project is used.
EOF
}
function help() {
cat << EOF
This will create (and override) "<output_dir>/cycles-ledger.wasm.gz".
EOF
}
## Building
function build() {
outdir="$1"
image_name="cycles-ledger"
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" --progress plain
set +x
echo "Copying build output from $tmp_outdir to $PWD"
mkdir -p "$(dirname ${outdir})"
cp "$tmp_outdir/cycles-ledger.wasm.gz" "$outdir"
echo "Removing $tmp_outdir"
rm -rf "$tmp_outdir"
}
# ARGUMENT PARSING
if [[ $# -gt 1 ]]; then
>&2 echo "Too many arguments"
usage
echo
exit 1
fi
OUTDIR="."
while [[ $# -gt 0 ]]; do
case $1 in
-h|--help)
title
usage
help
exit 0
;;
*)
OUTDIR="$1"
shift
;;
esac
done
build "$OUTDIR"