1

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 && \
Ahmed Ablak
  • 718
  • 3
  • 14
  • The docker image you are using already has python installed. Trying to re-install it makes no sense. Also, you mention missing dependencies. What are trying to install? – akortex Sep 21 '21 at 10:57
  • @akortex Thank you for your comment. You are right about re-installing python. I have already attached list of dependencies/packages trying to install that are causing the error messages. – Ahmed Ablak Sep 21 '21 at 11:08
  • So aside from python what else is there that you need installed? – akortex Sep 21 '21 at 11:08
  • The following are list of items I am trying to install `python3-cffi` `libcairo2` `libpango-1.0-0` `libpangocairo-1.0-0` `libgdk-pixbuf2.0-0` `libffi-dev` `libsasl2-dev` `python-dev` `libldap2-dev` `libssl-dev` `libsnmp-dev` `pdftk` `python3-setuptools` `python3-wheel` `sqlite3` – Ahmed Ablak Sep 21 '21 at 11:13
  • Why do you need the various lib pacakges? Setup tools and so on can be installed by `pip`. – akortex Sep 21 '21 at 11:26
  • @akortex The lib packages to support the application functionalities such as LDAP authentication, PDF editing, SSL, DB connections (Oracle DB will be used through python cx_Oracle), ...etc. – Ahmed Ablak Sep 21 '21 at 11:35
  • Use `ubuntu` instead of `alpine`. potentially smaller image size than buster (haven't tested tho) – rv.kvetch Sep 23 '21 at 15:50
  • 1
    @rv.kvetch Thank you for your comment, but it does not answer my question. – Ahmed Ablak Sep 24 '21 at 09:08

1 Answers1

5

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!

valiano
  • 16,433
  • 7
  • 64
  • 79