From 9231f6c57beb6bfabc030f9debcb659dd964634e Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Thu, 24 Sep 2020 09:52:00 -0700 Subject: Add VSCode devcontainer configuration --- .devcontainer/Dockerfile | 1 + .devcontainer/devcontainer.json | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..ba4e122 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1 @@ +FROM zmkfirmware/zephyr-west-action-arm \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7450534 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,6 @@ +{ + "name": "ZMK Development", + "dockerFile": "Dockerfile", + "extensions": ["ms-vscode.cpptools"] +} + -- cgit v1.2.3 From 5bd09b586e153185850fe468b19fdd0eb534f35d Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Wed, 30 Sep 2020 23:23:42 -0700 Subject: Remove Dockerfile in favor of image Per the docs, we can directly specify an image in devcontainer.json: https://code.visualstudio.com/docs/remote/devcontainerjson-reference --- .devcontainer/Dockerfile | 1 - .devcontainer/devcontainer.json | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index ba4e122..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM zmkfirmware/zephyr-west-action-arm \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7450534..bbf44bc 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,7 @@ { "name": "ZMK Development", - "dockerFile": "Dockerfile", - "extensions": ["ms-vscode.cpptools"] + "image": "zmkfirmware/zephyr-west-action-arm", + "extensions": ["ms-vscode.cpptools"], + "runArgs": ["--security-opt", "label=disable"] } -- cgit v1.2.3 From 9b29f9b861464a8a0eba78f25058cded118b84d5 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Thu, 1 Oct 2020 06:52:33 +0000 Subject: Install SSH and GPG into container 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! --- .devcontainer/Dockerfile | 8 ++++++++ .devcontainer/devcontainer.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..abbe54a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,8 @@ +from zmkfirmware/zephyr-west-action-arm + +RUN apt-get -y update && \ + apt-get -y upgrade && \ + apt-get install --no-install-recommends -y \ + ssh \ + gpg && \ + rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bbf44bc..f21465d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "ZMK Development", - "image": "zmkfirmware/zephyr-west-action-arm", + "dockerFile": "Dockerfile", "extensions": ["ms-vscode.cpptools"], "runArgs": ["--security-opt", "label=disable"] } -- cgit v1.2.3 From 42d1915ced3f7ec8a74cf5be506438d2bf07a7d3 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Thu, 1 Oct 2020 06:56:18 +0000 Subject: Use spaces, not tabs --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index abbe54a..cf62b5a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,7 @@ from zmkfirmware/zephyr-west-action-arm RUN apt-get -y update && \ - apt-get -y upgrade && \ + apt-get -y upgrade && \ apt-get install --no-install-recommends -y \ ssh \ gpg && \ -- cgit v1.2.3 From 15614a946fac635a27ba94a4f32450c67016e5b2 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Thu, 1 Oct 2020 00:41:33 -0700 Subject: WIP docs for docker development --- docs/docs/dev-setup.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 4891f5a..be3d6f9 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -16,6 +16,7 @@ values={[ {label: 'macOS', value: 'mac'}, {label: 'Raspberry OS', value: 'raspberryos'}, {label: 'Fedora', value: 'fedora'}, +{label: 'VS Code & Docker', value: 'docker'}, ] }>{props.children}); @@ -178,6 +179,20 @@ Homebrew is required to install the system dependencies. If you haven't done so, brew install cmake ninja python3 ccache dtc git wget ``` + + + +This setup leverages the same [image which is used by the GitHub action](https://github.com/zmkfirmware/zephyr-west-action) for local development. Beyond the benefits of [dev/prod parity](https://12factor.net/dev-prod-parity), this approach is also the easiest to set up. No toolchain or dependencies are necessary when using Docker; the container image you'll be using already has the toolchain installed and set up to use. + + +1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop) for your operating system. +2. Install [VS Code](https://code.visualstudio.com/) +3. Install the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + +:::info +The docker container includes `west` and the compilation toolchain. If you're using docker and VS Code, you can skip right to [Source Code](#source-code). +::: + @@ -323,6 +338,11 @@ Please be sure to read the [additional setup instructions](https://docs.zephyrpr ::: + + + +You're already set up: the toolchain is installed and configured inside the docker container. + -- cgit v1.2.3 From 63931a706870652e649346e4052a9fb1b105ff5b Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Tue, 6 Oct 2020 08:51:25 -0700 Subject: Accept suggestions Co-authored-by: Pete Johanson --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cf62b5a..160b148 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,8 +1,8 @@ -from zmkfirmware/zephyr-west-action-arm +FROM zmkfirmware/zephyr-west-action-arm RUN apt-get -y update && \ apt-get -y upgrade && \ apt-get install --no-install-recommends -y \ ssh \ gpg && \ - rm -rf /var/lib/apt/lists/* \ No newline at end of file + rm -rf /var/lib/apt/lists/* -- cgit v1.2.3 From db40fbad598b6f84472cb2921df89f1a46fc6b5c Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Fri, 9 Oct 2020 17:49:42 -0700 Subject: Conditionally source zephyr-env.sh in .bashrc --- .devcontainer/.bashrc | 6 ++++++ .devcontainer/Dockerfile | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 .devcontainer/.bashrc diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc new file mode 100644 index 0000000..6a6ea69 --- /dev/null +++ b/.devcontainer/.bashrc @@ -0,0 +1,6 @@ +export LS_OPTIONS='-F --color=auto' +eval "`dircolors`" +alias ls='ls $LS_OPTIONS' +if [ -f /workspaces/zmk/zephyr/zephyr-env.sh ]; then + source /workspaces/zmk/zephyr/zephyr-env.sh +fi diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 160b148..184aae9 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,3 +6,6 @@ RUN apt-get -y update && \ ssh \ gpg && \ rm -rf /var/lib/apt/lists/* + +COPY .bashrc tmp +RUN mv /tmp/.bashrc ~/.bashrc -- cgit v1.2.3 From 63ad5b7c089f13a5b5d5514514cc9ad7e798d3e8 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Sat, 10 Oct 2020 01:42:50 +0000 Subject: Inject $WORKSPACE_DIR into container This permits users to check ZMK out into arbitrarily-named directories --- .devcontainer/.bashrc | 4 ++-- .devcontainer/devcontainer.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/.bashrc b/.devcontainer/.bashrc index 6a6ea69..855ea75 100644 --- a/.devcontainer/.bashrc +++ b/.devcontainer/.bashrc @@ -1,6 +1,6 @@ export LS_OPTIONS='-F --color=auto' eval "`dircolors`" alias ls='ls $LS_OPTIONS' -if [ -f /workspaces/zmk/zephyr/zephyr-env.sh ]; then - source /workspaces/zmk/zephyr/zephyr-env.sh +if [ -f "$WORKSPACE_DIR/zephyr/zephyr-env.sh" ]; then + source "$WORKSPACE_DIR/zephyr/zephyr-env.sh" fi diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f21465d..940b78b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,6 +2,7 @@ "name": "ZMK Development", "dockerFile": "Dockerfile", "extensions": ["ms-vscode.cpptools"], - "runArgs": ["--security-opt", "label=disable"] + "runArgs": ["--security-opt", "label=disable"], + "containerEnv": {"WORKSPACE_DIR": "${containerWorkspaceFolder}"} } -- cgit v1.2.3 From 5c00c97e9a1647e2676586c303d19c5559e2e2f1 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Fri, 9 Oct 2020 18:48:41 -0700 Subject: Wrap up documentation --- docs/docs/assets/dev-setup/vscode_devcontainer.png | Bin 0 -> 20773 bytes docs/docs/dev-setup.md | 62 +++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 docs/docs/assets/dev-setup/vscode_devcontainer.png diff --git a/docs/docs/assets/dev-setup/vscode_devcontainer.png b/docs/docs/assets/dev-setup/vscode_devcontainer.png new file mode 100644 index 0000000..e5c22b0 Binary files /dev/null and b/docs/docs/assets/dev-setup/vscode_devcontainer.png differ diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index be3d6f9..6ef0f02 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -369,12 +369,63 @@ Since ZMK is built as a Zephyr™ application, the next step is to use `west` to initialize and update your workspace. The ZMK Zephyr™ application is in the `app/` source directory: + #### Step into the repository + + + +```sh +cd zmk +``` + + + + +```sh +cd zmk +``` + + + + +```sh +cd zmk +``` + + + + +```sh +cd zmk +``` + + + + ```sh cd zmk ``` + + + + +Open the `zmk` checkout folder in VS Code. The repository includes a configuration for containerized development, so an alert will pop up: + +![VS Code Dev Container Configuration Alert](assets/dev-setup/vscode_devcontainer.png) + +Click `Reopen in Container` in order to reopen the VS Code with the running container. + +The first time you do this on your machine, it will pull the docker image down from the registry and build the container. Subsequent launches are much faster! + +:::caution +All subsequent steps must be performed from the VS Code terminal _inside_ the container. +::: + + + + #### Initialize West ```sh @@ -393,6 +444,17 @@ section again for links to how to do this west update ``` +:::tip +This step pulls down quite a bit of tooling. Go grab a cup of coffee, it can take 10-15 minutes even on a good internet connection! +::: + +:::info +If you're using Docker, you're done with setup! You must restart the container at this point. The easiest way to do so is to close the VS Code window, verify that the container has stopped in Docker Dashboard, and reopen the container with VS Code. + +Once your container is restarted, proceed to [Building and Flashing](./dev-build.md). +::: + + #### Export Zephyr™ Core ```sh -- cgit v1.2.3 From 5401afc002ba086ca964aa7a164fbc6dbd1898b1 Mon Sep 17 00:00:00 2001 From: Idan Gazit Date: Fri, 9 Oct 2020 19:10:07 -0700 Subject: Skip toolchain for docker --- docs/docs/dev-setup.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/docs/dev-setup.md b/docs/docs/dev-setup.md index 6ef0f02..114fe0b 100644 --- a/docs/docs/dev-setup.md +++ b/docs/docs/dev-setup.md @@ -338,11 +338,6 @@ Please be sure to read the [additional setup instructions](https://docs.zephyrpr ::: - - - -You're already set up: the toolchain is installed and configured inside the docker container. - -- cgit v1.2.3