Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/actions/smoke-test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ shopt -s dotglob
SRC_DIR="/tmp/${TEMPLATE_ID}"
cp -R "src/${TEMPLATE_ID}" "${SRC_DIR}"

export DOCKER_BUILDKIT=1
echo "(*) Installing @devcontainer/cli"
npm install -g @devcontainers/cli

PREBUILD_DIR="prebuild/${TEMPLATE_ID}"
if [ -d "${PREBUILD_DIR}" ] ; then
RUNTIME_OPTION=$(jq -r '.options | keys[] | select(. != "azureFunctionsCliVersion")' "src/${TEMPLATE_ID}/devcontainer-template.json")
RUNTIME_VERSION=$(jq -r ".options | .${RUNTIME_OPTION} | .default" "src/${TEMPLATE_ID}/devcontainer-template.json")
PREBUILD_IMAGE="ghcr.io/shibayan/devcontainers/${TEMPLATE_ID}:${RUNTIME_VERSION}-noble"

if [ -z "${RUNTIME_OPTION}" ] || [ -z "${RUNTIME_VERSION}" ] || [ "${RUNTIME_VERSION}" = "null" ] ; then
echo "Unable to determine the runtime version for '${TEMPLATE_ID}'"
exit 1
fi

echo "(*) Building prebuild image '${PREBUILD_IMAGE}'"
export RUNTIME_VERSION
devcontainer build --workspace-folder "${PREBUILD_DIR}" --image-name "${PREBUILD_IMAGE}"
fi

pushd "${SRC_DIR}"

# Configure templates only if `devcontainer-template.json` contains the `options` property.
Expand Down Expand Up @@ -46,10 +66,6 @@ if [ -d "${TEST_DIR}" ] ; then
cp test/test-utils/* ${DEST_DIR}
fi

export DOCKER_BUILDKIT=1
echo "(*) Installing @devcontainer/cli"
npm install -g @devcontainers/cli

echo "Building Dev Container"
ID_LABEL="test-container=${TEMPLATE_ID}"
devcontainer up --id-label ${ID_LABEL} --workspace-folder "${SRC_DIR}"
135 changes: 135 additions & 0 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: "Prebuild Dev Container Images"

on:
workflow_dispatch:
push:
branches:
- master
paths:
- "prebuild/**"
- ".github/workflows/prebuild.yml"
- "src/*/devcontainer-template.json"
schedule:
- cron: "23 17 * * 0"

concurrency:
group: prebuild-dev-container-images
cancel-in-progress: false

