DEV Community

Cover image for .NET on OPA Wasm - moving on the edge
Thang Chung
Thang Chung

Posted on

.NET on OPA Wasm - moving on the edge

Currently, our team is working on the requirement that we use OPA to do authorization checks (policy). The reason is we want to make policy management in OPA so that we can consistently do the same with other languages (.NET, Nodejs, Go, and Python are possible then).

That's new to us, and our team can handle it to make it work eventually. We use dotnet-opa-wasm.

Everything is working in the local development environment ❤️

But when we deploy it into Kubernetes, then the problem happens (we use the alpine image). The error is below 😂😂😂

Image description

/app/wasmtime.so: No such file or directory
Enter fullscreen mode Exit fullscreen mode

We know that WebAssembly is quite new and should be something that needs to be added to the builds. I find the solution at https://github.com/bytecodealliance/wasmtime-dotnet/issues/82

But after struggling a bit to make the build runs. I found out the best way. Justifying the Dockerfile with the following content:

FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.18 AS base
RUN addgroup -g 1000 -S <username> && \
    adduser -u 1000 -S <username> -G <username>
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories
RUN apk update --no-cache && apk upgrade --no-cache
RUN apk add libwasmtime --repository=dl-cdn.alpinelinux.org/alpine/edge/testing
# cut of for brevity
# ...
Enter fullscreen mode Exit fullscreen mode

And it worked as we expected. I also commented on #82 on GitHub so that other guys can solve it if they get it.

Happy hacking!

Top comments (0)