Nodejs libxmljs crashes docker container when xml fails schema validation

717 views Asked by At

I'm making a web service in NodeJs that needs to support a specific xml request. So I'm using libxmljs to parse xml and validate it against an xsd.

On my Windows machine everything works well, so when doing this:

isValid = xml.validate(xsd)

isValid will be set as a boolean and xml will have items in the property validationErrors. Everything is fine until I run it in a docker container running node:10.15.2-alpine.

As long as the validation passes, everything is fine, but when there are validation errors, the entire docker container crashes.

I could not find an answer to this when googling so I will provide the answer myself :-)

2

There are 2 answers

3
TBear On BEST ANSWER

Change in your Dockerfile to use FROM node:10.15.2-slim and not FROM node:10.15.2-alpine.

Yes it uses more space, but the alpine edition is appearently not compatible with some of the prebuild python libraries the libxmljs uses.

0
TalR On

I faced the same problem, I was able to resolve it for some of the alpine distributions by installing python, g++ and make.

apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python && apk add --update --no-cache g++ && apk add --update --no-cache make