jobs:
prepare:
runs-on: ubuntu-24.04
outputs:
configs: ${{ steps.matrix.outputs.configs }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Generate prebuild matrix
id: matrix
shell: bash
run: |
configs=$(
for manifest in src/*/devcontainer-template.json; do
template=$(basename "$(dirname "${manifest}")")
jq -c --arg template "${template}" '
[
.options
| to_entries[]
| select(.key != "azureFunctionsCliVersion")
| .value.proposals[] as $runtime
| { template: $template, runtime: $runtime }
]
' "${manifest}"
done | jq -sc 'add'
)
echo "configs=${configs}" >> "${GITHUB_OUTPUT}"

build:
needs: prepare
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
config: ${{ fromJSON(needs.prepare.outputs.configs) }}
os:
- ubuntu-24.04
- ubuntu-24.04-arm
env:
RUNTIME_VERSION: ${{ matrix.config.runtime }}
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/devcontainers/${{ matrix.config.template }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Log in to GitHub Container Registry
shell: bash
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin

- name: Install Dev Container CLI
shell: bash
run: npm install --global @devcontainers/cli

- name: Build and push architecture image
shell: bash
env:
RUNNER_ARCHITECTURE: ${{ runner.arch }}
run: |
case "${RUNNER_ARCHITECTURE}" in
X64) architecture=amd64 ;;
ARM64) architecture=arm64 ;;
*) echo "Unsupported runner architecture: ${RUNNER_ARCHITECTURE}" >&2; exit 1 ;;
esac

devcontainer build \
--workspace-folder "prebuild/${{ matrix.config.template }}" \
--image-name "${IMAGE_NAME}:${RUNTIME_VERSION}-noble-${architecture}" \
--label "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}" \
--label "org.opencontainers.image.revision=${GITHUB_SHA}" \
--label "org.opencontainers.image.version=${RUNTIME_VERSION}-noble" \
--push true

merge:
needs:
- prepare
- build
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
config: ${{ fromJSON(needs.prepare.outputs.configs) }}
env:
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/devcontainers/${{ matrix.config.template }}
RUNTIME_VERSION: ${{ matrix.config.runtime }}
steps:
- name: Log in to GitHub Container Registry
shell: bash
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io --username "${{ github.actor }}" --password-stdin

- name: Create multi-architecture image
shell: bash
run: |
tag="${RUNTIME_VERSION}-noble"
dated_tag="${tag}-$(date -u +%Y%m%d)"
revision_tag="${tag}-sha-${GITHUB_SHA::7}"

docker buildx imagetools create \
--tag "${IMAGE_NAME}:${tag}" \
--tag "${IMAGE_NAME}:${dated_tag}" \
--tag "${IMAGE_NAME}:${revision_tag}" \
"${IMAGE_NAME}:${tag}-amd64" \
"${IMAGE_NAME}:${tag}-arm64"

- name: Verify image platforms
shell: bash
run: |
manifest=$(docker buildx imagetools inspect --raw "${IMAGE_NAME}:${RUNTIME_VERSION}-noble")
for architecture in amd64 arm64; do
jq -e --arg architecture "${architecture}" '
any(.manifests[]; .platform.os == "linux" and .platform.architecture == $architecture)
' <<< "${manifest}" > /dev/null
done
20 changes: 20 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Verify prebuild images
shell: bash
run: |
for manifest_path in src/*/devcontainer-template.json; do
template=$(basename "$(dirname "${manifest_path}")")
runtime_option=$(jq -r '.options | keys[] | select(. != "azureFunctionsCliVersion")' "${manifest_path}")

while IFS= read -r runtime_version; do
image="ghcr.io/${GITHUB_REPOSITORY_OWNER}/devcontainers/${template}:${runtime_version}-noble"
echo "Verifying ${image}"
manifest=$(docker buildx imagetools inspect --raw "${image}")

for architecture in amd64 arm64; do
jq -e --arg architecture "${architecture}" '
any(.manifests[]; .platform.os == "linux" and .platform.architecture == $architecture)
' <<< "${manifest}" > /dev/null
done
done < <(jq -r ".options.${runtime_option}.proposals[]" "${manifest_path}")
done

- name: "Publish Templates"
uses: devcontainers/action@1082abd5d2bf3a11abccba70eef98df068277772 # v1.4.3
with:
Expand Down
43 changes: 36 additions & 7 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,46 @@ jobs:
id: filter
with:
filters: |
azure-functions-dotnet: ./**/azure-functions-dotnet/**
azure-functions-go: ./**/azure-functions-go/**
azure-functions-java: ./**/azure-functions-java/**
azure-functions-node: ./**/azure-functions-node/**
azure-functions-powershell: ./**/azure-functions-powershell/**
azure-functions-python: ./**/azure-functions-python/**
azure-functions-dotnet:
- ./**/azure-functions-dotnet/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml
azure-functions-go:
- ./**/azure-functions-go/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml
azure-functions-java:
- ./**/azure-functions-java/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml
azure-functions-node:
- ./**/azure-functions-node/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml
azure-functions-powershell:
- ./**/azure-functions-powershell/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml
azure-functions-python:
- ./**/azure-functions-python/**
- .github/actions/smoke-test/**
- .github/workflows/prebuild.yml
- test/test-utils/**
- .github/workflows/test-pr.yml

test:
needs: [detect-changes]
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
templates: ${{ fromJSON(needs.detect-changes.outputs.templates) }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ A collection of [Dev Container Templates](https://containers.dev/implementors/te

> All templates include the Azure Functions Core Tools (version selectable, default: `latest`).

All language runtimes are provided through prebuilt Ubuntu 24.04 images for both AMD64 and ARM64. The templates add the selected Azure Functions Core Tools version when the development container is created.

## Usage

1. Open the Command Palette in VS Code and select **Dev Containers: Add Dev Container Configuration Files...**
Expand Down
2 changes: 2 additions & 0 deletions prebuild/azure-functions-dotnet/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG RUNTIME_VERSION
FROM mcr.microsoft.com/devcontainers/dotnet:${RUNTIME_VERSION}-noble
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Azure Functions (.NET) Prebuild",
"build": {
"dockerfile": "Dockerfile",
"args": {
"RUNTIME_VERSION": "${localEnv:RUNTIME_VERSION}"
}
}
}
1 change: 1 addition & 0 deletions prebuild/azure-functions-go/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
11 changes: 11 additions & 0 deletions prebuild/azure-functions-go/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Azure Functions (Go) Prebuild",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "${localEnv:RUNTIME_VERSION}"
}
}
}
1 change: 1 addition & 0 deletions prebuild/azure-functions-java/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
12 changes: 12 additions & 0 deletions prebuild/azure-functions-java/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Azure Functions (Java) Prebuild",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "${localEnv:RUNTIME_VERSION}",
"installMaven": true
}
}
}
1 change: 1 addition & 0 deletions prebuild/azure-functions-node/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
11 changes: 11 additions & 0 deletions prebuild/azure-functions-node/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Azure Functions (Node.js) Prebuild",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "${localEnv:RUNTIME_VERSION}"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/dotnet:8.0-noble
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Azure Functions (PowerShell) Prebuild",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/powershell:1": {
"version": "${localEnv:RUNTIME_VERSION}"
}
}
}
1 change: 1 addition & 0 deletions prebuild/azure-functions-python/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
12 changes: 12 additions & 0 deletions prebuild/azure-functions-python/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Azure Functions (Python) Prebuild",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "${localEnv:RUNTIME_VERSION}",
"installTools": false
}
}
}
2 changes: 1 addition & 1 deletion src/azure-functions-dotnet/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mcr.microsoft.com/devcontainers/dotnet:${templateOption:dotnetVersion}-noble
FROM ghcr.io/shibayan/devcontainers/azure-functions-dotnet:${templateOption:dotnetVersion}-noble
2 changes: 1 addition & 1 deletion src/azure-functions-dotnet/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "azure-functions-dotnet",
"version": "2.0.5",
"version": "2.0.6",
"name": "Azure Functions (.NET)",
"description": "Develop C# and .NET based Azure Functions. Includes all needed SDKs, extensions, and dependencies.",
"documentationURL": "https://github.com/shibayan/devcontainers/tree/master/src/azure-functions-dotnet",
Expand Down
2 changes: 1 addition & 1 deletion src/azure-functions-go/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
FROM ghcr.io/shibayan/devcontainers/azure-functions-go:${templateOption:goVersion}-noble
3 changes: 0 additions & 3 deletions src/azure-functions-go/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"onAutoForward": "ignore"
},
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "${templateOption:goVersion}"
},
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {
"version": "${templateOption:azureFunctionsCliVersion}"
}
Expand Down
2 changes: 1 addition & 1 deletion src/azure-functions-go/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "azure-functions-go",
"version": "1.0.0",
"version": "1.0.1",
"name": "Azure Functions (Go)",
"description": "Develop Go based Azure Functions. Includes all needed SDKs, extensions, and dependencies.",
"documentationURL": "https://github.com/shibayan/devcontainers/tree/master/src/azure-functions-go",
Expand Down
2 changes: 1 addition & 1 deletion src/azure-functions-java/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM mcr.microsoft.com/devcontainers/base:noble
FROM ghcr.io/shibayan/devcontainers/azure-functions-java:${templateOption:javaVersion}-noble
4 changes: 0 additions & 4 deletions src/azure-functions-java/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
"onAutoForward": "ignore"
},
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "${templateOption:javaVersion}",
"installMaven": true
},
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {
"version": "${templateOption:azureFunctionsCliVersion}"
}
Expand Down
Loading