unosquare / raspberryio

The Raspberry Pi's IO Functionality in an easy-to-use API for Mono/.NET/C#
https://unosquare.github.io/raspberryio
Other
672 stars 104 forks source link

Support for running in a container? #203

Closed thnk2wn closed 4 years ago

thnk2wn commented 4 years ago

Is your feature request related to a problem? Please describe. Currently it appears difficult to use raspberryio in a container (or at least not obvious how to).

I see this error

wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: No such file or directory.
  Aborting your program because if it can not access the GPIO
  hardware then it most certianly won't work
  Try running with sudo?

Currently using .Net Core 3.1 and:

 <PackageReference Include="Unosquare.Raspberry.IO" Version="0.27.0" />
 <PackageReference Include="Unosquare.WiringPi" Version="0.5.0" />

Dockerfille:

# Stage 1
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
WORKDIR /build
COPY . .
RUN dotnet restore
RUN dotnet publish -c Release -o /app -r linux-arm
# Stage 2
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1.1-buster-slim-arm32v7 AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "./siren.dll"]

Project: https://github.com/thnk2wn/rasp-cat-siren/tree/master/siren

Describe the solution you'd like

Describe alternatives you've considered I've looked at these threads so far and am still experimenting:

Additional context Add any other context or screenshots about the feature request here.

logicethos commented 4 years ago

Does this help? https://stackoverflow.com/questions/30059784/docker-access-to-raspberry-pi-gpio-pins

thnk2wn commented 4 years ago

Yeah, thanks.