alpine に lxml をインストールした docker を構築する

alpine に lxml をインストールしようとするとこんなエラーが出る。

...
** make sure the development packages of libxml2 and libxslt are installed **
...
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed
*********************************************************************************
error: command 'gcc' failed with exit status 1
...
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-96bb0z1d/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-i0hoswq1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-96bb0z1d/lxml/

結論としては Dockerfile を次のようにしてインストールできた。

FROM python:3-alpine
RUN apk --no-cache add gcc libc-dev libxml2-dev libxslt-dev
RUN pip3 install lxml

libxml2-dev と libxslt-dev は本家に必要と書いてあった
https://lxml.de/installation.html
また g++ と gcc をインストールしてたが、こちらの stackoverflow によるとlibc-dev と gcc でよさそう
https://stackoverflow.com/questions/35931579/how-can-i-install-lxml-in-docker