I need to add a python package to an existing docker alpine image.
There is a couple of caveats with the solution, which I share below:
alpinedoes not have a python package. Instead, it ships a
pythoninstallation does not include
pip. It is another standalone package called
python3package doesn't add
pythonto the path (it adds
pipto the path.
A simplified Dockerfile, looks like:
RUN apk update && apk add --update --no-cache \
python3 \ #Install the latest version of python 3
py3-pip && \ # Installs pip since it isn't packaged with python
ln -sf python3 /usr/bin/python # Makes 'python' available in path
COPY ./requirements.txt ./
RUN pip install -r requirements.txt