The Power of Dev Containers and GitHub Codespaces

Chris Ayers

Chris Ayers

Senior Customer Engineer
Microsoft

Twitter: @Chris_L_Ayers
Mastodon: @Chrisayers@hachyderm.io
LinkedIn: - chris-l-ayers
Blog: https://chris-ayers.com/
GitHub: Codebytes

Agenda

  • Prerequisites
  • What are Dev Containers?
  • How Dev Containers Work?
  • Why use Dev Containers?
  • How to build a Dev Containers?

Prerequisites

DevContainers

  • VSCode
    • Dev Containers Extension
    • GitHub Codespaces Extension
  • IntelliJ IDEA

Docker

  • Docker installed locally
  • Docker installed on a remote environment
  • Other Docker compliant CLIs, installed locally or remotely

GitHub Codespaces Requirement

  • GitHub Account
  • GitHub Codespaces

What are Dev Containers?

  • Environments that run in a container
  • Containers that let you open or mount any folder and still use VS Code UI and tooling
  • Places to run Apps, Tools, or Runtimes needed for a project or codebase
  • Containers.dev - An open specification for enriching containers with development specific content and settings.

Why use Dev Containers?

  • Onboard new People
  • Use consistent tooling
  • Use consistent versions
  • Reduce System Conflicts
  • Perform Startup Tasks

Inner and Outer Loops

How Dev Containers Work

Dev Containers

Where do Dev Containers Live?

devcontainer folder

Multiple Dev Container Configurations

Tooling supports multiple devcontainers.
Each one should be in its own subdirectory at:

.devcontainer/SUBDIRECTORY/devcontainer.json.

How do you build a Dev Container?

From the Command Pallet

Add Dev Container files

Which Dev Container do I Pick?

Add Options

Templates

Full List: https://containers.dev/templates

  • Base (Alpine, Debian, Ubuntu)
  • Language Based (C#, C++, Java, Go, Node, Python, Rust, Ruby, PHP)
  • Tool Focused (Markdown, Kubernetes, Docker, Jekyll)

Customizations

  • Features
  • Extensions
  • Settings
  • Startup Tasks
  • Networking

Features

Full list here: https://containers.dev/features

  • CLIs (azure, gh, gcp, aws)
  • Tools (Terraform, kubernetes...)
  • Runtimes (Node, Python, Go, Java, .NET, PHP, Ruby, Rust, C/C++, C#)

Configuration Loop

Configuration Loop

GitHub Codespaces

  • Don't need to worry about Docker Desktop
  • VSCode, IntelliJ, Browser
  • From 2 cores up to 16 cores w/ 64GB of RAM
  • Default universal DevContainers
  • Codespaces only offers Linux as the OS and x86_64 as the Architecture

GitHub Codespaces Architecture

GitHub Codespace templates

https://github.com/codespaces/templates

DEMO TIME

Resources