balena-cloud-apps 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/README.md +4 -4
- package/aarch64.env +1 -1
- package/armhf.env +1 -1
- package/package.json +1 -1
- package/test/build/aarch64.env +1 -1
- package/test/build/armhf.env +1 -1
- package/test/build/submodule/Dockerfile.aarch64 +3 -3
- package/test/build/submodule/Dockerfile.armhf +3 -3
- package/test/build/submodule/Dockerfile.template +3 -3
- package/test/build/submodule/Dockerfile.x86_64 +3 -3
- package/test/build/x86_64.env +1 -1
- package/test/build-test.sh +10 -10
- package/vendor/cni/auto_reboot.sh +1 -1
- package/vendor/cni/balena_deploy.sh +41 -41
- package/vendor/cni/docker_build.sh +9 -9
- package/vendor/cni/init_functions.sh +1 -1
- package/vendor/cni/post_install.sh +1 -1
- package/x86_64.env +1 -1
package/.gitattributes
CHANGED
package/README.md
CHANGED
|
@@ -22,15 +22,15 @@ Initialize .env and package.json:
|
|
|
22
22
|
|
|
23
23
|
### Configure template environment
|
|
24
24
|
|
|
25
|
-
Complete common definitions:
|
|
25
|
+
Complete common definitions (leading and trailing ( spaces ) when defining arrays !!):
|
|
26
26
|
```common.env
|
|
27
|
-
BALENA_PROJECTS=(MY/PATH MY/RELATIVE/PATH)
|
|
28
|
-
BALENA_PROJECTS_FLAGS=(BALENA_MACHINE_NAME MY_VARIABLE)
|
|
27
|
+
BALENA_PROJECTS=( MY/PATH MY/RELATIVE/PATH )
|
|
28
|
+
BALENA_PROJECTS_FLAGS=( BALENA_MACHINE_NAME MY_VARIABLE )
|
|
29
29
|
```
|
|
30
30
|
Define architectures:
|
|
31
31
|
An ARM computer units like Raspberry PI use `armhf.env` (or `aarch64.env` if it's deployed on a 64 bits platform), desktop units are often `x86_64.env`:
|
|
32
32
|
```x86_64.env
|
|
33
|
-
|
|
33
|
+
BALENA_ARCH=x86_64
|
|
34
34
|
BALENA_MACHINE_NAME=intel-nuc
|
|
35
35
|
IMG_TAG=latest
|
|
36
36
|
PRIMARY_HUB=docker-hub-balenalib-repo\\/container-servìce-image
|
package/aarch64.env
CHANGED
package/armhf.env
CHANGED
package/package.json
CHANGED
package/test/build/aarch64.env
CHANGED
package/test/build/armhf.env
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
ARG BALENA_MACHINE_NAME
|
|
2
2
|
FROM balenalib/${BALENA_MACHINE_NAME:-generic-aarch64}:latest
|
|
3
|
-
ARG
|
|
4
|
-
ENV
|
|
3
|
+
ARG BALENA_ARCH
|
|
4
|
+
ENV BALENA_ARCH ${BALENA_ARCH:-aarch64}
|
|
5
5
|
RUN ["cross-build-start"]
|
|
6
6
|
|
|
7
|
-
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$
|
|
7
|
+
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$BALENA_ARCH"
|
|
8
8
|
|
|
9
9
|
RUN ["cross-build-end"]
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
ARG BALENA_MACHINE_NAME
|
|
2
2
|
FROM balenalib/${BALENA_MACHINE_NAME:-raspberrypi3}:latest
|
|
3
|
-
ARG
|
|
4
|
-
ENV
|
|
3
|
+
ARG BALENA_ARCH
|
|
4
|
+
ENV BALENA_ARCH ${BALENA_ARCH:-armhf}
|
|
5
5
|
RUN ["cross-build-start"]
|
|
6
6
|
|
|
7
|
-
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$
|
|
7
|
+
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$BALENA_ARCH"
|
|
8
8
|
|
|
9
9
|
RUN ["cross-build-end"]
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
ARG BALENA_MACHINE_NAME
|
|
2
2
|
FROM balenalib/${BALENA_MACHINE_NAME:-raspberrypi3}:latest
|
|
3
|
-
ARG
|
|
4
|
-
ENV
|
|
3
|
+
ARG BALENA_ARCH
|
|
4
|
+
ENV BALENA_ARCH ${BALENA_ARCH:-armhf}
|
|
5
5
|
# RUN ["cross-build-start"]
|
|
6
6
|
|
|
7
|
-
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$
|
|
7
|
+
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$BALENA_ARCH"
|
|
8
8
|
|
|
9
9
|
# RUN ["cross-build-end"]
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
ARG BALENA_MACHINE_NAME
|
|
2
2
|
FROM balenalib/${BALENA_MACHINE_NAME:-intel-nuc}:latest
|
|
3
|
-
ARG
|
|
4
|
-
ENV
|
|
3
|
+
ARG BALENA_ARCH
|
|
4
|
+
ENV BALENA_ARCH ${BALENA_ARCH:-x86_64}
|
|
5
5
|
# RUN ["cross-build-start"]
|
|
6
6
|
|
|
7
|
-
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$
|
|
7
|
+
RUN printf "* %s VM, %s IMAGE" "$(arch)" "$BALENA_ARCH"
|
|
8
8
|
|
|
9
9
|
# RUN ["cross-build-end"]
|
|
10
10
|
|
package/test/build/x86_64.env
CHANGED
package/test/build-test.sh
CHANGED
|
@@ -9,47 +9,47 @@ LOG=$(new_log "/tmp")
|
|
|
9
9
|
[ "$DEBUG" ] && LOG=$(new_log "/dev" "/stderr")
|
|
10
10
|
function test_deploy() {
|
|
11
11
|
# x86_64
|
|
12
|
-
args=("3" --nobuild --exit)
|
|
12
|
+
args=( "3" --nobuild --exit )
|
|
13
13
|
# shellcheck disable=SC1090
|
|
14
14
|
. "$vendord/balena_deploy.sh" "$testd" "${args[@]}" >> "$LOG"
|
|
15
15
|
grep -q "intel-nuc" < "$testd/submodule/Dockerfile.x86_64"
|
|
16
16
|
}
|
|
17
17
|
function test_deploy_2() {
|
|
18
18
|
# aarch64
|
|
19
|
-
args=("2" --nobuild --exit)
|
|
19
|
+
args=( "2" --nobuild --exit )
|
|
20
20
|
# shellcheck disable=SC1090
|
|
21
21
|
. "$vendord/balena_deploy.sh" "$testd" "${args[@]}" >> "$LOG"
|
|
22
22
|
grep -q "generic-aarch64" < "$testd/submodule/Dockerfile.aarch64"
|
|
23
23
|
}
|
|
24
24
|
function test_deploy_3() {
|
|
25
25
|
# armhf
|
|
26
|
-
args=("1" --nobuild --exit)
|
|
26
|
+
args=( "1" --nobuild --exit )
|
|
27
27
|
# shellcheck disable=SC1090
|
|
28
28
|
. "$vendord/balena_deploy.sh" "$testd" "${args[@]}" >> "$LOG"
|
|
29
29
|
grep -q "raspberrypi3" < "$testd/submodule/Dockerfile.armhf"
|
|
30
30
|
}
|
|
31
31
|
function test_docker_3() {
|
|
32
|
-
args=("${testd}/submodule" -m . "betothreeprod/raspberrypi3" "$
|
|
32
|
+
args=( "${testd}/submodule" -m . "betothreeprod/raspberrypi3" "$BALENA_ARCH" )
|
|
33
33
|
# shellcheck disable=SC1090
|
|
34
34
|
. "$vendord/docker_build.sh" "${args[@]}" >> "$LOG"
|
|
35
35
|
docker image ls -q "${args[3]}*"
|
|
36
36
|
}
|
|
37
37
|
function test_docker() {
|
|
38
|
-
args=("${testd}/deployment/images/dind-php7" -m . "betothreeprod/dind-php7" "$
|
|
38
|
+
args=( "${testd}/deployment/images/dind-php7" -m . "betothreeprod/dind-php7" "$BALENA_ARCH" )
|
|
39
39
|
# shellcheck disable=SC1090
|
|
40
40
|
. "$vendord/docker_build.sh" "${args[@]}" >> "$LOG"
|
|
41
41
|
docker image ls -q "${args[3]}*"
|
|
42
42
|
}
|
|
43
43
|
test_deploy
|
|
44
|
-
results=("$?")
|
|
44
|
+
results=( "$?" )
|
|
45
45
|
test_docker
|
|
46
|
-
results+=("$?")
|
|
46
|
+
results+=( "$?" )
|
|
47
47
|
test_deploy_2
|
|
48
|
-
results+=("$?")
|
|
48
|
+
results+=( "$?" )
|
|
49
49
|
test_deploy_3
|
|
50
|
-
results+=("$?")
|
|
50
|
+
results+=( "$?" )
|
|
51
51
|
test_docker_3
|
|
52
|
-
results+=("$?")
|
|
52
|
+
results+=( "$?" )
|
|
53
53
|
[ "$chkSet" = 'x' ] && unset DEBIAN_FRONTEND || DEBIAN_FRONTEND=${chkSet:2}
|
|
54
54
|
check_log "$LOG"
|
|
55
55
|
|
|
@@ -30,7 +30,7 @@ DAEMON_SVC="/usr/lib/systemd/system/$SVC_NAME.service.d/"
|
|
|
30
30
|
[ -f $DAEMON_CF ] || touch "$DAEMON_CF"
|
|
31
31
|
[ -d $DAEMON_SVC ] || mkdir -p "$DAEMON_SVC"
|
|
32
32
|
|
|
33
|
-
banner=("" "[services.d] $DAEMON_SVC" ""); log_daemon_msg "%s\n" "${banner[@]}"
|
|
33
|
+
banner=( "" "[services.d] $DAEMON_SVC" "" ); log_daemon_msg "%s\n" "${banner[@]}"
|
|
34
34
|
|
|
35
35
|
DAEMON_CF="$DAEMON_CF $(find "$DAEMON_SVC" -name "*.conf")"
|
|
36
36
|
for cnf in $DAEMON_CF; do
|
|
@@ -3,7 +3,7 @@ set +u
|
|
|
3
3
|
[ "$#" -eq 0 ] && echo "usage $0 <project_root|\${BASH_SOURCE[0]}> <args>" && exit 0
|
|
4
4
|
[ -f "$1" ] && set -- "$(cd "$(dirname "$1")" && pwd)" "${@:2}"
|
|
5
5
|
project_root="$(cd "$1" && pwd)"; shift
|
|
6
|
-
banner=("" "[$0] BASH ${BASH_SOURCE[0]}" "$project_root" ""); printf "%s\n" "${banner[@]}"
|
|
6
|
+
banner=( "" "[$0] BASH ${BASH_SOURCE[0]}" "$project_root" "" ); printf "%s\n" "${banner[@]}"
|
|
7
7
|
|
|
8
8
|
# shellcheck source=init_functions.sh
|
|
9
9
|
. "$(command -v init_functions)" "${BASH_SOURCE[0]}"
|
|
@@ -31,13 +31,13 @@ usage=("" \
|
|
|
31
31
|
" 6,--build-deps Deployment images dependencies build." \
|
|
32
32
|
" 0,--exit Quit script (non interactive)." \
|
|
33
33
|
"" \
|
|
34
|
-
"Deployment images Set BALENA_PROJECTS=(./dir_one ./dir_two ./dir_three)" \
|
|
34
|
+
"Deployment images Set BALENA_PROJECTS=( ./dir_one ./dir_two ./dir_three )" \
|
|
35
35
|
" in common.env file." \
|
|
36
|
-
"Variable filters Set BALENA_PROJECTS_FLAGS=(VAR_ONE VAR_TWO)" \
|
|
36
|
+
"Variable filters Set BALENA_PROJECTS_FLAGS=( VAR_ONE VAR_TWO )" \
|
|
37
37
|
" in common.env" \
|
|
38
38
|
"")
|
|
39
39
|
arch=${1:-''}
|
|
40
|
-
saved=("${@:2}")
|
|
40
|
+
saved=( "${@:2}" )
|
|
41
41
|
while true; do
|
|
42
42
|
case $arch in
|
|
43
43
|
1|arm32*|armv7l|armhf)
|
|
@@ -52,7 +52,7 @@ while true; do
|
|
|
52
52
|
*)
|
|
53
53
|
printf "%s\n" "${usage[@]}"
|
|
54
54
|
if [ "${DEBIAN_FRONTEND:-}" = 'noninteractive' ]; then
|
|
55
|
-
arch=$(grep "
|
|
55
|
+
arch=$(grep "BALENA_ARCH" < "$project_root/.env"| cut -d= -f2)
|
|
56
56
|
else
|
|
57
57
|
read -rp "Set docker machine architecture ARM32, ARM64 bits or X86-64 (choose 1, 2 or 3) ? " arch
|
|
58
58
|
fi
|
|
@@ -60,28 +60,28 @@ while true; do
|
|
|
60
60
|
esac
|
|
61
61
|
log_progress_msg "Architecture $arch was selected"
|
|
62
62
|
done
|
|
63
|
-
|
|
64
|
-
[ ! -f "$project_root/${
|
|
65
|
-
ln -vsf "$project_root/${
|
|
63
|
+
BALENA_ARCH=${arch}
|
|
64
|
+
[ ! -f "$project_root/${BALENA_ARCH}.env" ] && log_failure_msg "Missing arch file ${BALENA_ARCH}.env" && exit 1
|
|
65
|
+
ln -vsf "$project_root/${BALENA_ARCH}.env" "$project_root/.env" >> "$LOG"
|
|
66
66
|
# shellcheck disable=SC1090
|
|
67
67
|
. "$project_root/.env" && . "$project_root/common.env"
|
|
68
68
|
### ADD ANY ENVIRONMENT VARIABLE TO BALENA_PROJECTS_FLAGS
|
|
69
|
-
flags=()
|
|
69
|
+
flags=( )
|
|
70
70
|
if [ -n "$BALENA_PROJECTS_FLAGS" ]; then
|
|
71
71
|
log_daemon_msg "Found ${#BALENA_PROJECTS_FLAGS[@]} flags set BALENA_PROJECTS_FLAGS" >> "$LOG"
|
|
72
|
-
flags=("${BALENA_PROJECTS_FLAGS[@]}")
|
|
72
|
+
flags=( "${BALENA_PROJECTS_FLAGS[@]}" )
|
|
73
73
|
fi
|
|
74
74
|
function setArch() {
|
|
75
75
|
while [ "$#" -gt 1 ]; do
|
|
76
76
|
cat /dev/null > "$1.sed"
|
|
77
77
|
sed=("s/%%BALENA_MACHINE_NAME%%/${BALENA_MACHINE_NAME}/g" \
|
|
78
|
-
"s/(Dockerfile\.)[^\.]*/\\1${
|
|
79
|
-
"s/%%BALENA_ARCH%%/${
|
|
80
|
-
"s/(
|
|
78
|
+
"s/(Dockerfile\.)[^\.]*/\\1${BALENA_ARCH}/g" \
|
|
79
|
+
"s/%%BALENA_ARCH%%/${BALENA_ARCH}/g" \
|
|
80
|
+
"s/(BALENA_ARCH[=:-]+)[^\$ }]+/\\1${BALENA_ARCH}/g" )
|
|
81
81
|
printf "%s\n" "${sed[@]}" >> "$1.sed"
|
|
82
82
|
for flag in "${flags[@]}"; do
|
|
83
83
|
flag_val=$(eval "echo \${$flag}")
|
|
84
|
-
sed=("s#(${flag}[=:-]+)[^\$ }]+#\\1${flag_val}#g" \
|
|
84
|
+
sed=( "s#(${flag}[=:-]+)[^\$ }]+#\\1${flag_val}#g" \
|
|
85
85
|
"s#%%${flag}%%#${flag_val}#g" )
|
|
86
86
|
printf "%s\n" "${sed[@]}" >> "$1.sed"
|
|
87
87
|
done
|
|
@@ -89,16 +89,16 @@ function setArch() {
|
|
|
89
89
|
shift 2; done
|
|
90
90
|
}
|
|
91
91
|
### ADD ANY SUBMODULE DOCKER IMAGE / SERVICE TO BALENA_PROJECTS
|
|
92
|
-
projects=(".")
|
|
92
|
+
projects=( "." )
|
|
93
93
|
if [ "${#BALENA_PROJECTS[@]}" -gt 0 ]; then
|
|
94
94
|
log_daemon_msg "Found ${#BALENA_PROJECTS[@]} projects set BALENA_PROJECTS" >> "$LOG"
|
|
95
|
-
projects=("${BALENA_PROJECTS[@]}")
|
|
95
|
+
projects=( "${BALENA_PROJECTS[@]}" )
|
|
96
96
|
fi
|
|
97
97
|
function deploy_deps() {
|
|
98
|
-
mapfile -t dock < <(find "${project_root}/deployment/images" -name "Dockerfile.${
|
|
98
|
+
mapfile -t dock < <(find "${project_root}/deployment/images" -name "Dockerfile.${BALENA_ARCH}")
|
|
99
99
|
for d in "${dock[@]}"; do
|
|
100
100
|
dir=$(dirname "$d")
|
|
101
|
-
docker_build "$dir" "." "$DOCKER_USER/$(basename "$dir")" "${
|
|
101
|
+
docker_build "$dir" "." "$DOCKER_USER/$(basename "$dir")" "${BALENA_ARCH}"
|
|
102
102
|
done
|
|
103
103
|
}
|
|
104
104
|
### ADD HERE ### A MARKER STARTS... ### A MARKER ENDS
|
|
@@ -123,8 +123,8 @@ function comment() {
|
|
|
123
123
|
echo "/${ARM_BEGIN}/,/${ARM_END}/s/^[# ]*(.*)/# \\1/g" >> "$file.sed"
|
|
124
124
|
;;
|
|
125
125
|
-c*|--cross)
|
|
126
|
-
sed=("s/[# ]*(${MARK_BEGIN})/# \\1/g" \
|
|
127
|
-
"s/[# ]*(${MARK_END})/# \\1/g")
|
|
126
|
+
sed=( "s/[# ]*(${MARK_BEGIN})/# \\1/g" \
|
|
127
|
+
"s/[# ]*(${MARK_END})/# \\1/g" )
|
|
128
128
|
printf "%s\n" "${sed[@]}" >> "$file.sed"
|
|
129
129
|
;;
|
|
130
130
|
esac; shift; done;
|
|
@@ -143,8 +143,8 @@ function uncomment() {
|
|
|
143
143
|
echo "/${ARM_BEGIN}/,/${ARM_END}/s/^(# )+(.*)/\\2/g" >> "$file.sed"
|
|
144
144
|
;;
|
|
145
145
|
-c*|--cross)
|
|
146
|
-
sed=("s/(# )+(${MARK_BEGIN})/\\2/g" \
|
|
147
|
-
"s/(# )+(${MARK_END})/\\2/g")
|
|
146
|
+
sed=( "s/(# )+(${MARK_BEGIN})/\\2/g" \
|
|
147
|
+
"s/(# )+(${MARK_END})/\\2/g" )
|
|
148
148
|
printf "%s\n" "${sed[@]}" >> "$file.sed"
|
|
149
149
|
;;
|
|
150
150
|
esac; shift; done;
|
|
@@ -166,31 +166,31 @@ function cross_build_start() {
|
|
|
166
166
|
log_progress_msg "$MARK_BEGIN" >> "$LOG"
|
|
167
167
|
fi
|
|
168
168
|
for d in "${projects[@]}"; do
|
|
169
|
-
ln -vsf "$project_root/${
|
|
169
|
+
ln -vsf "$project_root/${BALENA_ARCH}.env" "$project_root/$d/.env" >> "$LOG"
|
|
170
170
|
[ "$(cd "$project_root/$d" && pwd)" != "$(pwd)" ] && ln -vsf "$project_root/common.env" "$project_root/$d/common.env" >> "$LOG"
|
|
171
|
-
setArch "$project_root/$d/Dockerfile.template" "$project_root/$d/Dockerfile.${
|
|
171
|
+
setArch "$project_root/$d/Dockerfile.template" "$project_root/$d/Dockerfile.${BALENA_ARCH}"
|
|
172
172
|
if [ "$crossbuild" = 0 ]; then
|
|
173
173
|
if [ "$arch" != "x86_64" ]; then
|
|
174
|
-
comment "$project_root/$d/Dockerfile.${
|
|
175
|
-
uncomment "$project_root/$d/Dockerfile.${
|
|
176
|
-
uncomment "$project_root/docker-compose.${
|
|
174
|
+
comment "$project_root/$d/Dockerfile.${BALENA_ARCH}" -c
|
|
175
|
+
uncomment "$project_root/$d/Dockerfile.${BALENA_ARCH}" -a
|
|
176
|
+
uncomment "$project_root/docker-compose.${BALENA_ARCH}" -a
|
|
177
177
|
else
|
|
178
|
-
comment "$project_root/$d/Dockerfile.${
|
|
179
|
-
comment "$project_root/docker-compose.${
|
|
178
|
+
comment "$project_root/$d/Dockerfile.${BALENA_ARCH}"
|
|
179
|
+
comment "$project_root/docker-compose.${BALENA_ARCH}"
|
|
180
180
|
fi
|
|
181
181
|
else
|
|
182
182
|
if [ "$arch" != "x86_64" ]; then
|
|
183
|
-
uncomment "$project_root/docker-compose.${
|
|
184
|
-
uncomment "$project_root/$d/Dockerfile.${
|
|
183
|
+
uncomment "$project_root/docker-compose.${BALENA_ARCH}"
|
|
184
|
+
uncomment "$project_root/$d/Dockerfile.${BALENA_ARCH}"
|
|
185
185
|
else
|
|
186
|
-
comment "$project_root/docker-compose.${
|
|
187
|
-
comment "$project_root/$d/Dockerfile.${
|
|
186
|
+
comment "$project_root/docker-compose.${BALENA_ARCH}"
|
|
187
|
+
comment "$project_root/$d/Dockerfile.${BALENA_ARCH}"
|
|
188
188
|
fi
|
|
189
189
|
fi
|
|
190
|
-
[ "$(cd "$project_root/$d" && pwd)" != "$(pwd)" ] && cd "$project_root/$d" && git_commit "${
|
|
190
|
+
[ "$(cd "$project_root/$d" && pwd)" != "$(pwd)" ] && cd "$project_root/$d" && git_commit "${BALENA_ARCH} pushed ${d}"
|
|
191
191
|
cd "$project_root" || return
|
|
192
192
|
done
|
|
193
|
-
git_commit "${
|
|
193
|
+
git_commit "${BALENA_ARCH} pushed"
|
|
194
194
|
}
|
|
195
195
|
function git_commit() {
|
|
196
196
|
if ! git config user.email > /dev/null; then
|
|
@@ -202,16 +202,16 @@ function git_commit() {
|
|
|
202
202
|
}
|
|
203
203
|
function native_compose_file_set() {
|
|
204
204
|
if [ "$#" -gt 0 ]; then
|
|
205
|
-
setArch "$project_root/docker-compose.template" "$project_root/docker-compose.${
|
|
205
|
+
setArch "$project_root/docker-compose.template" "$project_root/docker-compose.${BALENA_ARCH}"
|
|
206
206
|
cp -vf "$project_root/docker-compose.$1" "$project_root/docker-compose.yml"
|
|
207
207
|
else
|
|
208
|
-
native_compose_file_set "${
|
|
208
|
+
native_compose_file_set "${BALENA_ARCH}"
|
|
209
209
|
fi
|
|
210
210
|
}
|
|
211
211
|
function balena_push() {
|
|
212
|
-
apps=("$#")
|
|
212
|
+
apps=( "$#" )
|
|
213
213
|
i=0
|
|
214
|
-
[ "$#" -gt 0 ] && for a in "$@"; do apps+=("$a"); done
|
|
214
|
+
[ "$#" -gt 0 ] && for a in "$@"; do apps+=( "$a" ); done
|
|
215
215
|
for a in "${!apps[@]}"; do
|
|
216
216
|
[ "$a" = 0 ] && continue
|
|
217
217
|
printf "[%s]: %s " "$a" "${apps[$a]}"
|
|
@@ -246,11 +246,11 @@ while true; do
|
|
|
246
246
|
4|--docker)
|
|
247
247
|
slogger -st docker "Allow cross-build"
|
|
248
248
|
cross_build_start
|
|
249
|
-
file=docker-compose.${
|
|
249
|
+
file=docker-compose.${BALENA_ARCH}
|
|
250
250
|
if [ -f "$file" ]; then
|
|
251
251
|
bash -c "docker-compose -f $file --host ${DOCKER_HOST:-''} build" >> "$LOG"
|
|
252
252
|
else
|
|
253
|
-
bash -c "docker build -f Dockerfile.${
|
|
253
|
+
bash -c "docker build -f Dockerfile.${BALENA_ARCH} . && docker ps" >> "$LOG"
|
|
254
254
|
fi
|
|
255
255
|
;;
|
|
256
256
|
2|--balena)
|
|
@@ -3,21 +3,21 @@ set -u
|
|
|
3
3
|
[ "$#" -eq 0 ] && echo "usage $0 <work_dir> <args>" && exit 0
|
|
4
4
|
[ -f "$1" ] && set -- "$(cd "$(dirname "$1")" && pwd)" "${@:2}"
|
|
5
5
|
workd="$(cd "$1" && pwd)"; shift
|
|
6
|
-
banner=("" "[$0] BASH ${BASH_SOURCE[0]}" "$workd" ""); printf "%s\n" "${banner[@]}"
|
|
6
|
+
banner=( "" "[$0] BASH ${BASH_SOURCE[0]}" "$workd" "" ); printf "%s\n" "${banner[@]}"
|
|
7
7
|
[ "${DEBUG:-0}" != 0 ] && printf "passed arg %s\n" "$*"
|
|
8
8
|
usage=("" \
|
|
9
|
-
"Usage: $0 [options] <work_sub_dir> <container_name> [
|
|
9
|
+
"Usage: $0 [options] <work_sub_dir> <container_name> [BALENA_ARCH]" \
|
|
10
10
|
" <-f, --force> <-e> <-m, --make-space>" \
|
|
11
11
|
"" \
|
|
12
12
|
" Base balenalib/raspberrypi3 images may be" \
|
|
13
13
|
" built from a Mac or PC without any specific" \
|
|
14
|
-
" cross-build backend, just set
|
|
14
|
+
" cross-build backend, just set BALENA_ARCH to ARM32" \
|
|
15
15
|
" or ARM64." \
|
|
16
16
|
"" \
|
|
17
17
|
" work_sub_dir: Path relative to $0" \
|
|
18
18
|
" container_name: Set to username/container to push to" \
|
|
19
19
|
" Docker.io, e.g. myself/cakephp2-image x86_64" \
|
|
20
|
-
"
|
|
20
|
+
" BALENA_ARCH: 1|arm32*|armv7l|armhf ARMv7 OS" \
|
|
21
21
|
" 2|arm64*|aarch64 ARMv8 OS" \
|
|
22
22
|
" 3|amd64|x86_64 All X86 64 bits" \
|
|
23
23
|
" OS (Mac or PC)" \
|
|
@@ -25,7 +25,7 @@ usage=("" \
|
|
|
25
25
|
" -e: Reset docker machine environment variables" \
|
|
26
26
|
" -m,--make-space: Remove exited containers to free some disk space" \
|
|
27
27
|
" TAG: Set as environment variable IMG_TAG" \
|
|
28
|
-
" File <
|
|
28
|
+
" File <BALENA_ARCH>.env" \
|
|
29
29
|
"More about docker tag:" \
|
|
30
30
|
" docker tag <repository/image:tag> <new_repository/new_image:tag>" \
|
|
31
31
|
"")
|
|
@@ -45,13 +45,13 @@ while [[ "$#" -gt 0 ]]; do case $1 in
|
|
|
45
45
|
*)
|
|
46
46
|
DIR="$1"
|
|
47
47
|
NAME=$(echo "$2" | cut -d: -f1)
|
|
48
|
-
|
|
48
|
+
BALENA_ARCH="$3"
|
|
49
49
|
shift 2
|
|
50
50
|
;;
|
|
51
51
|
esac; shift; done
|
|
52
52
|
# shellcheck disable=SC1090
|
|
53
53
|
. "${workd}/.env" && . "${workd}/common.env"
|
|
54
|
-
docker build -f "$workd/$DIR/Dockerfile.${
|
|
54
|
+
docker build -f "$workd/$DIR/Dockerfile.${BALENA_ARCH}" -t "$NAME:$IMG_TAG" "$workd/$DIR"
|
|
55
55
|
container=$(echo "$NAME" | cut -d/ -f2-)
|
|
56
56
|
docker run --rm -itd --name "$container" "$NAME:$IMG_TAG" &
|
|
57
57
|
sleep 2
|
|
@@ -59,5 +59,5 @@ container="$(docker ps -q -a -f "name=$container")"
|
|
|
59
59
|
[ "$container" ] && docker stop "$container"
|
|
60
60
|
docker login docker.io -u "${DOCKER_USER:-}" -p "${DOCKER_PASS:-}"
|
|
61
61
|
docker push "$NAME:$IMG_TAG"
|
|
62
|
-
docker tag "$NAME:$IMG_TAG" "$NAME:$IMG_TAG-${
|
|
63
|
-
docker push "$NAME:$IMG_TAG-${
|
|
62
|
+
docker tag "$NAME:$IMG_TAG" "$NAME:$IMG_TAG-${BALENA_ARCH}"
|
|
63
|
+
docker push "$NAME:$IMG_TAG-${BALENA_ARCH}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
[ "$#" -eq 0 ] && echo "usage $0 \${BASH_SOURCE[0]} <args>" && exit 0
|
|
3
|
-
banner=("" "[$0] BASH ${BASH_SOURCE[0]}" ""); printf "%s\n" "${banner[@]}"
|
|
3
|
+
banner=( "" "[$0] BASH ${BASH_SOURCE[0]}" "" ); printf "%s\n" "${banner[@]}"
|
|
4
4
|
function log_daemon_msg() {
|
|
5
5
|
printf "* %s\n" "$@"
|
|
6
6
|
}
|
|
@@ -7,6 +7,6 @@ read -r -a BALENA_PROJECTS < <(find . -name "Dockerfile*" | awk -F"/Dockerfile"
|
|
|
7
7
|
printf "Found %s BALENA_PROJECTS(" "${#BALENA_PROJECTS}"
|
|
8
8
|
printf "%s " "${BALENA_PROJECTS[@]}"
|
|
9
9
|
printf " )\n"
|
|
10
|
-
sed -i.old -E -e "s#(BALENA_PROJECTS)=(.*))#\\1=\(${BALENA_PROJECTS[*]}\) \#\\2#" common.env
|
|
10
|
+
sed -i.old -E -e "s#(BALENA_PROJECTS)=(.*))#\\1=\( ${BALENA_PROJECTS[*]} \) \#\\2#" common.env
|
|
11
11
|
cat common.env
|
|
12
12
|
printf "Ready to <( balena_deploy . \n"
|
package/x86_64.env
CHANGED