Skip to content

Commit

Permalink
Improve devcontainer file structure (#2854)
Browse files Browse the repository at this point in the history
networkfusion authored Jan 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 3566af2 commit 641cd9e
Showing 24 changed files with 251 additions and 57 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"name": "nanoFramework",
// Adjust this file to choose the platform you want using the prebuild containers:
// - Dockerfile.All = you can build anything but it's a very large container
// - Dockerfile.AzureRTOS = for AzureRTOS targets
// - Dockerfile.ChibiOS = for ChibiOS based targets (ex: STM32, Netduino, Orgpal)
// - Dockerfile.ESP32 = for ESP32 targets
// - Dockerfile.TI = for TI targets
"name": "nanoFramework-All",
// If you prefer, you can use the source files and adjust them where they are located,
// To do this, prefix 'sources'. e.g. 'sources/Dockerfile.All'.
// To do this, change the "dockerFile" to use 'Dockerfile.All.SRC'.
// This will allow you to customize and build the container source and add anything you may need on top.
"dockerFile": "Dockerfile.All",
"context": ".",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions .devcontainer/AzureRTOS/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "nanoFramework-AzureRTOS",
// If you prefer, you can use the source files and adjust them where they are located,
// To do this, change the "dockerFile" to use 'Dockerfile.AzureRTOS.SRC'.
// This will allow you to customize and build the container source and add anything you may need on top.
"dockerFile": "Dockerfile.AzureRTOS",
"context": ".",
"mounts": [
// Bind the Unix socket the Docker daemon listens on by default
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
// Keep command history
"source=nano-bashhistory,target=/home/vscode/commandhistory,type=volume",
// OPTIONAL: Mount .azure folder for seamless az cli auth
// "source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind"
],
// Set the *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.generator": "Ninja",
"cmake.autoRestartBuild" : true,
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM":"/usr/bin/ninja"
},
"cmake.configureOnOpen": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vsliveshare.vsliveshare-pack",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"ms-vscode.cmake-tools",
"xaver.clang-format"
]
}
}
// You can pull all the repos with the latest changes, this is only valid if you are using the ./sources/Dockerfile.All containers
// "postAttachCommand": "/usr/local/git-pull-repos.sh"
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "terraform --version",
// Uncomment to connect as a non-root user. See https: //aka.ms/vscode-remote/containers/non-root.
// ,"remoteUser": "vscode"
}
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions .devcontainer/ChibiOS/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "nanoFramework-ChibiOS",
// Adjust this file to choose the platform you want using the prebuild containers:
// To do this, change the "dockerFile" to use 'Dockerfile.ChibiOS.SRC'.
// This will allow you to customize and build the container source and add anything you may need on top.
"dockerFile": "Dockerfile.ChibiOS",
"context": ".",
"mounts": [
// Bind the Unix socket the Docker daemon listens on by default
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
// Keep command history
"source=nano-bashhistory,target=/home/vscode/commandhistory,type=volume",
// OPTIONAL: Mount .azure folder for seamless az cli auth
// "source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind"
],
// Set the *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.generator": "Ninja",
"cmake.autoRestartBuild" : true,
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM":"/usr/bin/ninja"
},
"cmake.configureOnOpen": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vsliveshare.vsliveshare-pack",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"ms-vscode.cmake-tools",
"xaver.clang-format"
]
}
}
// You can pull all the repos with the latest changes, this is only valid if you are using the ./sources/Dockerfile.All containers
// "postAttachCommand": "/usr/local/git-pull-repos.sh"
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "terraform --version",
// Uncomment to connect as a non-root user. See https: //aka.ms/vscode-remote/containers/non-root.
// ,"remoteUser": "vscode"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/nanoframework/dev-container-esp32:v2.28
FROM ghcr.io/nanoframework/dev-container-esp32:v2.28
File renamed without changes.
48 changes: 48 additions & 0 deletions .devcontainer/ESP32/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "nanoFramework-ESP32",
// Adjust this file to choose the platform you want using the prebuild containers:
// To do this, change the "dockerFile" to use 'Dockerfile.ESP32.SRC'.
// This will allow you to customize and build the container source and add anything you may need on top.
"dockerFile": "Dockerfile.ESP32",
"context": ".",
"mounts": [
// Bind the Unix socket the Docker daemon listens on by default
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
// Keep command history
"source=nano-bashhistory,target=/home/vscode/commandhistory,type=volume",
// OPTIONAL: Mount .azure folder for seamless az cli auth
// "source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind"
],
// Set the *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.generator": "Ninja",
"cmake.autoRestartBuild" : true,
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM":"/usr/bin/ninja"
},
"cmake.configureOnOpen": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vsliveshare.vsliveshare-pack",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"ms-vscode.cmake-tools",
"xaver.clang-format"
]
}
}
// You can pull all the repos with the latest changes, this is only valid if you are using the ./sources/Dockerfile.All containers
// "postAttachCommand": "/usr/local/git-pull-repos.sh"
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "terraform --version",
// Uncomment to connect as a non-root user. See https: //aka.ms/vscode-remote/containers/non-root.
// ,"remoteUser": "vscode"
}
29 changes: 16 additions & 13 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This folder contains all the elements used for .NET nanoFramework dev container
# This folder contains all the elements used for .NET nanoFramework dev containers

