Skip to content

Commit 2f75d95

Browse files
authored
Chore: devcontainer cleanups, update python version (#34)
2 parents ee91ff7 + 6008fc1 commit 2f75d95

File tree

14 files changed

+89
-54
lines changed

14 files changed

+89
-54
lines changed

.devcontainer/Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM python:3.10
1+
ARG PYTHON_VERSION=3.11
2+
3+
FROM python:${PYTHON_VERSION}
24

35
ENV PYTHONDONTWRITEBYTECODE=1 \
46
PYTHONUNBUFFERED=1 \
@@ -15,7 +17,7 @@ USER $USER
1517
WORKDIR /home/$USER/src
1618

1719
# update PATH for local pip installs
18-
ENV PATH "$PATH:/home/$USER/.local/bin"
20+
ENV PATH="$PATH:/home/$USER/.local/bin"
1921

2022
# upgrade pip
2123
RUN python -m pip install --upgrade pip

.devcontainer/devcontainer.json

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
{
22
"name": "compilerla/template-devcontainer",
3-
"dockerComposeFile": ["compose.yml"],
3+
"dockerComposeFile": ["../compose.yml"],
44
"service": "dev",
55
"runServices": ["dev", "docs"],
66
"workspaceFolder": "/home/compiler/src",
77
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],
8-
// Set *default* container specific settings.json values on container create.
9-
"settings": {
10-
"terminal.integrated.defaultProfile.linux": "bash",
11-
"terminal.integrated.profiles.linux": {
12-
"bash": {
13-
"path": "/bin/bash"
14-
}
8+
"customizations": {
9+
"vscode": {
10+
// Set *default* container specific settings.json values on container create.
11+
"settings": {
12+
"terminal.integrated.defaultProfile.linux": "bash",
13+
"terminal.integrated.profiles.linux": {
14+
"bash": {
15+
"path": "/bin/bash"
16+
}
17+
}
18+
},
19+
// Add the IDs of extensions you want installed when the container is created.
20+
"extensions": [
21+
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
22+
"DavidAnson.vscode-markdownlint",
23+
"eamodio.gitlens",
24+
"esbenp.prettier-vscode",
25+
"mhutchie.git-graph"
26+
]
1527
}
16-
},
17-
// Add the IDs of extensions you want installed when the container is created.
18-
"extensions": [
19-
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
20-
"DavidAnson.vscode-markdownlint",
21-
"eamodio.gitlens",
22-
"esbenp.prettier-vscode",
23-
"mhutchie.git-graph"
24-
]
28+
}
2529
}

.devcontainer/devcontainer.pre-built.json

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@
22
"name": "compilerla/template-devcontainer-pre-built",
33
"image": "ghcr.io/compilerla/template-devcontainer:main",
44
"postAttachCommand": "pre-commit install --overwrite",
5-
// Set *default* container specific settings.json values on container create.
6-
"settings": {
7-
"terminal.integrated.defaultProfile.linux": "bash",
8-
"terminal.integrated.profiles.linux": {
9-
"bash": {
10-
"path": "/bin/bash"
11-
}
5+
"customizations": {
6+
"vscode": {
7+
// Set *default* container specific settings.json values on container create.
8+
"settings": {
9+
"terminal.integrated.defaultProfile.linux": "bash",
10+
"terminal.integrated.profiles.linux": {
11+
"bash": {
12+
"path": "/bin/bash"
13+
}
14+
}
15+
},
16+
// Add the IDs of extensions you want installed when the container is created.
17+
"extensions": [
18+
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
19+
"DavidAnson.vscode-markdownlint",
20+
"eamodio.gitlens",
21+
"esbenp.prettier-vscode",
22+
"mhutchie.git-graph"
23+
]
1224
}
13-
},
14-
// Add the IDs of extensions you want installed when the container is created.
15-
"extensions": [
16-
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
17-
"DavidAnson.vscode-markdownlint",
18-
"eamodio.gitlens",
19-
"esbenp.prettier-vscode",
20-
"mhutchie.git-graph"
21-
]
25+
}
2226
}

.devcontainer/postAttach.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
set -eux
33

44
# initialize pre-commit
5+
git config --global --add safe.directory /home/$USER/src
56
pre-commit install --overwrite

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# default to engineering team
2+
* @compilerla/engineering

.github/workflows/publish-devcontainer.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,41 @@ defaults:
1313
jobs:
1414
publish:
1515
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.10", "3.11", "3.12"]
1619

1720
steps:
1821
- name: Checkout
1922
uses: actions/checkout@v4
2023

21-
- name: Docker Login to GitHub Container Registry
24+
- name: Docker Login to GHCR
2225
uses: docker/login-action@v3
2326
with:
2427
registry: ghcr.io
2528
username: ${{ github.actor }}
2629
password: ${{ secrets.GITHUB_TOKEN }}
2730

31+
- name: Set up QEMU
32+
uses: docker/setup-qemu-action@v3
33+
2834
- name: Set up Docker Buildx
2935
id: buildx
3036
uses: docker/setup-buildx-action@v3
3137

32-
- name: Build, tag, and push image to GitHub Container Registry
38+
- name: Build, tag, and push image to GHCR [python ${{ matrix.python-version }}]
3339
uses: docker/build-push-action@v6
3440
with:
3541
builder: ${{ steps.buildx.outputs.name }}
36-
build-args: GIT-SHA=${{ github.sha }}
42+
build-args: |
43+
GIT-SHA=${{ github.sha }}
44+
PYTHON_VERSION=${{ matrix.python-version }}
3745
cache-from: type=gha,scope=compilerla
3846
cache-to: type=gha,scope=compilerla,mode=max
3947
context: .
4048
file: .devcontainer/Dockerfile
49+
platforms: linux/amd64,linux/arm64
4150
push: true
4251
tags: |
43-
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
44-
ghcr.io/${{ github.repository }}:${{ github.sha }}
52+
${{ matrix.python-version == '3.11' && format('ghcr.io/{0}:main', github.repository) || format('ghcr.io/{0}:main_{1}', github.repository, matrix.python-version) }}
53+
${{ matrix.python-version == '3.11' && format('ghcr.io/{0}:{1}', github.repository, github.sha) || format('ghcr.io/{0}:{1}_{2}', github.repository, github.sha, matrix.python-version) }}

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@ A [template repository][template-repo] with a minimal [VS Code devcontainer][dev
44

55
Read the full documentation online: <https://compilerla.github.io/template-devcontainer>
66

7+
## Why?
8+
9+
Read more in our blog post: [How to support a platform-agnostic engineering team with VS Code Dev Containers](https://compiler.la/blog/2024/devcontainer-platform-agnostic-team).
10+
711
## Features
812

9-
- Base Docker image `python:3.10` includes support for common dev tooling like `git`, `curl`, `pip`, and `pre-commit`
13+
- Base Docker image `python:3.11` includes support for common dev tooling like `git`, `curl`, `pip`, and `pre-commit`
1014
- Includes VS Code extensions like [`GitLens`][gitlens] and [`Prettier`][prettier] and good default settings for the editor
1115
- The [`pre-commit` configuration][pre-commit-config] includes a number of useful [`pre-commit-hooks`][pre-commit-hooks] and
1216
Compiler's [`conventional-pre-commit`][conventional-pre-commit] hook
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: compilerla/template-devcontainer
1+
name: template-devcontainer
22

33
services:
44
dev:
55
build:
6-
context: ..
6+
context: .
77
dockerfile: .devcontainer/Dockerfile
88
image: compilerla/template-devcontainer:main
99
volumes:
10-
- ../:/home/compiler/src
10+
- ./:/home/compiler/src
1111

1212
docs:
1313
image: compilerla/template-devcontainer:main
@@ -16,4 +16,4 @@ services:
1616
ports:
1717
- "8000"
1818
volumes:
19-
- ../:/home/compiler/src
19+
- ./:/home/compiler/src

docs/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Docs are built using [`mkdocs`](https://www.mkdocs.org/). This site is built usi
2020

2121
In no particular order, here are some reasons Compiler likes to use devcontainers as part of our software engineering workflow:
2222

23+
_Read more in our blog post: [How to support a platform-agnostic engineering team with VS Code Dev Containers](https://compiler.la/blog/2024/devcontainer-platform-agnostic-team)_.
24+
2325
| Reason | More |
2426
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
2527
| **Cross-platform** | With only VS Code and Docker as dependencies, devcontainers allow developers on Linux, Mac, and Windows to work in a consistent environment, no matter the project's stack |
@@ -37,7 +39,7 @@ Some of our recent work built on the devcontainer pattern includes:
3739
- [`cal-itp/benefits`](https://github.com/cal-itp/benefits) (Python/Django web app)
3840
- [`cal-itp/eligibility-api`](https://github.com/cal-itp/eligibility-api) (Python API library)
3941
- [`cal-itp/eligibility-server`](https://github.com/cal-itp/eligibility-server) (Python/Flask API server)
40-
- [`cal-itp/hashfields`](https://github.com/cal-itp/hashfields) (.NET core CLI tool)
42+
- [`cal-itp/hashfields`](https://github.com/cal-itp/hashfields) (Python CLI tool)
43+
- [`cal-itp/mobility-marketplace`](https://github.com/cal-itp/mobility-marketplace) (Jekyll static site)
4144
- [`compilerla/compiler.la`](https://github.com/compilerla/compiler.la) (Jekyll static site)
4245
- [`compilerla/conventional-pre-commit`](https://github.com/compilerla/conventional-pre-commit) (Python pre-commit hook)
43-
- [`compilerla/intake-html-table`](https://github.com/compilerla/intake-html-table) (Python intake plugin)

docs/features/devcontainer.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The devcontainer's image is called `compilerla/template-devcontainer`.
2424

2525
### Base
2626

27-
The image is based on [`python:3.10`](https://hub.docker.com/_/python), to ease installation of common tooling like
27+
The image is based on [`python:3.11`](https://hub.docker.com/_/python), to ease installation of common tooling like
2828
[`mkdocs`](docs.md) and [`pre-commit`](pre-commit.md).
2929

3030
### Setup

0 commit comments

Comments
 (0)