Skip to content

Commit 750c991

Browse files
committed
Fix bugs and add run script
1 parent 1768d26 commit 750c991

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

tools/docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ ENV IDF_CCACHE_ENABLE=1
8585

8686
WORKDIR /opt/esp/lib-builder
8787
ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ]
88+
CMD [ "bash" ]

tools/docker/entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@ then
1515
done
1616
fi
1717

18-
if [ "$(id -u)" = "0" ]; then
18+
if [ "$(id -u)" = "0" ] && [ -n "${HOST_UID}" ]; then
1919
groupadd -g ${HOST_UID} host_user
2020
useradd -m -u ${HOST_UID} -g ${HOST_UID} host_user
21-
chown -R ${HOST_UID}:${HOST_UID} /arduino-esp32
21+
22+
if [ -d /arduino-esp32 ]; then
23+
chown -R ${HOST_UID}:${HOST_UID} /arduino-esp32
24+
fi
25+
2226
chown -R ${HOST_UID}:${HOST_UID} /opt/esp
2327

2428
# Add call to gosu to drop from root user to host_user
2529
# when running original entrypoint
26-
set -- gosu host_user "$@" -c /arduino-esp32
30+
set -- gosu host_user "$@"
2731
fi
2832

29-
exec "$@" -c /arduino-esp32
33+
exec "$@"

tools/docker/run.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
i=0
4+
NEXT_ARG="false"
5+
ARDUINO_DIR=""
6+
DOCKER_ARGS=()
7+
ORIGINAL_ARGS=("$@")
8+
TRIMMED_ARGS=()
9+
10+
while [ $i -lt ${#ORIGINAL_ARGS[@]} ]; do
11+
arg=${ORIGINAL_ARGS[$i]}
12+
if [ $arg == "-c" ]; then
13+
NEXT_ARG="true"
14+
elif [ $NEXT_ARG == "true" ]; then
15+
ARDUINO_DIR=$arg
16+
NEXT_ARG="false"
17+
else
18+
TRIMMED_ARGS+=($arg)
19+
fi
20+
i=$((i + 1))
21+
done
22+
23+
if [ -n "$ARDUINO_DIR" ]; then
24+
if [ ! -d "$ARDUINO_DIR" ]; then
25+
echo "Arduino directory \"$ARDUINO_DIR\" does not exist"
26+
exit 1
27+
fi
28+
ARDUINO_DIR=$(echo $(cd $ARDUINO_DIR; pwd))
29+
DOCKER_ARGS+=(-v $ARDUINO_DIR:/arduino-esp32)
30+
TRIMMED_ARGS+=(-c /arduino-esp32)
31+
fi
32+
33+
DOCKER_ARGS+=(-e HOST_UID=$UID)
34+
35+
if [ -n "$LIBBUILDER_GIT_SAFE_DIR" ]; then
36+
DOCKER_ARGS+=(-e LIBBUILDER_GIT_SAFE_DIR=$LIBBUILDER_GIT_SAFE_DIR)
37+
fi
38+
39+
if [ "$VERBOSE_OUTPUT" -eq 1 ]; then
40+
echo "Arguments:"
41+
echo "DOCKER_ARGS = ${DOCKER_ARGS[@]}"
42+
echo "TRIMMED_ARGS = ${TRIMMED_ARGS[@]}"
43+
echo "Running: docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}"
44+
fi
45+
46+
docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder ./build.sh ${TRIMMED_ARGS[@]}

0 commit comments

Comments
 (0)