setup-qemu-action icon indicating copy to clipboard operation
setup-qemu-action copied to clipboard

Qemu in Github Action Workflow with arm64 platform

Open 1fini opened this issue 2 years ago • 4 comments

Behaviour

[linux/arm64 publish 1/1] RUN dotnet publish "Automate.csproj" -c Release -o /app/publish:

/usr/share/dotnet/sdk/7.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.DefaultItems.Shared.targets(201,5): error MSB4063: The "CheckForDuplicateItems" task could not be initialized with its input parameters. [/src/Automate/Automate.csproj]

Steps to reproduce this issue

  1. Dockerfile with net7 app
  2. Qemu to build image for platform arm64 on GitHub Actions
name: Docker Image CI

on:
  push:
    branches: [ main ]
    tags:
      - 'v*'

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Login to DockerHub
      uses: docker/login-action@v1
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKERHUB_PASSWORD }}
        
    - name: Set up QEMU
      uses: docker/setup-qemu-action@v2
      with:
        platforms: all
        
    - name: Set up Docker Buildx
      id: docker_buildx
      uses: docker/setup-buildx-action@v1
        
    - name: Build and push amd64 & arm64
      uses: docker/build-push-action@v2
      with:
        builder: ${{ steps.docker_buildx.outputs.name}}
        context: .
        file: ./Automate/Dockerfile
        push: true
        platforms: linux/amd64, linux/arm64
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}

Dockerfile

FROM mcr.microsoft.com/dotnet/runtime:7.0-jammy AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS build
WORKDIR /src
COPY ["Automate/Automate.csproj", "Automate/"]
COPY ["Automate.Domain/Automate.Domain.csproj", "Automate.Domain/"]
COPY ["Automate.Infrastructure/Automate.Infrastructure.csproj", "Automate.Infrastructure/"]
RUN dotnet restore "Automate/Automate.csproj"
COPY . .
WORKDIR "/src/Automate"
RUN dotnet build "Automate.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Automate.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Automate.dll"]

Logs

first paragraph

Regards

1fini avatar Feb 17 '23 13:02 1fini

Can you post a basic Dockerfile for repro please?

crazy-max avatar Feb 17 '23 13:02 crazy-max

Can you post a basic Dockerfile for repro please?

Thank you @crazy-max for your comment and help. I updated my initial post with my dockerfile which is almost the same as the template provided by VS2022 at project creation time.

1fini avatar Feb 17 '23 13:02 1fini

@1fini We've been seeing this issue, we fixed it by putting DOTNET_EnableWriteXorExecute=0 in front of every dotnet call.

RUN DOTNET_EnableWriteXorExecute=0 dotnet build "myproject.csproj" -c Release -o /app/build

It still doesn't resolve issues with multi-platform and especially arm64 builds running horrifically slow on the default github actions runners.

KempMVitesse avatar Apr 05 '23 15:04 KempMVitesse

did anyone figure this out? I added the DOTNET_EnableWriteXorExecute=0 and it took 30m to build vs the normal 3m or so - BUT with no errors! Any updates would be greatly appreciated! 30m on a GitHub runner adds up over time 😄

darena-patrick avatar Aug 22 '23 01:08 darena-patrick