Skip to content

Commit a8fc596

Browse files
committed
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>
1 parent c0e580c commit a8fc596

File tree

3 files changed

+37
-42
lines changed

3 files changed

+37
-42
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

+28-28
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#
1818

1919
HERE="$(dirname "$0")"
20-
CHIP_ROOT="$(realpath "$HERE"/..)"
21-
BUILD_VERSION="latest"
20+
CHIP_ROOT="$(git rev-parse --show-toplevel)"
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

@@ -44,31 +44,31 @@ eval set -- "$OPTS"
4444

4545
while :; do
4646
case "$1" in
47-
-h | --help)
48-
show_usage
49-
exit 0
50-
;;
51-
-t | --tag)
52-
IMAGE_TAG=$2
53-
shift 2
54-
;;
55-
-u | --uid)
56-
USER_UID=$2
57-
shift 2
58-
;;
59-
-v | --version)
60-
BUILD_VERSION=$2
61-
shift 2
62-
;;
63-
--)
64-
shift
65-
break
66-
;;
67-
*)
68-
echo "Unexpected option: $1"
69-
show_usage
70-
exit 2
71-
;;
47+
-h | --help)
48+
show_usage
49+
exit 0
50+
;;
51+
-t | --tag)
52+
IMAGE_TAG=$2
53+
shift 2
54+
;;
55+
-u | --uid)
56+
USER_UID=$2
57+
shift 2
58+
;;
59+
-v | --version)
60+
BUILD_VERSION=$2
61+
shift 2
62+
;;
63+
--)
64+
shift
65+
break
66+
;;
67+
*)
68+
echo "Unexpected option: $1"
69+
show_usage
70+
exit 2
71+
;;
7272
esac
7373
done
7474

.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)