Skip to content

Commit 1768d26

Browse files
committed
Fix file permissions
1 parent a635979 commit 1768d26

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

tools/docker/Dockerfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
FROM ubuntu:22.04
22

3+
# switch to root, let the entrypoint drop back to host user
4+
USER root
5+
36
ARG DEBIAN_FRONTEND=noninteractive
47

58
RUN : \
@@ -34,6 +37,13 @@ RUN : \
3437
&& rm -rf /var/lib/apt/lists/* \
3538
&& :
3639

40+
# install gosu for a better su+exec command
41+
ARG GOSU_VERSION=1.17
42+
RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
43+
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" \
44+
&& chmod +x /usr/local/bin/gosu \
45+
&& gosu nobody true
46+
3747
# To build the image for a branch or a tag of the lib-builder, pass --build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=name.
3848
# To build the image with a specific commit ID of lib-builder, pass --build-arg LIBBUILDER_CHECKOUT_REF=commit-id.
3949
# It is possibe to combine both, e.g.:
@@ -51,6 +61,7 @@ ARG LIBBUILDER_CLONE_SHALLOW_DEPTH=1
5161
ARG LIBBUILDER_TARGETS=all
5262

5363
ENV LIBBUILDER_PATH=/opt/esp/lib-builder
64+
ENV ARDUINO_PATH=/opt/esp/lib-builder/arduino-esp32
5465

5566
RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANCH_OR_TAG=$LIBBUILDER_CLONE_BRANCH_OR_TAG && \
5667
git clone --recursive \
@@ -67,10 +78,10 @@ RUN echo LIBBUILDER_CHECKOUT_REF=$LIBBUILDER_CHECKOUT_REF LIBBUILDER_CLONE_BRANC
6778
git submodule update --init --recursive; \
6879
fi
6980

70-
RUN cp $LIBBUILDER_PATH/tools/docker/entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh
81+
COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh
7182

7283
# Ccache is installed, enable it by default
7384
ENV IDF_CCACHE_ENABLE=1
7485

75-
WORKDIR $LIBBUILDER_PATH
76-
ENTRYPOINT [ "$LIBBUILDER_PATH/entrypoint.sh" ]
86+
WORKDIR /opt/esp/lib-builder
87+
ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ]

tools/docker/entrypoint.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,15 @@ then
1515
done
1616
fi
1717

18-
exec "$@"
18+
if [ "$(id -u)" = "0" ]; then
19+
groupadd -g ${HOST_UID} host_user
20+
useradd -m -u ${HOST_UID} -g ${HOST_UID} host_user
21+
chown -R ${HOST_UID}:${HOST_UID} /arduino-esp32
22+
chown -R ${HOST_UID}:${HOST_UID} /opt/esp
23+
24+
# Add call to gosu to drop from root user to host_user
25+
# when running original entrypoint
26+
set -- gosu host_user "$@" -c /arduino-esp32
27+
fi
28+
29+
exec "$@" -c /arduino-esp32

0 commit comments

Comments
 (0)