Skip to content

Commit

Permalink
devcontainer: add documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan committed Nov 25, 2024
1 parent 0ff8356 commit 618c2fc
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .devcontainer/gsg/devcontainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Device Containers Getting Started Guide

This guide will walk you through using a [Development Container](https://containers.dev/)
configured with all the tools needed to build and run CNDP. The Dev
Container setup is compatible with local development in Visual Studio Code
and with GitHub Codespaces for cloud-based workflows.

## Prerequisites

- **VSCode**
- **Docker**
- **VSCode Dev Containers Extension**

> **_NOTE_**: Details of the Dev Container prerequisites can be found
[here](https://code.visualstudio.com/docs/devcontainers/tutorial#_prerequisites).

## Basic Workflow

1. Dev Container Configurations can be found in the `.devcontainer` directory.
Files are set up with configuration details: the Docker image to use,
extensions to install, environment variables...
> **_NOTE_**: The Dev Container configuration provided supports both root
(not recommended) and non-root (recommended) users.
2. Open project in Container: Open the project folder in VS Code or Github
workspaces to build and attach the development environment.
3. Development: Work as usual, with access to tools and dependencies defined
in the container.

The following sections will walk through Step 2 in detail.

### Running in Visual Studio Code

Follow these steps to launch and work with the Dev Container in Visual
Studio Code.

Open the project in Visual Studio Code. A pop up will appear asking to reopen
in project in a Dev Container.
![reopen-in-container](./images/reopen-in-container.png)

If the pop up doesn't appear, the container can be launched by accessing the
Visual Studio Code Command Palette and looking for the:
`Dev Containers: Reopen in Container` option as shown below.

![reopen-in-container](./images/rebuild-container.png)

Visual Studio Code will relaunch inside the Dev Container.

When the container is ready CNDP can be built as usual.

### Running in Github Codespace

Use GitHub Codespaces for cloud-based development with the same Dev Container configuration.

### Running the Tutorials in the Dev Container

1. Navigate to your repository and click the `< >Code` dropdown.
2. In the Codespaces tab, click the ellipsis (...), then select `+ New with Options`:
![codespaces-options](./images/codespaces-options.png)
3. (If needed) Select the Branch, the Dev Container configuration, number of CPUs:
![codespaces-config](./images/codespaces-config.png)
4. Click the Button to `Create codespace`.

When the codespace is available CNDP can be built as usual.
Binary file added .devcontainer/gsg/images/codespaces-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .devcontainer/gsg/images/codespaces-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .devcontainer/gsg/images/rebuild-container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .devcontainer/gsg/images/reopen-in-container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,40 @@ To run pre-commit manually
pre-commit run --all-files
```

### Development Container (Dev Container)

This project includes a **Dev Container** specification that provides a
consistent, isolated development environment. With this setup, you can
develop and build CNDP as well as run its tutorials seamlessly.

#### Key Benefits

- **Consistency**: All developers can work with the same development
environment, ensuring uniform behavior across different systems.
- **Isolation**: The container prevents potential conflicts with software
installed on your local machine.
- **Portability**: Easily share the development environment with team members,
minimizing onboarding time and setup issues.

#### How to Use the Dev Container

1. **Visual Studio Code (Locally)**:
- Open the project in VS Code and use the *Dev Containers* extension to
launch the environment.
- Simply choose **“Reopen in Container”**, and VS Code will build and
attach the container for you.

2. **GitHub Codespaces**:
If you prefer working in the cloud, the Dev Container is compatible with
[GitHub Codespaces](https://docs.github.com/en/codespaces/overview), allowing
you to develop directly in your browser with minimal local setup.

#### More Information

For further details, refer to the [GSG](./.devcontainer/gsg/devcontainer.md) or
the [introduction to Dev Containers](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers)
provided by GitHub.

## CNDP notable directories

The following shows a subset of the directory structure.
Expand Down

0 comments on commit 618c2fc

Please sign in to comment.