Docker alpine image fails to build because of HDF5 and tables

Viewed 618

I am building a Docker image based on alpine linux. During build I get the error when installing tables that I have no local hdf5 installation.

To solve this I tried to install hdf5 as recommended in various posts:

Yet, even if I install hdf5 package in my Docker container the same error occurs (I also tried hdf5-dev package but this includes SciPy and I don't want SciPy since it takes ages to build).

Note that I don't even know why tables is installed, or let's say which dependency installs tables. So as a solution I'd be happy to remove the dependency that installs tables, if I don't need it. Yet most of my requirements in my requirements.txt I do need. Most of all I need pandas, matplotlib and numpy.

My dockerfile looks like this:

FROM python:3.9-alpine3.14

RUN apk add --no-cache --update-cache hdf5

RUN apk update \
  # psycopg2 dependencies
  && apk add --virtual build-deps gcc python3-dev musl-dev \
  && apk add postgresql-dev \
  # Pillow dependencies
  && apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-dev \
  # CFFI dependencies
  && apk add libffi-dev py-cffi \
  # Translations dependencies
  && apk add gettext \
  # https://docs.djangoproject.com/en/dev/ref/django-admin/#dbshell
  && apk add postgresql-client \
  ## Needed for sphinx https://github.com/pydanny/cookiecutter-django/issues/1747
  && apk add make \
  ## Needed for postgis
  && apk add --no-cache --virtual .build-deps \
    autoconf \
    automake \
    g++ \
    gdal-dev \
    geos-dev \
    json-c-dev \
    libtool \
    libxml2-dev \
    proj-dev \
    protobuf-c-dev \
    graphviz \
    ttf-freefont

RUN apk update && apk add --no-cache build-base

COPY ./requirements /requirements
RUN python -m pip install -r /requirements/local.txt

Also note that my dockerfile was working perfectly fine until maybe 4 weeks ago. Then it started throwing this error. I would be happy to completely change the Docker image as long as I can install pandas, matplotlib and numpy in it.

What I also tried:

  • Pulling image python:3.8
  • Changing alpine version
  • Not using --virtual and removing .build-deps

The full error:

Downloading tables-3.6.1.tar.gz (4.6 MB) ERROR: Command errored out with exit status 1: command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-g7jsy3s2/tables_ade9c044a3584a07b883ac519dd110db/setup.py'"'"'; file='"'"'/tmp/pip-install-g7jsy3s2/tables_ade9c044a3584a07b883ac519dd110db/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-geym875g cwd: /tmp/pip-install-g7jsy3s2/tables_ade9c044a3584a07b883ac519dd110db/ Complete output (12 lines): * Using Python 3.9.7 (default, Aug 31 2021, 19:01:35) * USE_PKGCONFIG: True /tmp/H5closelwxa646a.c: In function 'main': /tmp/H5closelwxa646a.c:2:5: warning: implicit declaration of function 'H5close' [-Wimplicit-function-declaration] 2 | H5close(); | ^~~~~~~ /usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lhdf5 collect2: error: ld returned 1 exit status .. ERROR:: Could not find a local HDF5 installation. You may need to explicitly state where your local HDF5 headers and library can be found by setting the HDF5_DIR environment variable or by using the --hdf5 command-line option. ---------------------------------------- WARNING: Discarding https://files.pythonhosted.org/packages/2b/32/847ee3f521aae6a0be380d923a736162d698586f444df1ac24b98c65025c/tables-3.6.1.tar.gz#sha256=49a972b8a7c27a8a173aeb05f67acb45fe608b64cd8e9fa667c0962a60b71b49 (from https://pypi.org/simple/tables/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

0 Answers
Related