Tuesday, 17 December 2024

Dockerfile run apk add --virtual, build base, pip install

 https://stackoverflow.com/questions/46221063/what-is-build-deps-for-apk-add-virtual-command



apk installs global stuff into the container like python, dependecy packages,


pip install python sepcific libraries specified in requirement file



https://stackoverflow.com/questions/46221063/what-is-build-deps-for-apk-add-virtual-command
What is .build-deps for apk add --virtual command?

RUN apk add --no-cache --virtual .build-deps \
gcc \
freetype-dev \
musl-dev

RUN pip install --no-cache-dir <packages_that_require_gcc...> \

RUN apk del .build-deps

-t, --virtual NAME    Instead of adding all the packages to 'world', create a new 
                      virtual package with the listed dependencies and add that 
                      to 'world'; the actions of the command are easily reverted 
                      by deleting the virtual package

https://forums.docker.com/t/what-does-run-apk-add-do/128234
apk is Alpine Linux package system, so what it does is that it installs python, g++ and make

https://hub.docker.com/r/alpinelinux/build-base

Build base

This is a docker image that can be used to build Alpine Linux packages with abuild



DockerFile

From python:3.10-alpine3.14


RUN apk update

# gcc pytho3-dev musl-dev is for mysql client depedencies

RUN apk add --virtual build-deps gcc python3-dev musl-dev

RUN apk add --no-cache mariadb-dev


# For xmlsec required for  python3-saml

# https://pypi.org/project/xmlsec/

RUN apk add build-base libressl libffi-dev libressl-dev libxslt-dev libxml2-dev xmlsec-dev xmlsec


ENV PYTHONBUFFERED 1


COPY ./requirements.txt /requirements.txt


RUN pip install -r /requirements.txt


#

RUN apk add expat-dev

RUN pip install mod_wsgi-standalone


RUN apk del build-deps


RUN mkdir /app

WORKDIR /app

COPY ./app /app



requirements.txt

Django>=4.0.4,<4.1.0

djangorestframework>=3.13.1,<3.20.0


mysqlclient>=2.1.0,<2.2.0


flake8>=4.0.1,<4.1.0


lxml==4.9.3

xmlsec==1.3.13

python3-saml==1.11.0


requests>=2.28.1,<2.29.0


django-cors-headers >=3.13.0,<3.14.0


django-smtp-ssl>=1.0,<2.0





No comments:

Post a Comment