Skip to content

Commit 8a2bb57

Browse files
ATmobicapan-
andauthored
[devcontainer] Standalone build and update (#26511)
* [vscode] Make the devcontainer image build a standalone script This enable us to set --net=host for the image creation. This should avoid dns restrictions one may have on one's local network by giving the image the same network as the host. This is only for the image build, not for running the container. Signed-off-by: Yoan Picchi <yoan.picchi@arm.com> * [vscode] Update dev container configuration - Move deprecated configuration into correct section - Add mcu-debug.debug-tracker-vscode into extension list. This extension is required for cortex debug. Signed-off-by: Vincent Coubard <vincent.coubard@arm.com> --------- Signed-off-by: Yoan Picchi <yoan.picchi@arm.com> Signed-off-by: Vincent Coubard <vincent.coubard@arm.com> Co-authored-by: Vincent Coubard <vincent.coubard@arm.com>
1 parent c216384 commit 8a2bb57

File tree

2 files changed

+121
-31
lines changed

2 files changed

+121
-31
lines changed

.devcontainer/build.sh

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright (c) 2023 Project CHIP Authors
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
HERE="$(dirname "$0")"
20+
CHIP_ROOT="$(realpath "$HERE"/..)"
21+
BUILD_VERSION="latest"
22+
IMAGE_TAG="matter-dev-environment:local"
23+
USER_UID=$UID
24+
25+
function show_usage() {
26+
cat <<EOF
27+
Usage: $0
28+
29+
Build vscode dev environment docker image.
30+
31+
Options:
32+
-h,--help Show this help
33+
-t,--tag Image tag - default is matter-dev-environment:local
34+
-u,--uid User UIDa - default is the current user ID
35+
-v,--version Build version - default is the latest
36+
EOF
37+
}
38+
39+
SHORT=t:,u:,h:,v
40+
LONG=tag:,uid:,help:,version:
41+
OPTS=$(getopt -n build --options "$SHORT" --longoptions "$LONG" -- "$@")
42+
43+
eval set -- "$OPTS"
44+
45+
while :; do
46+
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+
;;
72+
esac
73+
done
74+
75+
if [ "$USER_UID" = "0" ]; then
76+
USER_UID=1000
77+
fi
78+
79+
docker build \
80+
-t "$IMAGE_TAG" \
81+
--pull \
82+
--build-arg USER_UID="$USER_UID" \
83+
--build-arg BUILD_VERSION="$BUILD_VERSION" \
84+
--network=host \
85+
"$HERE"

.devcontainer/devcontainer.json

+36-31
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,43 @@
1414
"mounts": [
1515
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
1616
],
17-
"build": {
18-
"dockerfile": "Dockerfile",
19-
"args": {
20-
"BUILD_VERSION": "0.7.3"
21-
}
22-
},
17+
"initializeCommand": ".devcontainer/build.sh --tag matter-dev-environment:local --version 0.7.3",
18+
"image": "matter-dev-environment:local",
2319
"remoteUser": "vscode",
24-
// Add the IDs of extensions you want installed when the container is created in the array below.
25-
"extensions": [
26-
"aaron-bond.better-comments",
27-
"augustocdias.tasks-shell-input",
28-
"christian-kohler.path-intellisense",
29-
"eamodio.gitlens",
30-
"editorconfig.editorconfig",
31-
"esbenp.prettier-vscode",
32-
"foxundermoon.shell-format",
33-
"github.vscode-pull-request-github",
34-
"maelvalais.autoconf",
35-
"marus25.cortex-debug",
36-
"ms-azuretools.vscode-docker",
37-
"ms-vscode.cpptools",
38-
"msedge-dev.gnls",
39-
"redhat.vscode-yaml",
40-
"vadimcn.vscode-lldb",
41-
"xaver.clang-format",
42-
"yuichinukiyama.vscode-preview-server",
43-
"yzhang.markdown-all-in-one"
44-
],
45-
// Use 'settings' to set *default* container specific settings.json values on container create.
46-
// You can edit these settings after create using File > Preferences > Settings > Remote.
47-
"settings": {
48-
"terminal.integrated.shell.linux": "/bin/bash"
20+
"customizations": {
21+
"vscode": {
22+
// Add the IDs of extensions you want installed when the container is created in the array below.
23+
"extensions": [
24+
"mcu-debug.debug-tracker-vscode",
25+
"aaron-bond.better-comments",
26+
"augustocdias.tasks-shell-input",
27+
"christian-kohler.path-intellisense",
28+
"eamodio.gitlens",
29+
"editorconfig.editorconfig",
30+
"esbenp.prettier-vscode",
31+
"foxundermoon.shell-format",
32+
"github.vscode-pull-request-github",
33+
"maelvalais.autoconf",
34+
"marus25.cortex-debug",
35+
"ms-azuretools.vscode-docker",
36+
"ms-vscode.cpptools",
37+
"msedge-dev.gnls",
38+
"redhat.vscode-yaml",
39+
"vadimcn.vscode-lldb",
40+
"xaver.clang-format",
41+
"yuichinukiyama.vscode-preview-server",
42+
"yzhang.markdown-all-in-one"
43+
],
44+
"settings": {
45+
"terminal.integrated.defaultProfile.linux": "bash",
46+
"terminal.integrated.profiles.linux": {
47+
"bash": {
48+
"path": "/bin/bash",
49+
"args": ["-l"]
50+
}
51+
}
52+
}
53+
}
4954
},
5055
"remoteEnv": {
5156
"GIT_PS1_SHOWDIRTYSTATE": "1",

0 commit comments

Comments
 (0)