Skip to content

Commit

Permalink
docker-in-docker (dind) devcontainer image to be used for labs (#2058)
Browse files Browse the repository at this point in the history
* devcontainer init

* fix name

* cleanup devcontainer setup

* set user to "user" staticly
  • Loading branch information
hellt committed Jun 2, 2024
1 parent 2b735d9 commit 0559eec
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/containers/dind/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM public.ecr.aws/docker/library/debian:12-slim

# Switch to user
USER user
ENV PATH=$PATH:/home/${USERNAME}/.local/bin
32 changes: 32 additions & 0 deletions .github/containers/dind/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"build": {
"dockerfile": "./Dockerfile",
"context": "."
// "args": {
// "USERNAME": "${localEnv:USERNAME}"
// }
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"dockerDashComposeVersion": "none"
},
// Add sshd to support gh cli codespace cp.
"ghcr.io/devcontainers/features/sshd:1": {
"version": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
// Python.
"ms-python.python",
"ms-python.vscode-pylance",
// Errors and highlighters.
"mechatroner.rainbow-csv",
"oderwat.indent-rainbow"
]
}
}
}
47 changes: 47 additions & 0 deletions .github/workflows/build-devcontainer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: dind-devcontainer
on:
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
dind-devcontainer:
name: lint
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
# git short commit
type=sha
- name: Pre-build dev container image 🔨
uses: devcontainers/ci@v0.3
# env:
# USERNAME: ${{ inputs.username }}
# UID: ${{ inputs.user_id }}
# GID: ${{ inputs.group_id }}
with:
subFolder: .github/containers/dind
imageName: ghcr.io/${{ github.repository }}/clab-dind
imageTag: ${{ steps.meta.outputs.tags }}
push: always

0 comments on commit 0559eec

Please sign in to comment.