Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve devcontainer image build and push #2856

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .devcontainer/FreeRTOS-NXP/Dockerfile.FreeRTOS-NXP
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
FROM ghcr.io/nanoframework/dev-container-freertos-nxp:v1.01
LABEL org.website="https://nanoframework.net/"
LABEL description="This is dockerfile image for NXP targets"
21 changes: 13 additions & 8 deletions .github/workflows/devcontainer-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Build Dev Container for all platforms
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-all
CONTAINER_SRC_FILE: .devcontainer/All/Dockerfile.All.SRC
CONTAINER_SOURCE_FILE: .devcontainer/All/Dockerfile.All.SRC
CONTAINER_VERSION_FILE: .devcontainer/All/Dockerfile.All

on:
push:
Expand All @@ -21,8 +22,11 @@ jobs:
build:
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
runs-on: ubuntu-latest
steps:
permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

Expand All @@ -35,28 +39,29 @@ jobs:
large-packages: false

- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content(".devcontainer/All/Dockerfile.All")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

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

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
21 changes: 13 additions & 8 deletions .github/workflows/devcontainer-azurertos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Build Dev Container for Azure RTOS
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-azure-rtos
CONTAINER_SRC_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
CONTAINER_SOURCE_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS.SRC
CONTAINER_VERSION_FILE: .devcontainer/AzureRTOS/Dockerfile.AzureRTOS

on:
push:
Expand All @@ -21,8 +22,11 @@ jobs:
build:
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:

- name: Checkout Repository
uses: actions/checkout@v4

Expand All @@ -35,28 +39,29 @@ jobs:
large-packages: false

- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content(".devcontainer/AzureRTOS/Dockerfile.AzureRTOS")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

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

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/devcontainer-chibios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Build Dev Container for ChibiOS
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-chibios
CONTAINER_SRC_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
CONTAINER_SOURCE_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS.SRC
CONTAINER_VERSION_FILE: .devcontainer/ChibiOS/Dockerfile.ChibiOS

on:
push:
Expand All @@ -21,8 +22,11 @@ jobs:
build:
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
runs-on: ubuntu-latest
steps:
permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

Expand All @@ -35,28 +39,29 @@ jobs:
large-packages: false

- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content(".devcontainer/ChibiOS/Dockerfile.ChibiOS")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

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

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
16 changes: 9 additions & 7 deletions .github/workflows/devcontainer-esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Build Dev Container for ESP32
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-esp32
CONTAINER_SRC_FILE: .devcontainer/ESP32/Dockerfile.ESP32.SRC
CONTAINER_SOURCE_FILE: .devcontainer/ESP32/Dockerfile.ESP32.SRC
CONTAINER_VERSION_FILE: .devcontainer/ESP32/Dockerfile.ESP32

on:
push:
Expand Down Expand Up @@ -35,28 +36,29 @@ jobs:
large-packages: false

- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content(".devcontainer/ESP32/Dockerfile.ESP32")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

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

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
2 changes: 1 addition & 1 deletion .github/workflows/devcontainer-freertos-nxp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}") -First 1
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/devcontainer-ti.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ name: Build Dev Container for TI
env:
CONTAINER_REPO: ghcr.io
CONTAINER_NAME: dev-container-ti
CONTAINER_SRC_FILE: .devcontainer/TI/Dockerfile.TI.SRC
CONTAINER_SOURCE_FILE: .devcontainer/TI/Dockerfile.TI.SRC
CONTAINER_VERSION_FILE: .devcontainer/TI/Dockerfile.TI

on:
push:
Expand All @@ -21,8 +22,11 @@ jobs:
build:
if: ${{ vars.PUBLISH_DOCKER_IMAGE == 'true' }}
runs-on: ubuntu-latest
steps:
permissions:
contents: read
packages: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

Expand All @@ -35,28 +39,29 @@ jobs:
large-packages: false

- name: Get container version
shell: pwsh
run: |
$dockerfileContent = Get-Content(".devcontainer/TI/Dockerfile.TI")
$dockerfileContent = Get-Content("${{ env.CONTAINER_VERSION_FILE }}")
$dockerfileContent -match '(?<=\:)(?:[v]\d+.\d+)'
$containerVersion = $Matches[0].ToString()
echo "GCR_VERSION=$containerVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
shell: pwsh

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

- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.CONTAINER_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.CONTAINER_BUILD_TOKEN }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
file: ${{ env.CONTAINER_SRC_FILE }}
push: true # Will only build if this is not here
file: ${{ env.CONTAINER_SOURCE_FILE }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:${{ env.GCR_VERSION }}
${{ env.CONTAINER_REPO }}/${{ github.repository_owner }}/${{ env.CONTAINER_NAME }}:latest
Loading