You'll find Docker files for .NET nanoFramework. They are used to facilitate building images.

@@ -10,18 +10,21 @@ The available pre build images are:
* ghcr.io/nanoframework/dev-container-esp32: contains all elements to build a firmware image for any of the ESP32 targets
* ghcr.io/nanoframework/dev-container-azure-rtos: contains all elements to build a firmware image for any of the Azure RTOS targets

To choose the dev container you want to use, adjust `devcontainer.json` and change the `"dockerFile": "Dockerfile"` elements for the image you'd liked to use:

* `Dockerfile.All` to use the pre build container with all the elements to build a firmware image for any of the targets
* `Dockerfile.AzureRTOS` to use the pre build container with all the elements to build Azure RTOS targets
* `Dockerfile.ChibiOS` to use the pre build container with all the elements to build ChibiOS targets
* `Dockerfile.ESP32` to use the pre build container with all the elements to build ESP32 targets
* `Dockerfile.TI` to use the pre build container with all the elements to build TI SimpleLink targets
* `./sources/Dockerfile.All` to build the container image from the source with all the elements to build all the images
* `./sources/Dockerfile.AzureRTOS` to build the container image from the source with all the elements to build Azure RTOS based devices
* `./sources/Dockerfile.ChibiOS` to build the container image from the source with all the elements to build ChibiOS based devices
* `./sources/Dockerfile.ESP32` to build the container image from the source with all the elements to build ESP32 based devices
* `./sources/Dockerfile.TI` to build the container image from the source with all the elements to build TI SimpleLink based devices
You can choose the dev container needed when opening a remote container in VSCode. The options are:

* `nanoFramework-All` to use the pre build container with all the elements to build a firmware image for any of the targets
* `nanoFramework-AzureRTOS` to use the pre build container with all the elements to build Azure RTOS targets
* `nanoFramework-ChibiOS` to use the pre build container with all the elements to build ChibiOS targets
* `nanoFramework-ESP32` to use the pre build container with all the elements to build ESP32 targets
* `nanoFramework-TI` to use the pre build container with all the elements to build TI SimpleLink targets

To use the source dockerfile for the respective platform adjust its `devcontainer.json` file and change the `"dockerFile": "Dockerfile.<platform>"` element for the image you would like to use:

