Skip to content

Commit

Permalink
build: use SDK Container Building Tools for building Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
mu88 committed Nov 11, 2023
1 parent 5b4f2e3 commit c4e8b21
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 50 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ on:

jobs:
CI:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up .NET
Expand All @@ -32,17 +30,7 @@ jobs:
run: dotnet test --no-build /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: End Sonar scan
run: dotnet sonarscanner end /d:sonar.login=${{ secrets.SONAR_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker
id: docker_build
uses: docker/build-push-action@v5
with:
file: RaspiFanController/Dockerfile
run: |
dotnet publish RaspiFanController/RaspiFanController.csproj --os linux --arch x64 /t:PublishContainer -c Release
dotnet publish RaspiFanController/RaspiFanController.csproj --os linux --arch arm64 /t:PublishContainer -c Release
22 changes: 6 additions & 16 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0'
Expand All @@ -21,26 +21,16 @@ jobs:
run: dotnet build --configuration Release --no-restore
- name: .NET Test
run: dotnet test --no-build --configuration Release --verbosity normal
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: registry.hub.docker.com
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Docker and push
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
provenance: false
platforms: linux/arm64,linux/amd64
tags: |
mu88/raspifancontroller:latest
mu88/raspifancontroller:${{ github.ref_name }}
file: RaspiFanController/Dockerfile
- name: Build Docker and Push
run: |
dotnet publish RaspiFanController/RaspiFanController.csproj --os linux --arch x64 /t:PublishContainer -c Release '-p:ContainerImageTags="${{ github.ref_name }};latest"' -p:ContainerRegistry=registry.hub.docker.com
dotnet publish RaspiFanController/RaspiFanController.csproj --os linux --arch arm64 /t:PublishContainer -c Release '-p:ContainerImageTags="${{ github.ref_name }};latest"' -p:ContainerRegistry=registry.hub.docker.com
- name: .NET Publish
run: dotnet publish RaspiFanController/RaspiFanController.csproj -r linux-arm64 -c Release /p:PublishSingleFile=true --self-contained
- name: Create artifact
Expand Down
19 changes: 0 additions & 19 deletions RaspiFanController/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions RaspiFanController/RaspiFanController.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<ContainerRepository>mu88/raspifancontroller</ContainerRepository>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit c4e8b21

Please sign in to comment.