-
Notifications
You must be signed in to change notification settings - Fork 9.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devcontainer #29259
Devcontainer #29259
Changes from 23 commits
4de62a0
8c0ea4d
c6c8cf8
ba2177d
d1a3a75
40b559a
e734099
d5f48b9
db19249
ad9a87b
2d0456f
33e7ebc
bd611bf
f98ae2f
a62a9ba
fa104b1
fd1e402
a9924ad
8e1456a
1d1c822
27a5f12
949275a
0a84a57
5e5f53a
17768e5
d3aa650
aa75b3f
6c83c1b
11b82d5
bd8d87b
4972a3b
0126999
15305c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ghcr.io/commaai/openpilot-base:latest | ||
|
||
RUN printf "\nsource /workspaces/openpilot/tools/openpilot_env.sh\n" >> ~/.bashrc | ||
# remove gitconfig if exists, since its gonna be replaced by host one | ||
RUN rm -f /root/.gitconfig | ||
RUN apt update && apt install -y vim net-tools usbutils htop ripgrep | ||
RUN pip install ipython jupyter jupyterlab | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should consider adding this as a poetry group |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "openpilot devcontainer", | ||
"build": { | ||
"dockerfile": "Dockerfile" | ||
}, | ||
"postCreateCommand": "bash -c 'if [[ $DISPLAY == *xquartz* ]]; then echo \"export DISPLAY=host.docker.internal:0\" >> /root/.bashrc; fi'", | ||
"privileged": true, | ||
"containerEnv": { | ||
"DISPLAY": "${localEnv:DISPLAY}", | ||
"PYTHONPATH": "${containerWorkspaceFolder}", | ||
"force_color_prompt": "1" | ||
}, | ||
"runArgs": [ | ||
robbederks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"--volume=/tmp/.X11-unix:/tmp/.X11-unix", | ||
"--volume=${localEnv:XAUTHORITY}:/root/.Xauthority", | ||
"--volume=${localEnv:HOME}/.comma:/root/.comma", | ||
"--volume=/tmp/comma_download_cache:/tmp/comma_download_cache", | ||
"--shm-size=1G" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: development tools | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we've already got tools_tests.yaml |
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
devcontainer: | ||
name: devcontainer | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'commaai/openpilot' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- name: Setup Dev Container CLI | ||
run: npm install -g @devcontainers/cli | ||
- name: Build dev container image | ||
run: devcontainer build --workspace-folder . | ||
- name: Run dev container | ||
run: devcontainer up --workspace-folder . | ||
- name: Stop containers | ||
run: docker kill $(docker ps -q) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't seem necessary |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,32 @@ Build openpilot with this command: | |
scons -u -j$(nproc) | ||
``` | ||
|
||
### Dev Container | ||
|
||
openpilot supports [Dev Containers](https://containers.dev/). Dev containers provide customizable and consistent development environment wrapped inside a container. This means you can develop in a designated environment matching our primary development target, regardless of you local setup. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you -> your |
||
|
||
Dev containers are supported in [multiple editors and IDEs](https://containers.dev/supporting), including [Visual Studio Code](https://code.visualstudio.com/docs/devcontainers/containers). | ||
|
||
#### X11 forwarding on macOS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like we can link away this whole section |
||
|
||
GUI apps like `ui` or `cabana` can also run inside the container by leveraging X11 forwarding. To make use of it on macOS, additional configuration steps must be taken. First of all, install [XQuartz](https://formulae.brew.sh/cask/xquartz#default): | ||
```sh | ||
brew install --cask xquartz | ||
``` | ||
|
||
Open XQuartz, go to `XQuartz` > `Settings...` > `Security` and check "Authenticate connections" and "Allow connections from network clients" boxes. Then allow for connections from localhost with: | ||
```sh | ||
xhost +localhost | ||
``` | ||
Note that this is temporary and only affects current XQuartz session. To make it permanent, add the above line to shell rc file. | ||
|
||
`.Xauthority` file is used for authentication with X11 server. It's typically stored in user's `$HOME` directory. Openpilot's dev container is using `XAUTHORITY` env var to locate such file in host file system. If it's not set already, run following lines to set it up (and again, to make it permanent, add it to rc file): | ||
|
||
```sh | ||
XAUTH_FILE_ROW=($(xauth info | head -n 1)) | ||
export XAUTHORITY="${XAUTH_FILE_ROW[@]:2}" | ||
``` | ||
|
||
### Windows | ||
|
||
Neither openpilot nor any of the tools are developed or tested on Windows, but the [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/about) should provide a similar experience to native Ubuntu. [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/compare-versions) specifically has been reported by several users to be a seamless experience. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't it be shadowed anyway when it's mounted in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not mounting it ourselves, vscode/devcontainer does that for us, and it fails silently if it exists already.