* `Dockerfile.All.SRC` to build the container image from the source with all the elements to build all the images
* `Dockerfile.AzureRTOS.SRC` to build the container image from the source with all the elements to build Azure RTOS based devices
* `Dockerfile.ChibiOS.SRC` to build the container image from the source with all the elements to build ChibiOS based devices
* `Dockerfile.ESP32.SRC` to build the container image from the source with all the elements to build ESP32 based devices
* `Dockerfile.TI.SRC` to build the container image from the source with all the elements to build TI SimpleLink based devices


## Building and releasing Docker images in a fork
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions .devcontainer/TI/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "nanoFramework-TI",
// Adjust this file to choose the platform you want using the prebuild containers:
// To do this, change the "dockerFile" to use 'Dockerfile.TI.SRC'.
// This will allow you to customize and build the container source and add anything you may need on top.
"dockerFile": "Dockerfile.TI",
"context": ".",
"mounts": [
// Bind the Unix socket the Docker daemon listens on by default
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
// Keep command history
"source=nano-bashhistory,target=/home/vscode/commandhistory,type=volume",
// OPTIONAL: Mount .azure folder for seamless az cli auth
// "source=${env:HOME}${env:USERPROFILE}/.azure,target=/home/vscode/.azure,type=bind"
],
// Set the *default* container specific settings.json values on container create.
"customizations": {
"vscode": {
"settings": {
"cmake.preferredGenerators": [
"Ninja"
],
"cmake.generator": "Ninja",
"cmake.autoRestartBuild" : true,
"cmake.configureSettings": {
"CMAKE_MAKE_PROGRAM":"/usr/bin/ninja"
},
"cmake.configureOnOpen": false
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vsliveshare.vsliveshare-pack",
"streetsidesoftware.code-spell-checker",
"twxs.cmake",
"ms-vscode.cmake-tools",
"xaver.clang-format"
]
}
}
// You can pull all the repos with the latest changes, this is only valid if you are using the ./sources/Dockerfile.All containers
// "postAttachCommand": "/usr/local/git-pull-repos.sh"
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "terraform --version",
// Uncomment to connect as a non-root user. See https: //aka.ms/vscode-remote/containers/non-root.
// ,"remoteUser": "vscode"
}
13 changes: 7 additions & 6 deletions .github/workflows/devcontainer-all.yaml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
name: Build Dev Container for all platforms

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-all
GCR_FILE: .devcontainer/sources/Dockerfile.All
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-all
CONTAINER_SRC_FILE: .devcontainer/All/Dockerfile.All.SRC

on:
push:
@@ -27,7 +28,7 @@ jobs:

- name: Get container version
run: |
$dockerfileContent = Get-Content(".devcontainer/Dockerfile.All")
$dockerfileContent = Get-Content(".devcontainer/All/Dockerfile.All")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -46,8 +47,8 @@ jobs:
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.GCR_FILE }}
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
tags: |
${{ env.GCR_IMAGE }}:${{ env.GCR_VERSION }}
${{ env.GCR_IMAGE }}:latest
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
13 changes: 7 additions & 6 deletions .github/workflows/devcontainer-azurertos.yaml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
name: Build Dev Container for Azure RTOS

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-azure-rtos
GCR_FILE: .devcontainer/sources/Dockerfile.AzureRTOS
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-azure-rtos
CONTAINER_SRC_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC

on:
push:
@@ -27,7 +28,7 @@ jobs:

- name: Get container version
run: |
$dockerfileContent = Get-Content(".devcontainer/Dockerfile.AzureRTOS")
$dockerfileContent = Get-Content(".devcontainer/AzureRTOS/Dockerfile.AzureRTOS")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -46,9 +47,9 @@ jobs:
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.GCR_FILE }}
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
tags: |
${{ env.GCR_IMAGE }}:${{ env.GCR_VERSION }}
${{ env.GCR_IMAGE }}:latest
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
13 changes: 7 additions & 6 deletions .github/workflows/devcontainer-chibios.yaml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
name: Build Dev Container for ChibiOS

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-chibios
GCR_FILE: .devcontainer/sources/Dockerfile.ChibiOS
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-chibios
CONTAINER_SRC_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC

