Skip to content

ministryofjustice/.devcontainer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Development Containers

repo standards badge

Contents

This repository was created by Ministry of Justice's Dev Container Community of Practice. The goal is to release a foundational image for deployment, develop features that boost developer efficiency, and set a benchmark for using containerised development environments within the Ministry of Justice. Additionally this repository serves documentation relating to the use and configuration of devcontainers within the Ministry of Justice.

Contact us on our Slack channel - #devcontainer-community.

Official documentation is located here.

Benefits of Development Containers

  1. Consistency Across Environments - Ensures that every developer in a team/project/product works with the same tools and configurations, reducing compatibility issues.

  2. Isolation from Local Machine - Keeps project-specific settings and dependencies separate from the local environment, avoiding conflicts.

  3. Simplified Onboarding - Allows new developers to quickly set up a pre-configured development environment, speeding up the onboarding process.

  4. Reproducibility - Enhances the reliability of builds and tests across different environments by maintaining consistent settings.

  5. Tool Integration - Offers seamless integration with development tools for efficient coding, debugging, and execution within the container.

  6. Portability - Enables developers to move their development environments across machines and platforms easily without reconfiguration.

  7. Ease of Updates - Facilitates straightforward updates and dependency management by allowing updates to be propagated through container images.

  8. GitHub Codespaces Integration - Enables developers to access fully configured development environments in the cloud via GitHub Codespaces, enhancing flexibility and accessibility.

Adding a Development Container to a Project

  1. Create a .devcontainer folder in the root of your project.
  2. Add a devcontainer.json file to the .devcontainer folder. There are a number of parameters which can be included in a devconatiner.json file, these are noted in detail here.
  3. Populate the devcontainer.json file with the required settings:
{
  "name": "devcontainer-example",
  "image": "ghcr.io/ministryofjustice/devcontainer-base:latest"
}

In the example above, the name parameter specifies the name of the development container, and the image parameter specifies the base image for the development container.

The ghcr.io/ministryofjustice/devcontainer-base image is an extension of mcr.microsoft.com/devcontainers/base:ubuntu-24.04. The enhancements are documented here.

What are Features?

In the context of the Ministry of Justice Development Container community, features are built by the community to satisfy the specific needs of our developers and the challenges they face on a day to day basis.

Features created in the Dev Container community are described here both can be consumed when constructing a Development Container. From this point on, we will refer to these features as "Community Features" and Ministry of Justice feature as "Features".

Features are built using the .devcontainer GitHub repository and are designed to be modular and reusable. This means that features can be combined to create a custom development environment that meets the needs of a specific project or team.

Features are can be used by Sofware Developers and those in Operations Roles to create consistent and reliable development environments for the applications and services they work on.

Ministry of Justice Features

Features are located in the features folder in the Development Container GitHub repository. Each feature is listed below.

AWS

The AWS feature installs the AWS CLI and AWS SSO CLI .

Cloud Platform

The Cloud Platform feature installs the Cloud Platform CLI.

Container Structure Tests

The Container Structure Tests feature installs the container-structure-test CLI, this tool provides a powerful framework to validate the structure of a container image.

Kubernetes

The Kubernetes feature installs:

  • kubectl - to interact with Kubernetes clusters

  • helm - the package manager for Kubernetes

  • ct - to lint and test Helm charts

Static Analysis

The Static Analysis feature installs:

Terraform

The Terraform feature installs the terraform CLI.

Creating a New Feature

To add a new feature:

  1. Clone the .devcontainer repository.
  2. Create a new feature in the .devcontainer GitHub repository.
  3. Add the feature to the Development Container Features documentation.
  4. Add tests for the feature in the .devcontainer GitHub repository.

Adding Features to a Development Container

To consume a feature, add the feature to the features array in the devcontainer.json file. An example of this is shown below:

{
  "name": "devcontainer-example",
  "image": "ghcr.io/ministryofjustice/devcontainer-base:latest",
  "features": {
    "ghcr.io/devcontainers/features/docker-in-docker:2": {},
    "ghcr.io/ministryofjustice/devcontainer-feature/container-structure-test:0": {},
    "ghcr.io/ministryofjustice/devcontainer-feature/static-analysis:0": {}
  }
}

In the example above, the features array includes the docker-in-docker, container-structure-test, and static-analysis features. Note that the docker-in-docker feature is a community feature, while the other two features are Ministry of Justice features. Both types of features can be consumed in the same way.

Contributing

The base branch requires all commits to be signed. Learn more about signing commits here.