Skip to content

Commit e98f227

Browse files
committed
Fix docker image
1 parent d87db7d commit e98f227

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

tools/config_editor/app.py

+9
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class ConfigEditorApp(App):
103103
# Options to be set by the command line arguments
104104
setting_target = ""
105105
setting_arduino_path = ""
106+
setting_arduino_permissions = ""
106107
setting_arduino_branch = ""
107108
setting_idf_branch = ""
108109
setting_idf_commit = ""
@@ -199,6 +200,13 @@ def main() -> None:
199200
required=False,
200201
help="Path to arduino-esp32 directory. Default: " + arduino_default_path())
201202

203+
parser.add_argument("-p", "--arduino-permissions",
204+
metavar="<uid:gid>",
205+
type=str,
206+
default="",
207+
required=False,
208+
help=argparse.SUPPRESS) # Hidden option. It is only supposed to be used by the docker container
209+
202210
parser.add_argument("-A", "--arduino-branch",
203211
metavar="<arduino branch>",
204212
type=str,
@@ -267,6 +275,7 @@ def main() -> None:
267275

268276
# Set the other options
269277
app.setting_arduino_path = os.path.abspath(args.arduino_path)
278+
app.setting_arduino_permissions = args.arduino_permissions
270279
app.setting_arduino_branch = args.arduino_branch
271280
app.setting_idf_branch = args.idf_branch
272281
app.setting_idf_commit = args.idf_commit

tools/config_editor/compile.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
import subprocess
33
import os
4+
import re
45

56
from rich.console import RenderableType
67

@@ -138,6 +139,20 @@ def compile_libs(self) -> None:
138139
print("Error reading child process errors: " + str(e))
139140
label.update("Compilation failed for " + target)
140141
else:
142+
regex = r"^[1-9][0-9]*:[1-9][0-9]*$" # Regex to match the line:column format
143+
if self.app.setting_arduino_permissions and re.match(regex, self.app.setting_arduino_permissions):
144+
chown_process = None
145+
try:
146+
chown_process = subprocess.run(["chown", "-R", self.app.setting_arduino_permissions, self.app.setting_arduino_path])
147+
except Exception as e:
148+
print("Error changing permissions: " + str(e))
149+
150+
if chown_process and chown_process.returncode != 0:
151+
self.print_error("Error changing permissions.")
152+
self.print_error("Please change the ownership of generated files manually")
153+
else:
154+
self.print_success("Permissions changed successfully")
155+
141156
self.print_success("Compilation successful for " + target)
142157
label.update("Compilation successful for " + target)
143158

tools/docker/Dockerfile

+1-9
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ RUN : \
3737
&& rm -rf /var/lib/apt/lists/* \
3838
&& :
3939

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-
4740
# To build the image for a branch or a tag of the lib-builder, pass --build-arg LIBBUILDER_CLONE_BRANCH_OR_TAG=name.
4841
# To build the image with a specific commit ID of lib-builder, pass --build-arg LIBBUILDER_CHECKOUT_REF=commit-id.
4942
# It is possibe to combine both, e.g.:
@@ -60,7 +53,6 @@ ARG LIBBUILDER_CLONE_SHALLOW_DEPTH=1
6053
ARG LIBBUILDER_TARGETS=all
6154

6255
ENV LIBBUILDER_PATH=/opt/esp/lib-builder
63-
ENV ARDUINO_PATH=/opt/esp/lib-builder/arduino-esp32
6456
# Ccache is installed, enable it by default
6557
ENV IDF_CCACHE_ENABLE=1
6658

@@ -83,4 +75,4 @@ COPY entrypoint.sh $LIBBUILDER_PATH/entrypoint.sh
8375

8476
WORKDIR /opt/esp/lib-builder
8577
ENTRYPOINT [ "/opt/esp/lib-builder/entrypoint.sh" ]
86-
CMD [ "python3", "tools/config_editor/app.py" ]
78+
CMD [ "python3", "tools/config_editor/app.py", "-c", "/arduino-esp32" ]

tools/docker/entrypoint.sh

+4-14
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,9 @@ then
1515
done
1616
fi
1717

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

28-
# Add call to gosu to drop from root user to host_user
29-
# when running original entrypoint
30-
set -- gosu host_user "$@"
20+
if [ -d /arduino-esp32 ]; then
21+
echo "Fixing permissions on /arduino-esp32"
22+
chown -R `stat -c "%u:%g" /arduino-esp32` /arduino-esp32
3123
fi
32-
33-
exec "$@"

0 commit comments

Comments
 (0)