3
votes

I am developing Asp.Net Core application (with React front-end) for my Raspberry Pi 3 Model B+. Application based on template (dotnet new react -o react-app).

I want to develop and debug application locally in my Windows OS laptop, then build application for ARM32 architecture, push image to docker hub and pull and run image on Raspberry device.

I found that, if I build application using microsoft/dotnet:2.2-sdk and microsoft/dotnet:2.2-aspnetcore-runtime on my Windows laptop, then I can't run this image on Raspberry device with error message: 'standard_init_linux.go:190: exec user process caused "exec format error"'. Looks like Windows builded image siutable only for AMD64 architecture.

Then I tried to change builder and runtime images to ARM32, but now build process crashes with error:

qemu: Unsupported syscall: 389 
qemu: Unsupported syscall: 345 qemu:
uncaught target signal 11 (Segmentation fault) - core dumped
Segmentation fault The command '/bin/sh -c dotnet restore' returned a
non-zero code: 139

My Docker file:

#FROM microsoft/dotnet:2.2-sdk AS builder
FROM microsoft/dotnet:2.2-sdk-stretch-arm32v7 AS builder
WORKDIR /source

RUN curl -sL https://deb.nodesource.com/setup_10.x |  bash -
RUN apt-get install -y nodejs

COPY *.csproj .
RUN dotnet restore

COPY ./ ./

RUN dotnet publish "./react-app.csproj" --output "./dist" --configuration Release --no-restore

#FROM microsoft/dotnet:2.2-aspnetcore-runtime
FROM microsoft/dotnet:2.2-aspnetcore-runtime-stretch-slim-arm32v7 as runtime
WORKDIR /app
COPY --from=builder /source/dist .
EXPOSE 80
ENTRYPOINT ["dotnet", "react-app.dll"]

Is it possible to build image for Raspberry device from Windows OS?

If yes, Could You help me please with Docker settings?

1

1 Answers

2
votes

I'm pretty new to the Docker stuff, but I got an example for Azure Edge Modules running on my RPi, which should be the same concept. For the build environment I use microsoft/dotnet:2.1-sdk - this is because my host is Win10 x86_64 and the generated IL code is platform agnostic anyway. But since the destination platform is arm32v7, the dotnet runtime has to be arm32v7. So for the runtime I use microsoft/dotnet:2.1-runtime-stretch-slim-arm32v7 (or microsoft/dotnet:2.2-aspnetcore-runtime-stretch-slim-arm32v7 in your case).

Try this Dockerfile:

FROM microsoft/dotnet:2.2-sdk AS builder
WORKDIR /source

RUN curl -sL https://deb.nodesource.com/setup_10.x |  bash -
RUN apt-get install -y nodejs

COPY *.csproj .
RUN dotnet restore

COPY ./ ./

RUN dotnet publish "./react-app.csproj" --output "./dist" --configuration Release --no-restore

FROM microsoft/dotnet:2.2-aspnetcore-runtime-stretch-slim-arm32v7 as runtime
WORKDIR /app
COPY --from=builder /source/dist .
EXPOSE 80
ENTRYPOINT ["dotnet", "react-app.dll"]