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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VSCode devcontainer configuration #209

Merged
merged 10 commits into from Oct 10, 2020

Conversation

idan
Copy link
Contributor

@idan idan commented Sep 24, 2020

This creates the a basic harness that permits users to develop with their local checkout inside the same docker container which powers the GitHub action. Does not yet contain docs and tests, but I did try it out with a clean checkout and was able to build images. 馃帀

See #208 for discussion about where this can go.

Steps to use:

  1. Install docker
  2. Install the Remote - Containers extension either via the extensions panel, or in your favorite terminal:
    code --install-extension ms-vscode-remote.remote-containers
  3. Opening the zmk folder in VS Code now displays a prompt to re-open inside a container:
    image
  4. Click Reopen in Container and the VS Code window will reload and do the necessary initial docker setup. This can take a little while.
  5. Open a terminal in VS Code and issue the following commands to initialize your environment:
$ west init -l app
$ west update # and go make lunch, this is going to take a while
$ cd app
$ west build -b YourBoardName -- -DSHIELD=YourShieldName

That's it!

@CrossR
Copy link
Contributor

CrossR commented Sep 24, 2020

Some potential to combine this with #192, and include the Docker ext as a recommended extension, though also raises the question of it the instructions provided there work for a Docker based workflow (making the compilation database, using it etc).

@idan idan mentioned this pull request Sep 24, 2020
@joelspadin
Copy link
Collaborator

I suspect that the compilation database part is still correct, but you'd need to change the compiler path to match wherever it ends up being in the container. Maybe we just add Docker to the list of OSes in all the docs pages?

@petejohanson
Copy link
Contributor

I suspect that the compilation database part is still correct, but you'd need to change the compiler path to match wherever it ends up being in the container. Maybe we just add Docker to the list of OSes in all the docs pages?

Yeah, if we can make this seemless, I definitely think it should be an "OS tab/option" in the dev setup docs.

Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

One tweak, and a question around SELinux settings.

.devcontainer/devcontainer.json Show resolved Hide resolved
@idan
Copy link
Contributor Author

idan commented Oct 1, 2020

So, the tweak above worked. Onto new issues!

Git pull/push with SSH remotes doesn't work inside the container because the docker image lacks SSH. Fixable with apt update; apt install ssh. We should probably bake that into the image? Once that's there, it Just Works鈩, and the devcontainers extension properly forwards things to the host's ssh-agent.

The more annoying (but less critical) thing I've run into is that GPG commit signing doesn't work. Like SSH, GPG is not installed in the image (easily fixable like above). Once it's there, it still doesn't work 鈥 the ~/.gnupg directory doesn't even exist:

image

Supposedly, this should work as of v118 of the remote-containers extension, but there's no documentation. However, another issue identifies a control to test against. When I try to gpg from inside the "try a sample" node container, I can see my keyring and a socket, and signing works fine:

image

My current hunch is that maybe the image needs to contain GPG already when it boots or the VSCode remote-containers extension doesn't try to set up forwarding.

@idan
Copy link
Contributor Author

idan commented Oct 1, 2020

To be clear:

  • SSH is critical, you can't git without it in many cases
  • Commit signing is nice to have
  • You can always commit from outside the container; this is all about quality of life at this point

@idan
Copy link
Contributor Author

idan commented Oct 1, 2020

OK, it works! I brought back the dockerfile and used it to install SSH/GPG into the image. Now when VSCode comes up, everything works out of the box for me (MacOS).

Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

One comment on the dockerfile, but certainly minor. I would love to get this in, so we can build on it, even if we aren't 100% happy with the documentation piece.

Thoughts @idan ?

.devcontainer/Dockerfile Outdated Show resolved Hide resolved
@idan
Copy link
Contributor Author

idan commented Oct 6, 2020

@petejohanson yes! I'll hack on the docs tonight and try to get it into a happy place, or move them to a separate branch so we can commit the docker bits and do the docs in a follow-onw

@petejohanson petejohanson added documentation Improvements or additions to documentation core Core functionality/behavior of ZMK enhancement New feature or request labels Oct 10, 2020
idan and others added 10 commits October 9, 2020 18:54
Per the docs, we can directly specify an image in devcontainer.json:
https://code.visualstudio.com/docs/remote/devcontainerjson-reference
Brings back the dockerfile so we can install SSH and GPG into it.
This fixes git actions with SSH remotes, and GPG signing now
works out of the box.

This commit was made from inside the container!
Co-authored-by: Pete Johanson <peter@peterjohanson.com>
This permits users to check ZMK out into arbitrarily-named directories
Copy link
Contributor

@petejohanson petejohanson left a comment

Choose a reason for hiding this comment

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

This is fabulous! Thanks sticking with this, and the docs updates.

@petejohanson petejohanson merged commit 0e6bea0 into zmkfirmware:main Oct 10, 2020
1 check passed
@idan idan deleted the containerize-development branch October 12, 2020 16:59
MangoIV pushed a commit to MangoIV/zmk that referenced this pull request Dec 18, 2020
tyalie pushed a commit to tyalie/zmk that referenced this pull request Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core functionality/behavior of ZMK documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants