Skip to content

Commit 5f150bb

Browse files
authored
Document QNX setup and Dependabot workaround (#107)
QNX setup cannot be done in a generic way via the devcontainer image. Thus documentation is added how to set it up at each repo. For getting Dependabot updates of Devcontainer image releases, no documentation was given so far, which is fixed now. Closes #49
1 parent 1eaf9ee commit 5f150bb

1 file changed

Lines changed: 102 additions & 15 deletions

File tree

README.md

Lines changed: 102 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,32 @@ From here on, we assume that such a development container setup is installed and
3838
Add a file called `.devcontainer/devcontainer.json` to your repository.
3939
It should contain the following:
4040

41+
`.devcontainer/devcontainer.json`
42+
4143
````json
4244
{
4345
"name": "eclipse-s-core",
44-
"image": "ghcr.io/eclipse-score/devcontainer:<version>"
46+
"build": {
47+
"dockerfile": "Dockerfile"
48+
}
4549
}
4650
````
4751

52+
`.devcontainer/Dockerfile`
53+
54+
```Dockerfile
55+
# Use Dockerfile to get Dependabot version bumps after new image is released
56+
FROM ghcr.io/eclipse-score/devcontainer:<version>
57+
```
58+
4859
The `<version>` must be a [valid, published release](https://github.com/eclipse-score/devcontainer/tags).
49-
You can also use `main` as `<version>` to automatically follow the `main` branch, and `latest` to follow release tags - but be aware that this can result in undesired updates.
60+
61+
> [!NOTE]
62+
> Dependabots devcontainer support does not include devcontainer images so far.
63+
> With the Dockerfile Dependabot will create pull request after a new devcontainer image release is published.
64+
65+
You can also use `main` as `<version>` to automatically follow the `main` branch, and `latest` to follow release tags - but be aware that this will make it harder to figure out with which container version the code has been build and tested.
66+
You and a colleague might be working with different container versions without knowing, because newer versions of the same tag name are not pulled automatically by Docker.
5067

5168
To start using the container, click the **Reopen in Container** button when prompted by Visual Studio Code:
5269

@@ -60,6 +77,19 @@ Afterwards, Visual Studio Code should show this in the lower left corner of your
6077

6178
![Dev container success](resources/devcontainer_success.png)
6279

80+
### Inside the Container
81+
82+
Open a Terminal, and - for example - type `bazel build ...` to execute the default build of the repository.
83+
84+
After you have build the code, create [compilation databases](https://clang.llvm.org/docs/JSONCompilationDatabase.html) via Visual Studio Code [Task](https://code.visualstudio.com/docs/debugtest/tasks):
85+
86+
- C++: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>p</kbd> -> `Tasks: Run Task` -> `Update compile_commands.json`
87+
- Rust: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>p</kbd> -> `Tasks: Run Task` -> `Update rust-project.json`
88+
89+
These databases are used by Visual Studio Code to support code navigation and auto-completion with the help of [language servers](https://microsoft.github.io/language-server-protocol/).
90+
91+
Congratulations, you are now a dev container enthusiast 😊.
92+
6393
### Bazel's `linux-sandbox`
6494

6595
`linux-sandbox` makes use of [Linux user namespaces](https://man7.org/linux/man-pages/man7/user_namespaces.7.html).
@@ -77,19 +107,6 @@ probably due to lack of alternatives.
77107
> [!NOTE]
78108
> If `linux-sandbox` is not needed, do not add this snippet.
79109
80-
### Inside the Container
81-
82-
Open a Terminal, and - for example - type `bazel build ...` to execute the default build of the repository.
83-
84-
After you have build the code, create [compilation databases](https://clang.llvm.org/docs/JSONCompilationDatabase.html) via Visual Studio Code [Task](https://code.visualstudio.com/docs/debugtest/tasks):
85-
86-
- C++: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>p</kbd> -> `Tasks: Run Task` -> `Update compile_commands.json`
87-
- Rust: <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>p</kbd> -> `Tasks: Run Task` -> `Update rust-project.json`
88-
89-
These databases are used by Visual Studio Code to support code navigation and auto-completion with the help of [language servers](https://microsoft.github.io/language-server-protocol/).
90-
91-
Congratulations, you are now a dev container enthusiast 😊.
92-
93110
### How to use: codeql
94111

95112
The devcontainer codeql installation supports C, C++ and Rust source code analysis. All publicly available
@@ -118,6 +135,76 @@ codeql database analyze _sca/codeql_data \
118135
--output=_sca/codeql-results.sarif
119136
```
120137

138+
### QNX Support in Your Repository
139+
140+
QNX support cannot be provided generically in this shared devcontainer image and has to be configured per repository.
141+
The basic reason is that QNX licenses might be bound to a user name, which is impossible to support for a generic container image.
142+
For more details see [issue #49](https://github.com/eclipse-score/devcontainer/issues/49#issuecomment-4217458769).
143+
144+
The recommended approach is to follow this pattern:
145+
146+
1. Build a small repository-local Dockerfile based on `ghcr.io/eclipse-score/devcontainer:<version>`.
147+
2. Rename the default `vscode` user to the host username via build arg.
148+
3. Bind-mount the QNX license and credentials into the container.
149+
4. Create missing host files in `initializeCommand` so startup is smooth.
150+
151+
Use this setup in your repository:
152+
153+
`.devcontainer/Dockerfile`
154+
155+
```Dockerfile
156+
FROM ghcr.io/eclipse-score/devcontainer:<version>
157+
158+
ARG USERNAME=vscode
159+
160+
# Rename 'vscode' to the host username for QNX-related user expectations.
161+
# In environments using a license server, the QNX license might be bound to a username.
162+
RUN if [ "$USERNAME" != "vscode" ]; then \
163+
usermod -l ${USERNAME} vscode \
164+
&& groupmod -n ${USERNAME} vscode \
165+
&& usermod -d /home/${USERNAME} -m ${USERNAME} \
166+
&& ln -s /home/${USERNAME} /home/vscode \
167+
&& echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} \
168+
&& chmod 0440 /etc/sudoers.d/${USERNAME}; \
169+
fi
170+
171+
USER ${USERNAME}
172+
```
173+
174+
`.devcontainer/devcontainer.json`
175+
176+
```json
177+
{
178+
"name": "eclipse-s-core",
179+
"build": {
180+
"dockerfile": "Dockerfile",
181+
"args": {
182+
"USERNAME": "${localEnv:USER}"
183+
}
184+
},
185+
"remoteUser": "${localEnv:USER}",
186+
"mounts": [
187+
{
188+
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.qnx/license/licenses",
189+
"target": "/opt/score_qnx/license/licenses",
190+
"type": "bind"
191+
},
192+
{
193+
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.netrc",
194+
"target": "/home/${localEnv:USER}/.netrc",
195+
"type": "bind"
196+
}
197+
],
198+
"initializeCommand": {
199+
"Make sure QNX license exists": "mkdir -p ~/.qnx/license && touch -a ~/.qnx/license/licenses",
200+
"Make sure .netrc exists": "touch -a ~/.netrc"
201+
}
202+
}
203+
```
204+
205+
> [!NOTE]
206+
> - `.netrc` is a practical way to provide myQNX credentials without committing secrets into the repository.
207+
121208
## Development
122209

123210
> [!NOTE]

0 commit comments

Comments
 (0)