Skip to content

Commit 9fc6f4a

Browse files
author
David Stenglein
committed
Initial commit of devcontainer build in GitHub Actions
Signed-off-by: David Stenglein <[email protected]>
1 parent 5a70c75 commit 9fc6f4a

File tree

3 files changed

+175
-1
lines changed

3 files changed

+175
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Build and Publish Devcontainer
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main ]
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Log in to the Container registry
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Install devcontainer CLI
37+
run: npm install -g @devcontainers/cli
38+
39+
- name: Extract metadata (tags, labels) for Docker
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44+
tags: |
45+
type=semver,pattern={{version}}
46+
type=semver,pattern={{major}}.{{minor}}
47+
type=semver,pattern={{major}}
48+
type=ref,event=branch
49+
type=ref,event=pr
50+
type=sha
51+
latest
52+
53+
- name: Build and push container image
54+
run: |
55+
devcontainer build --workspace-folder . --image-name ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} --push

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
11
# devcontainer-python-node-claude
2-
Repo for a common build of a devcontainer
2+
3+
A reusable development container (devcontainer) with Python 3.12, Node.js, and additional tools pre-installed. This container is built and published to GitHub Container Registry (ghcr.io) for easy reuse across projects.
4+
5+
## Features
6+
7+
This devcontainer includes:
8+
9+
- Python 3.12 (Bullseye)
10+
- Node.js
11+
- Poetry (Python dependency management)
12+
- GitHub CLI
13+
- Docker-outside-of-Docker support
14+
- Pack CLI (Buildpacks)
15+
- SQLite
16+
17+
## How It's Built and Published
18+
19+
This devcontainer is automatically built and published to GitHub Container Registry using GitHub Actions. The workflow:
20+
21+
1. Triggers on pushes to the main branch, tag creation, and pull requests
22+
2. Uses the devcontainer CLI to build the container
23+
3. Publishes the container to GitHub Container Registry (ghcr.io)
24+
25+
## How to Use
26+
27+
### In a GitHub Codespace or VS Code
28+
29+
1. Create a `.devcontainer/devcontainer.json` file in your project with:
30+
31+
```json
32+
{
33+
"image": "ghcr.io/YOUR-USERNAME/devcontainer-python-node-claude:latest",
34+
"forwardPorts": [],
35+
"customizations": {
36+
"vscode": {
37+
"extensions": [
38+
// Add your preferred extensions here
39+
]
40+
}
41+
}
42+
}
43+
```
44+
45+
Replace `YOUR-USERNAME` with your GitHub username.
46+
47+
### Available Tags
48+
49+
The container is published with several tags for flexible versioning:
50+
51+
- `latest`: The most recent build from the main branch
52+
- `vX.Y.Z`: Specific version (when tagged with a semantic version)
53+
- `vX.Y`: Major.Minor version
54+
- `vX`: Major version only
55+
- `main`: Latest build from the main branch
56+
- `sha-XXXXXXX`: Specific commit SHA
57+
58+
## Development
59+
60+
To modify this devcontainer:
61+
62+
1. Update the `devcontainer.json` file with your desired changes
63+
2. Push to the main branch or create a pull request
64+
3. The GitHub Actions workflow will automatically build and publish the updated container

devcontainer.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Python 3",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers-extra/features/bash-command:1": {
9+
"command": "(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.37.0/pack-v0.37.0-linux.tgz\" | sudo tar -C /usr/local/bin/ --no-same-owner -xzv pack)"
10+
},
11+
"ghcr.io/devcontainers/features/docker-outside-of-docker": {
12+
"version": "latest",
13+
},
14+
"ghcr.io/devcontainers-extra/features/poetry": {
15+
"version": "1.8.2",
16+
17+
},
18+
"ghcr.io/devcontainers/features/github-cli:1": {
19+
"installDirectlyFromGitHubRelease": true,
20+
"version": "latest"
21+
},
22+
"ghcr.io/devcontainers/features/node:1": {},
23+
"ghcr.io/warrenbuckley/codespace-features/sqlite:latest": {}
24+
25+
},
26+
"customizations": {
27+
"vscode": {
28+
"extensions": [
29+
"RooVeterinaryInc.roo-cline",
30+
"bierner.markdown-mermaid"
31+
]
32+
}
33+
},
34+
35+
// Features to add to the dev container. More info: https://containers.dev/features.
36+
// "features": {},
37+
38+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
39+
// "forwardPorts": [],
40+
41+
// Use 'postCreateCommand' to run commands after the container is created.
42+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
43+
44+
// Configure tool-specific properties.
45+
// "customizations": {},
46+
47+
"remoteEnv": {
48+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${localEnv:GITHUB_PERSONAL_ACCESS_TOKEN}",
49+
},
50+
51+
// "runArgs" : [
52+
// "--network="
53+
// ]
54+
55+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
56+
// "remoteUser": "root"
57+
}

0 commit comments

Comments
 (0)