pamidur / aspect-injector

AOP framework for .NET (c#, vb, etc)
Apache License 2.0
742 stars 111 forks source link

Cannot build project with AspectInjector on M1 mac inside docker. #190

Open pvoshell opened 2 years ago

pvoshell commented 2 years ago

Environment (please complete the following information):

Describe the bug When building our project with AspectInjector it fails when building a docker image:

docker build .

12 4.013 qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

12 4.013 AspectInjector : error AI_FAIL: Aspect Injector processing has failed. See other errors. [/src/Core/Core.csproj]

It does work when I build it as an AMD64 image:

docker build . --platform=amd64

I don't know how AspectInjector works internally, but it looks like it is trying to run an x64 binary on an arm linux container.

It does not matter when using non alpine images, as I tried that as well.

To Reproduce A steps to reproduce the bug. Or a description when it happens (in compile-time, in runtime).

It occurs during build time of the docker image on an m1 mac when dotnet publish -c Release -o out is executing.

Additional context

FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
WORKDIR /src

# Copy everything
COPY src ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
WORKDIR /src
COPY --from=build /src/out .

# expose the application on port 8080
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "Api.dll"]
pamidur commented 2 years ago

Hi @pvoshell ,yes indeed, AspectInjector internally uses a set of binaries that are built for specific target platform. And there is no ARM variant yet. I'll consider this report as feature request

pvoshell commented 2 years ago

Thanks @pamidur for your response. I think I can fix this myself. I will send you a pull request when I'm done.