Skip to content

Commit c9188a5

Browse files
devcontainers: Reduce maintenance workload, optimize docker build (#37997)
* devcontainers: Reduce maintenance workload, optimize docker build - optimize $AMEBA_PATH ownership and mode adjustment - drop duplicated $ANDROID_HOME path - autodetect current version number in build.sh removing the need for explicit bumps Signed-off-by: Maciej Grela <m.grela@samsung.com> * Restyled by shfmt * trigger rebuild, darwin job failure Signed-off-by: Maciej Grela <m.grela@samsung.com> * devcontainer: Do not rely on git rev-parse for CHIP_ROOT detection Signed-off-by: Maciej Grela <m.grela@samsung.com> --------- Signed-off-by: Maciej Grela <m.grela@samsung.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent e1ea4c6 commit c9188a5

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

.devcontainer/Dockerfile

+8-13
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,18 @@ RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/resty
5656

5757
RUN mkdir -p /opt/android/sdk \
5858
&& chown -R $USERNAME:$USERNAME \
59-
/opt/android/sdk `# NXP uses a patch_sdk script to change SDK files` \
6059
$ANDROID_HOME \
6160
$IDF_TOOLS_PATH \
62-
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
63-
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
64-
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
65-
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chown -R $USERNAME:$USERNAME \
66-
&& chmod -R +x \
67-
$ANDROID_HOME/cmdline-tools/10.0/bin `# sdkmanager for accepting licenses`\
61+
&& find $AMEBA_PATH \
62+
-name "inc_lp" -print0 -or \
63+
-name "inc_hp" -print0 -or \
64+
-name "project_lp" -print0 -or \
65+
-name "project_hp" -print0 \
66+
| xargs -0 -I {} sh -c 'chown -R $USERNAME:$USERNAME {}; chmod -R +w {}' \
67+
&& find $ANDROID_HOME/cmdline-tools/ -type d -name bin | xargs chmod -R +x `# sdkmanager for accepting licenses` \
6868
&& chmod -R +w \
6969
$IDF_TOOLS_PATH \
70-
&& find $AMEBA_PATH -name "inc_lp" -print0 | xargs -0 chmod -R +w \
71-
&& find $AMEBA_PATH -name "inc_hp" -print0 | xargs -0 chmod -R +w \
72-
&& find $AMEBA_PATH -name "project_lp" -print0 | xargs -0 chmod -R +w \
73-
&& find $AMEBA_PATH -name "project_hp" -print0 | xargs -0 chmod -R +w \
74-
# Safe directory is preferred over chown.
75-
&& git config --global --add safe.directory "*" \
70+
&& git config --global --add safe.directory "*" `# Safe directory is preferred over chown.` \
7671
&& :
7772

7873
# Fix Tizen SDK paths for new user

.devcontainer/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
HERE="$(dirname "$0")"
2020
CHIP_ROOT="$(realpath "$HERE"/..)"
21-
BUILD_VERSION="latest"
21+
BUILD_VERSION=$(sed 's/ .*//' "$CHIP_ROOT/integrations/docker/images/base/chip-build/version")
2222
IMAGE_TAG="matter-dev-environment:local"
2323
USER_UID=$UID
2424

@@ -32,7 +32,7 @@ Options:
3232
-h,--help Show this help
3333
-t,--tag Image tag - default is matter-dev-environment:local
3434
-u,--uid User UIDa - default is the current user ID
35-
-v,--version Build version - default is the latest
35+
-v,--version Build version - default is the version of the base chip-build docker image
3636
EOF
3737
}
3838

.devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"type": "bind"
2121
}
2222
],
23-
"initializeCommand": "bash .devcontainer/build.sh --tag matter-dev-environment:local --version 97",
23+
"initializeCommand": "bash .devcontainer/build.sh",
2424
"image": "matter-dev-environment:local",
2525
"remoteUser": "vscode",
2626
"containerEnv": {

0 commit comments

Comments
 (0)