on:
push:
@@ -27,7 +28,7 @@ jobs:

- name: Get container version
run: |
$dockerfileContent = Get-Content(".devcontainer/Dockerfile.ChibiOS")
$dockerfileContent = Get-Content(".devcontainer/ChibiOS/Dockerfile.ChibiOS")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -46,8 +47,8 @@ jobs:
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.GCR_FILE }}
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
tags: |
${{ env.GCR_IMAGE }}:${{ env.GCR_VERSION }}
${{ env.GCR_IMAGE }}:latest
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
13 changes: 7 additions & 6 deletions .github/workflows/devcontainer-esp32.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
name: Build Dev Container for ESP32

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-esp32
GCR_FILE: .devcontainer/sources/Dockerfile.ESP32
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-esp32
CONTAINER_SRC_FILE: .devcontainer/ESP32/Dockerfile.ESP32.SRC

on:
push:
@@ -27,7 +28,7 @@ jobs:

- name: Get container version
run: |
$dockerfileContent = Get-Content(".devcontainer/Dockerfile.ESP32")
$dockerfileContent = Get-Content(".devcontainer/ESP32/Dockerfile.ESP32")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -46,8 +47,8 @@ jobs:
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.GCR_FILE }}
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
tags: |
${{ env.GCR_IMAGE }}:${{ env.GCR_VERSION }}
${{ env.GCR_IMAGE }}:latest
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
10 changes: 5 additions & 5 deletions .github/workflows/devcontainer-smoketest.yaml
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@ name: Smoketest Dockerfile builds for selected targets
on:
pull_request:
paths:
- '.devcontainer/sources/*'
- '.devcontainer/**/*'
- '.github/workflows/*'
# push:
# paths:
# - '.devcontainer/sources/*'
# - '.devcontainer/**/*'
# - '.github/workflows/*'

jobs:
@@ -61,20 +61,20 @@ jobs:
- name: Adjust devcontainer.json for ${{ matrix.container }} source
run: |
# Move into the .devcontainer directory
pushd .devcontainer
pushd .devcontainer/${{ matrix.container }}
# Target the dockerfile source.
sed -i -- 's|"dockerFile": "Dockerfile.All"|"dockerFile": "sources/Dockerfile.${{ matrix.container }}"|g' devcontainer.json
sed -i -- 's|"dockerFile": "Dockerfile.${{ matrix.container }}"|"dockerFile": "Dockerfile.${{ matrix.container }}.SRC"|g' devcontainer.json
# Move out of the .devcontainer directory
popd
- name: Build ${{ matrix.target }} ${{ matrix.build-type }} Firmware
uses: devcontainers/ci@v0.3
with:
configFile: ./.devcontainer/${{ matrix.container }}/devcontainer.json
push: never
runCmd: |
# Build target:
cmake --preset=${{ matrix.target }} -DCMAKE_BUILD_TYPE=${{ matrix.build-type }}
cmake --build build
13 changes: 7 additions & 6 deletions .github/workflows/devcontainer-ti.yaml
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
name: Build Dev Container for TI

env:
GCR_IMAGE: ghcr.io/nanoframework/dev-container-ti
GCR_FILE: .devcontainer/sources/Dockerfile.TI
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-ti
CONTAINER_SRC_FILE: .devcontainer/TI/Dockerfile.TI.SRC

on:
push:
@@ -27,7 +28,7 @@ jobs:

- name: Get container version
run: |
$dockerfileContent = Get-Content(".devcontainer/Dockerfile.TI")
$dockerfileContent = Get-Content(".devcontainer/TI/Dockerfile.TI")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
@@ -46,8 +47,8 @@ jobs:
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.GCR_FILE }}
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
tags: |
${{ env.GCR_IMAGE }}:${{ env.GCR_VERSION }}
${{ env.GCR_IMAGE }}:latest
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest

0 comments on commit 641cd9e

Please sign in to comment.