Forum How do I...?

Docker Image for prince

sailorxyz
Is there an official Docker image for Princexml or a recommended one. Failing that, what do I need to know to make my own and how would I connect to it from a rails container and also from outside. I'm a complete newbie to Docker and am busy finding my feet.

Any assistance will be very, very much appreciated!
mikeday
You can create a Docker image for Prince by starting with your Linux distribution of choice and the installing Prince on it. Here is an example for CentOS:
FROM centos:7

# Or copy the RPM from the current directory instead of downloading it:
# WORKDIR /app
# ADD . /app
# RUN yum -y install /app/prince-12.4-1.centos7.x86_64.rpm

RUN yum -y update \
 && yum -y install https://www.princexml.com/download/prince-12.4-1.centos7.x86_64.rpm \
 && yum -y install liberation-sans-fonts liberation-serif-fonts liberation-mono-fonts liberation-narrow-fonts \
 && yum clean all

ENTRYPOINT ["prince"]

You could then run Prince as an application within the image, I assume? :)
michaelperrin
I created a Docker image that is similar to the one @mikeday proposed, but based on Alpine.

It is available here: https://hub.docker.com/r/michaelperrin/prince (code is here: https://github.com/michaelperrin/docker-prince).

It's quite convenient to use Prince in a Docker image 🙂
nsnsolutions
Mike, We are using a nodejs wrapper around princeXML any running it from the official node-carbon docker image based on alpine. We ran into a runtime error after our latest build. Apparently the official node-carbon docker image updated to alpine 3.9. We are running a pre-release version at the moment (prince-20171214-alpine3.6-x86_64.tar.gz)

I have been able to fix the majority of the dependencies save one. alpine3.7 ran on openssl but 3.8 switched to ressl. As such, i noticed that prince is looking specifically for libcrypto.so.41 rather then the generic libcrypto.so

2 questions for you:
1. Is it possible to get a alpine 3.9 build for prince 12.5
2. do you have a recommendation to avoid this sort of resource dependency moving forward?

I am prepared to build our own carbon image on 3.8 but i wanted to know if you have any suggestions before i started down this path.

thank you
mikeday
We have an Alpine 3.9 package for Prince 12.5 available now, please give it a try and let me know if you experience any issues with it.
nsnsolutions
I will, thank you. We did end up creating an alpine container with the version of node we needed. It seemed the appropriate thing to do as to not get surprised by an upstream change in the future if anyone else is in the same boat, here is my docker file - i updated it to 3.9 as suggested.

FROM alpine:3.9

RUN apk update && \
    apk upgrade && \
    apk --no-cache add nodejs=10.14.2-r0 && \
    apk --no-cache add npm=10.14.2-r0 && \
    apk --no-cache add libxml2 pixman tiff giflib libpng lcms2 libjpeg libcurl fontconfig freetype libgomp && \
    apk --no-cache add libressl-dev && \
    apk --no-cache add ttf-dejavu

ADD https://www.princexml.com/download/prince-12.5-alpine3.9-x86_64.tar.gz /opt/
RUN tar xzf /opt/prince-*-alpine3.*-x86_64.tar.gz -C /opt/ && \
    /opt/prince-*-alpine3.*-x86_64/install.sh

ADD license.dat /usr/local/lib/prince/license/license.dat

CMD [ "node" ]


Note: your license file is added on the second to last line. you might need to change that to point to the appropriate location.

Edited by nsnsolutions

wangp
Note that Alpine 3.9 switched from LibreSSL to OpenSSL so you don't need the libressl package (for Prince).