Development Container - gh05tdog/DAPM_Master_Thesis_Group_D GitHub Wiki

Development Container Setup

What is a Development Container?

A development container (or devcontainer) is a pre-configured, containerized environment designed for software development. It contains everything required to build, test, and run your code in an isolated environment. This includes the operating system, libraries, frameworks, language runtimes, and developer tools like version control or debugging extensions.

In this project, the devcontainer is set up using a devcontainer.json file. This configuration ensures that every developer works in a consistent environment, reducing potential issues caused by differences in local machine setups.

Advantages of Using a Development Container

  1. Consistency Across Environments: All team members, regardless of their local system configuration, work within the same development environment. This reduces "it works on my machine" problems.

  2. Ease of Onboarding: New developers can quickly get started without having to manually install and configure dependencies. They simply open the project in VS Code, and the devcontainer will configure the development environment automatically.

  3. Isolation: The devcontainer runs in a Docker container, ensuring the local machine remains unaffected by changes in the development environment, and different projects can run with different configurations without conflict.

  4. Simplified Collaboration: By having a consistent and reproducible development environment, collaboration becomes easier, as everyone is using the same setup.

  5. Version Control of the Environment: The configuration is stored as code (devcontainer.json), meaning changes to the development environment can be tracked and versioned alongside the project code.

How to Set Up the Devcontainer

Setting up the devcontainer for this project is straightforward. Follow the steps below:

Prerequisites

  • Docker: Ensure Docker is installed on your system to run containers.
  • Visual Studio Code (VS Code): Install the Remote - Containers extension for working with devcontainers.

Steps

  1. Open the Project in VS Code: Navigate to the root of the project in VS Code.

  2. Reopen the Folder in the Container: VS Code will detect the devcontainer.json file and prompt you to reopen the project in a development container. If not prompted, use the Command Palette (Ctrl + Shift + P) and search for Remote-Containers: Reopen in Container.

  3. Wait for the Devcontainer to Build: VS Code will automatically build the devcontainer using the configuration defined in devcontainer.json. It may take a few minutes on the first run as it pulls the necessary Docker image and installs extensions.

  4. Start Coding: Once the container is up and running, you’ll be inside the pre-configured development environment. You can use all the standard tools like Git, run tests, or debug your code without any further setup.

Devcontainer Configuration

In this project, the devcontainer uses the following setup:

  • Base Image: The development environment is based on the mcr.microsoft.com/dotnet/sdk:8.0 Docker image, which includes .NET SDK 8 for building and running C# projects.

  • Features: The devcontainer includes several features to enhance productivity:

    • common-utils: A set of common command-line utilities.
    • docker-in-docker: Allows running Docker commands within the container.
    • github-cli: Adds the GitHub CLI for managing GitHub repositories.
    • fish: Provides the Fish shell for an enhanced command-line experience.
    • sonarlint: A tool for static code analysis with support for C# and other languages.
  • VS Code Extensions:

    • .NET Runtime: Ensures the latest runtime and tooling for .NET development.
    • C# Development Kit: Adds C# support, syntax highlighting, and IntelliSense.
    • GitHub Copilot: Provides AI-assisted coding features.

Conclusion

By using a devcontainer, this project ensures that all team members are working in an identical, isolated environment. This setup minimizes environment-related issues, speeds up onboarding, and enhances productivity, allowing the team to focus on development rather than environment configuration.

Disclaimer

This was created with the help of prompt engineering. Needs to be reformulated for report usage.