Ahmed Ablak
Ahmed Ablak

Reputation: 738

How to resolve missing dependencies in Docker Alpine

I have Django application that works just fine when I build my docker image using python:3.10.0rc2-buster or python:3.10.0rc2-slim-buster without any problem.

In order to decrease the image size, I switched to python:3.10-rc-alpine, however, I am facing dozens of missing dependencies.

I found this post very helpful Docker Alpine Linux python (missing) It allowed me to resolve some of the missing dependencies.

Appreciate your support to guide me on what can I do to resolve this ?

These are the missing dependencies errors I am receiving:

#6 9.141 ERROR: unable to select packages:
#6 9.173   libcairo2 (no such package):
#6 9.173     required by: world[libcairo2]
#6 9.173   libgdk-pixbuf2.0-0 (no such package):
#6 9.173     required by: world[libgdk-pixbuf2.0-0]
#6 9.173   libldap2-dev (no such package):
#6 9.173     required by: world[libldap2-dev]
#6 9.173   libpango-1.0-0 (no such package):
#6 9.173     required by: world[libpango-1.0-0]
#6 9.173   libpangocairo-1.0-0 (no such package):
#6 9.173     required by: world[libpangocairo-1.0-0]
#6 9.173   libsasl2-dev (no such package):
#6 9.173     required by: world[libsasl2-dev]
#6 9.173   libsnmp-dev (no such package):
#6 9.173     required by: world[libsnmp-dev]
#6 9.173   libssl-dev (no such package):
#6 9.173     required by: world[libssl-dev]
#6 9.173   pdftk (no such package):
#6 9.173     required by: world[pdftk]
#6 9.173   python-dev (no such package):
#6 9.173     required by: world[python-dev]
#6 9.173   python3-cffi (no such package):
#6 9.173     required by: world[python3-cffi]
#6 9.173   python3-setuptools (no such package):
#6 9.173     required by: world[python3-setuptools]
#6 9.173   python3-wheel (no such package):
#6 9.173     required by: world[python3-wheel]
#6 9.173   sqlite3 (no such package):
#6 9.173     required by: world[sqlite3]

This is part of my docker file:

FROM python:3.10-rc-alpine
RUN apk --no-cache update && \
    apk --no-cache add --update alpine-sdk && \ 
    apk --no-cache add \
    python3 \
    lsof \
    pdftk \
    unixodbc-dev \
    vim \
    git \
    python3-dev \
    python3-setuptools \
    python3-wheel \
    python3-cffi libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi- 
    dev shared-mime-info \
    libsasl2-dev python-dev libldap2-dev libssl-dev libsnmp-dev \
    nginx \
    supervisor \
    sqlite3 && \
    pip3 install -U pip setuptools && \

Upvotes: 1

Views: 17130

Answers (1)

valiano
valiano

Reputation: 18551

At least one of the listed dependencies could not be resolved using an official package:

#6 9.173   pdftk (no such package):
#6 9.173     required by: world[pdftk]

The python:3.10-rc-alpine is based on Alpine 3.14.2, but the pdftk package has been deprecated since Alpine 3.9. However, you could try installing pdftk by following this answer:
https://stackoverflow.com/a/67747061/7256341
This could work, if pdftk is an application dependency and not a package dependency.

The following packages are provided by Alpine on different names:

These are the ones I was able to quickly pick up, using Alpine's package search:
https://pkgs.alpinelinux.org/packages

It's great and easy to use engine: you can search by package name using wildcards (e.g. *ldap*-dev) and using content search to locate file names in packages. With a bit of work, hopefully you should be able to find corresponding packages for the remaining dependencies. Good luck!

P.S.: Perhaps stating the obvious, but make sure to measure the size of the resulting Alpine image. The vanilla image is very compact, but once you add so many packages, the size reduction might become negligible compared to Debian slim - it might even exceed it!

Upvotes: 5

Related Questions