excubo-ag / WebCompiler

Apache License 2.0
149 stars 30 forks source link

Segmentation fault when running in alpine docker container using sdk:5.0-alpine MS image #24

Closed gunr2171 closed 3 years ago

gunr2171 commented 3 years ago

This is the same issue as #18, except it's for the 5.0 docker image. This was tested with version 2.6.4 of WebCompiler.

Here are some Linux Dockerfiles to reproduce the problem and show it working with non-alpine.


Running with the 5.0-alpine tag. Both install methods (first globally, then locally) have an exit code 139 with no error message when running ...webcompiler -r ..

FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine
WORKDIR /src
RUN dotnet tool install Excubo.WebCompiler --global
RUN /root/.dotnet/tools/webcompiler -h
RUN echo "body { background-color: orange; }" > /src/source.scss
RUN /root/.dotnet/tools/webcompiler -r .
RUN ls -la /src
FROM mcr.microsoft.com/dotnet/sdk:5.0-alpine
WORKDIR /src
RUN dotnet new tool-manifest
RUN dotnet tool install Excubo.WebCompiler
RUN dotnet tool restore
RUN dotnet tool webcompiler -h
RUN echo "body { background-color: orange; }" > source.scss
RUN dotnet webcompiler -r .
RUN ls -la .

Same steps, but this time running with the 5.0 tag (ubuntu). Both install methods (first globally, then locally) succeed.

FROM mcr.microsoft.com/dotnet/sdk:5.0
WORKDIR /src
RUN dotnet tool install Excubo.WebCompiler --global
RUN /root/.dotnet/tools/webcompiler -h
RUN echo "body { background-color: orange; }" > /src/source.scss
RUN /root/.dotnet/tools/webcompiler -r .
RUN ls -la /src
FROM mcr.microsoft.com/dotnet/sdk:5.0
WORKDIR /src
RUN dotnet new tool-manifest
RUN dotnet tool install Excubo.WebCompiler
RUN dotnet tool restore
RUN dotnet tool webcompiler -h
RUN echo "body { background-color: orange; }" > source.scss
RUN dotnet webcompiler -r .
RUN ls -la .
stefanloerwald commented 3 years ago

Thank you for raising this issue and providing such clear instructions on how to reproduce. I will investigate.

stefanloerwald commented 3 years ago

npm shouldn't be a requirement. I used Excubo.WebCompiler for ages on my device, which didn't have npm installed until very recently. But it is likely that the absence of some libraries is indeed the culprit.

stefanloerwald commented 3 years ago

I'm suspecting that this issue is related to https://github.com/Taritsyn/JavaScriptEngineSwitcher/issues/88

elken commented 3 years ago

Possible, would need a gdb bt to be sure

stefanloerwald commented 3 years ago

From a bit of research on the topic, it seems that alpine is riddled with issues like this, where libraries aren't found / linked properly. I tried hacking in the right commands, but failed since the ldconfig command on alpine behaves differently to other linux distributions.

I would therefore recommend to stay away from alpine. Even if it were possible to find a fix and paste it into a Dockerfile, it simply isn't worth the effort if there are alternatives working out of the box, such as using a ubuntu-based image.

If alpine is required for other build steps, I advise to use multiple build steps in docker and copying the output files from the webcompiler command to the alpine-based build step.

elken commented 3 years ago

Alpine is a very minimal Linux distribution and should only be used if you're trying to create a very small docker image

stefanloerwald commented 3 years ago

I added a small paragraph about docker/alpine in the Readme: https://github.com/excubo-ag/WebCompiler#docker Given how easy it is to create a multi-stage build, I can only recommend using alpine exclusively for non-build tasks.