Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run in docker throw an exception #298

Closed
wawa0210 opened this issue Aug 28, 2018 · 12 comments
Closed

Run in docker throw an exception #298

wawa0210 opened this issue Aug 28, 2018 · 12 comments
Labels

Comments

@wawa0210
Copy link

wawa0210 commented Aug 28, 2018

Environment

  • net core 2.1
  • docker 18.06.1
  • centos 7.3

Description

Running in Centos not docker is perfect,But in docker support that

ImageMagick.MagickDrawErrorException: NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/DrawImage/4307
   at ImageMagick.MagickExceptionHelper.Check(IntPtr exception)
   at ImageMagick.DrawingWand.NativeDrawingWand.Render()
   at ImageMagick.MagickImage.Draw(IEnumerable`1 drawables)
   at ImageMagick.Drawables.Draw(IMagickImage image)
   at ImageService.MomentImageService.GenerateMomentShareImages(RequestProduct request, ServerCallContext context) in /src/ImageService/MomentImageService.cs:line 36
NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/DrawImage/4307

@dlemstra

@dlemstra
Copy link
Owner

What is the contents of your Dockerfile? Do you also use centos as the base image? You probably need to install freetype in your container.

@wawa0210
Copy link
Author

image

This is my Dockerfile

@wawa0210
Copy link
Author

I don't know how to change my Dockerfile so it can work well @dlemstra

@dlemstra
Copy link
Owner

dlemstra commented Aug 31, 2018

The Dockerfile is using microsoft/dotnet:2.1-runtime-deps-stretch-slim that has debian:stretch-slim as the base image. This image probably does not contain freetype. You will need to install freetype. I will leave that as an exercise for the reader.

@wawa0210
Copy link
Author

image

This is my new Dockerfile,but it's report the same exception as before
image

@dlemstra
Copy link
Owner

Next time you could use code blocks in your post instead of screenshots: https://help.github.com/articles/creating-and-highlighting-code-blocks/ to improve the readability.

I am not a docker expert but should you not move the RUN apt-get line after the FROM ... AS base?

@wawa0210
Copy link
Author

FROM debian:stretch-slim
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NOWARNINGS yes
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils && apt-get install libfreetype6 -y
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ImageService /src/ImageService
COPY ImageService/nuget.config /root/.nuget/NuGet/
COPY ImageService.Base /src/ImageService.Base/
WORKDIR /src/ImageService
RUN dotnet restore
RUN dotnet build -c Release -o /app
FROM build AS publish
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ImageService.dll"]

This is my new Dockerfile,but it's not work well not yeat.and report the same exception as before

Fontconfig error: Cannot load default config file
ImageMagick.MagickDrawErrorException: NonconformingDrawingPrimitiveDefinition text' @ error/draw.c/DrawImage/4307 at ImageMagick.MagickExceptionHelper.Check(IntPtr exception) at ImageMagick.DrawingWand.NativeDrawingWand.Render() at ImageMagick.MagickImage.Draw(IEnumerable1 drawables)
at ImageMagick.Drawables.Draw(IMagickImage image)
at ImageService.MomentImageService.GenerateMomentShareImages(RequestProduct request, ServerCallContext context) in /src/ImageService/MomentImageService.cs:line 36
NonconformingDrawingPrimitiveDefinition text' @ error/draw.c/DrawImage/4307`

@dlemstra
Copy link
Owner

You can do multi line code blocks with [```].

This looks incorrect to me:

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends apt-utils && apt-get install libfreetype6 -y

Should this not be:

RUN apt-get install -y --no-install-recommends apt-utils && apt-get install libfreetype6 -y

And why do you have the FROM debian:stretch-slim?

I also wonder if you need to install FontConfig. This is now giving you an error:
Fontconfig error: Cannot load default config file

@wawa0210
Copy link
Author

Sorry, I don't use markdown for long. I change my Dockerfile again, like this:

FROM debian:stretch-slim
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
ENV DEBIAN_FRONTEND noninteractive
ENV DEBCONF_NOWARNINGS yes
RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils && apt-get install libfreetype6 -y && apt-get install fontconfig -y                      
WORKDIR /app
EXPOSE 80
FROM microsoft/dotnet:2.1-sdk AS build
WORKDIR /src
COPY ImageService /src/ImageService
COPY ImageService/nuget.config /root/.nuget/NuGet/
COPY ImageService.Base /src/ImageService.Base/
WORKDIR /src/ImageService
RUN dotnet restore
RUN dotnet build -c Release -o /app
FROM build AS publish
RUN dotnet publish -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "ImageService.dll"]

Building well ,But when I call the imageservice and it report the same exception .

Fontconfig error: Cannot load default config file
ImageMagick.MagickDrawErrorException: NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/DrawImage/4307
   at ImageMagick.MagickExceptionHelper.Check(IntPtr exception)
   at ImageMagick.DrawingWand.NativeDrawingWand.Render()
   at ImageMagick.MagickImage.Draw(IEnumerable`1 drawables)
   at ImageMagick.Drawables.Draw(IMagickImage image)
   at ImageService.MomentImageService.GenerateMomentShareImages(RequestProduct request, ServerCallContext context) in /src/ImageService/MomentImageService.cs:line 36
NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/DrawImage/4307

Have you ever tried using Magick.Net on docker? Can you give me a proper Dockerfile reference

@wawa0210
Copy link
Author

@dlemstra Hello,Can you help me to slove this problem ?

@dlemstra
Copy link
Owner

@wawa0210 It looks like an issue with font config: Fontconfig error: Cannot load default config file. I don't know how to fix this. Did you manage to resolve this yourself?

@dmelendez35
Copy link

@wawa0210, I have the same issue, Did you manage to resolve this yourself?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants