-
Notifications
You must be signed in to change notification settings - Fork 19
Working with the Uyuni Tools Project Using DevContainers
A DevContainer provides a consistent, containerized development environment for the uyuni-tools project. This guide explains how to use a DevContainer for uyuni-tools, including options for downloading a precompiled container or creating the container from the cloned code. It also highlights the tools that support DevContainers to streamline development workflows.
The DevContainer for uyuni-tools includes everything you need to start working with the code, such as Go dependencies, linters, pre-commit hooks, and more, ensuring that your development environment is fully configured and ready to go.
DevContainers provide a standardized and reproducible environment for development. They are used in different ways depending on the tools and workflows you prefer. In this section, we will show you some examples of how to use the DevContainer with popular development environments such as Visual Studio Code (VS Code), IntelliJ IDEA Ultimate, and GitHub Codespaces.
While we provide examples for these tools, we welcome contributions for other tools or workflows that can integrate with the DevContainer. Feel free to experiment with different environments and share your improvements with the community!
You can clone the uyuni-tools project using any method you prefer (e.g., through GitHub's web interface, using GitHub Desktop, or via the command line). Here's an example using the command line:
-
Example: Clone the Project Using CLI
Clone the uyuni-tools repository from GitHub:git clone https://github.com/uyuni-project/uyuni-tools.git cd uyuni-tools
You have two options to get started with the DevContainer:
-
Option 1: Download Precompiled Container
If you prefer a preconfigured environment, you can download the precompiled DevContainer image from GitHub Container Registry (GHCR). This image includes all necessary dependencies and tools for the uyuni-tools project:docker pull ghcr.io/uyuni-project/uyuni-tools/devcontainer:latest
This saves time by avoiding the need to build the container from scratch. It includes Go dependencies, linters, pre-commit hooks, and everything you need to start working immediately.
-
Option 2: Create the DevContainer from Cloned Code
Alternatively, you can create the DevContainer directly from the cloned uyuni-tools project. This involves opening the project directory and using a tool that supports DevContainers (e.g., Visual Studio Code, DevContainer CLI) to build and start the container. The container configuration is provided in the
devcontainer.json
file and theDockerfile
, which automatically sets up the environment with all necessary dependencies. Once the DevContainer is created, it will be ready to use for development.
Once you have the DevContainer running, follow these steps for a seamless development experience in Visual Studio Code:
After cloning or pulling the container, open the project directory in Visual Studio Code. If you have the Remote - Containers extension installed, VS Code will detect the devcontainer.json
configuration and prompt you to reopen the project inside the container. Click Reopen in Container.
Once inside the container, you can use the VS Code debugger to run and debug the project as you normally would. Since you're working inside the container, your environment will closely match the production setup, making it easier to reproduce issues and test in an isolated space.
VS Code will automatically install any extensions specified in the devcontainer.json
file inside the container. You can also install additional extensions if needed, which will only be available in the containerized environment.
If changes are made to the DevContainer configuration (e.g., the Dockerfile or devcontainer.json
), you may need to rebuild the container to apply them:
- Open the Command Palette in VS Code (
Ctrl+Shift+P
orCmd+Shift+P
). - Type "Remote-Containers: Rebuild Container" and select it.
To stop the container, close VS Code or select "Remote-Containers: Reopen Locally" from the Command Palette. To restart it, select "Reopen in Container" again.
GitHub Codespaces offers a cloud-based development environment that can automatically launch a containerized workspace configured using the DevContainer. This is a great option if you want to quickly spin up an environment without worrying about local setup or dependencies.
There are two ways to open the uyuni-tools project in GitHub Codespaces:
To open the uyuni-tools project in GitHub Codespaces directly from the repository:
-
Navigate to the uyuni-tools GitHub repository:
uyuni-tools GitHub repository. -
Click the "Code" button, then under the "Codespaces" tab, click "New codespace".
GitHub will automatically create a new Codespace for you, launching the uyuni-tools project inside a container configured by the
devcontainer.json
file.
If you're working on a pull request (PR), GitHub makes it easy to launch a Codespace directly from the PR:
-
When you create or view a PR, a "Create Codespace" button will be available within the PR description (this is typically added automatically in the PR template).
-
Clicking this button will automatically create a Codespace for you, pre-configured with the PR's code changes. This is an efficient way for reviewers and collaborators to instantly access the environment with the latest changes, without needing to manually check out branches or configure the environment themselves.
This integration makes it incredibly easy to work on pull requests, review code, and test changes within an isolated, cloud-based environment.
Once your Codespace is running, GitHub provides several helpful buttons and information:
- Workspace Information: You can view details about the current workspace, including its configuration, status, and other relevant metadata.
- Limits and Costs: A button will display important details about the workspace limits (e.g., CPU, memory) and associated costs (if applicable). This is useful for understanding resource usage and optimizing your cloud environment.
- Stopping the Codespace: You can stop the Codespace at any time to free up resources or save costs. Simply click the "Stop" button from the GitHub interface.
- To stop your Codespace, click the "Stop" button from the GitHub interface.
- To restart it, simply click "Reopen in Codespace", and GitHub will restore your environment and continue where you left off.