Skip to content
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

Merged
merged 33 commits into from
Aug 22, 2023
Merged

Devcontainer #29259

merged 33 commits into from
Aug 22, 2023

Conversation

robbederks
Copy link
Contributor

This makes it super easy to set up a dev environment with vscode.
It prepares the docker, and automatically mounts in the work dir.

Dockerfile.openpilot_dev Outdated Show resolved Hide resolved
.devcontainer/devcontainer.json Outdated Show resolved Hide resolved
.devcontainer/devcontainer.json Show resolved Hide resolved
@robbederks
Copy link
Contributor Author

@fredyshox Mind writing a small README for this? Think it's already in a pretty usable state

@adeebshihadeh
Copy link
Contributor

I imagine some contributors are going to be relying on this, so think we should add a small test before merging this.

@adeebshihadeh adeebshihadeh added the PC Issues related to running openpilot on PC label Aug 8, 2023
@@ -0,0 +1,5 @@
FROM ghcr.io/commaai/openpilot-base:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would put this file in .devcontainer/

tools/README.md Outdated Show resolved Hide resolved
@fredyshox
Copy link
Contributor

fredyshox commented Aug 9, 2023

Btw I've checked how slow would it be to build aarch64 images using QEMU and docker buildx on x64 machine. It's way too slow, after an hour it only made it to py3.11 installation (and crashed while doing so).

That's very unfortunate, because this feature makes it super easy to have stable development experience on a mac.

@fredyshox
Copy link
Contributor

fredyshox commented Aug 9, 2023

I've just found out that Azure pipelines seem to support arm64. We're already using that in some places, maybe we could utilize that for building such images.

@adeebshihadeh
Copy link
Contributor

I don't want to introduce another CI system for this. QEMU should be fine, or BuildJet (#29277) if we end up merging that.

tools/README.md Outdated
```
xhost +localhost
```
Note that this is temporary and only affects current XQuartz session. To make it pernament, add the above line to shell rc file.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: permanent

@fredyshox
Copy link
Contributor

Added simple CI test for this which builds an image and runs the container using @devcontainers/cli, which should act very similar to vscode extension.

Comment on lines +4 to +5
# remove gitconfig if exists, since its gonna be replaced by host one
RUN rm -f /root/.gitconfig
Copy link
Contributor

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?

Copy link
Contributor

@fredyshox fredyshox Aug 10, 2023

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.

# 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
RUN pip install ipython jupyter jupyterlab
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should consider adding this as a poetry group

tools/README.md Outdated

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.

Dev containers are supported in [multiple editors and IDEs](https://containers.dev/supporting), including Visual Studio Code. To start using it in VS Code, make sure you have `docker` installed. Then install `Dev Containers` extension. More detailed installation instructions can be found [here](https://code.visualstudio.com/docs/devcontainers/containers#_installation).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this new section is quite long. we should just link to the real instructions for each thing, i.e. https://code.visualstudio.com/docs/devcontainers/create-dev-container for this one

@robbederks robbederks marked this pull request as ready for review August 14, 2023 18:24
tools/README.md Outdated
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we can link away this whole section

@@ -0,0 +1,24 @@
name: development tools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we've already got tools_tests.yaml

Comment on lines 23 to 24
- name: Stop containers
run: docker kill $(docker ps -q)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem necessary

@fredyshox
Copy link
Contributor

@adeebshihadeh is this mergeable now?

name: devcontainer
runs-on: ubuntu-latest
if: github.repository == 'commaai/openpilot'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's this for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed in this case

run: devcontainer build --workspace-folder .
- name: Run dev container
run: devcontainer up --workspace-folder .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also run something like "scons --dry-run" to get some coverage on the environment?

@adeebshihadeh
Copy link
Contributor

Just got this while trying it out
image

@fredyshox
Copy link
Contributor

Just got this while trying it out image

Seems something is wrong with permission to submodules. Gonna see what i can do

@fredyshox
Copy link
Contributor

Should be fine now, can you try again?

@adeebshihadeh
Copy link
Contributor

Same thing (this is not an efficient loop)

@adeebshihadeh
Copy link
Contributor

New issue

bash: /tmp/tools/openpilot_env.sh: No such file or directory
bash: /workspaces/openpilot/tools/openpilot_env.sh: No such file or directory

@adeebshihadeh
Copy link
Contributor

Seems it's missing the scons cache

@fredyshox
Copy link
Contributor

New issue

bash: /tmp/tools/openpilot_env.sh: No such file or directory
bash: /workspaces/openpilot/tools/openpilot_env.sh: No such file or directory

Removed references to openpilot_env since it got removed

@fredyshox
Copy link
Contributor

Seems it's missing the scons cache

I don't think that causes big inconvenience, as it's relatively quick to build. Including it would significantly inflate image size, which is already quite big.

@adeebshihadeh
Copy link
Contributor

It should be volume mounted, not copied in

@fredyshox fredyshox merged commit d71a719 into master Aug 22, 2023
20 checks passed
@fredyshox fredyshox deleted the devcontainer branch August 22, 2023 18:47
"--volume=${localEnv:XAUTHORITY}:/root/.Xauthority",
"--volume=${localEnv:HOME}/.comma:/root/.comma",
"--volume=/tmp/comma_download_cache:/tmp/comma_download_cache",
"--volume=/tmp/devcontainer_scons_cache:/tmp/scons_cache",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there a special devcontainer cache?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to mess with hosts cache, which may be incompatible (like on macos)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, but this is also true for the build targets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PC Issues related to running openpilot on PC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants