-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·31 lines (23 loc) · 1.07 KB
/
docker-build.sh
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
#!/bin/bash
set -euxo pipefail
cd "$(dirname "$0")"
channel="${1:-stable}" # can be overriden with "bullseye" for example
target=growatt_exporter
container=${target}-builder-${channel}
volume=/root/HOST
cc=clang
if [ -z "${FAST:-}" ]; then
docker pull "debian:${channel}"
[ "$(docker ps -qaf "name=${container}")" ] || docker run --name "$container" --detach --tty --volume "${PWD}:${volume}" --network host "debian:${channel}"
docker start "$container"
docker exec "$container" dpkg --configure -a
docker exec "$container" apt-get update
docker exec "$container" apt-get upgrade -y
docker exec "$container" apt-get install -y $cc
docker exec "$container" apt-get install -y make pkg-config
docker exec "$container" apt-get install -y libbsd-dev libconfig-dev libmodbus-dev libmosquitto-dev
docker exec "$container" apt-get autoremove -y --purge
fi
docker exec --workdir "${volume}" "$container" rm -fv $target
docker exec --workdir "${volume}" "$container" env CC=$cc make $target
docker exec --workdir "${volume}" "$container" ls -l $target