[Django]-Docker & Python, Speed up when your requirements.pip list is huge?

1👍

I found a better alternative

export DOCKER_BUILDKIT=1
export COMPOSE_DOCKER_CLI_BUILD=1

put following line as the first line of Dockerfile .
# syntax=docker/dockerfile:experimental

I lost where I found this..

end result is that, your requirements package is cached (once downloaded, cached version will be used on next build)

👤eugene

2👍

You can divide by yourself in different files the requirements that are less likely to change and those that are most likely to change.

Then you have two different RUN stages like

RUN pip install -r less_likely_to_change.txt
RUN pip install -r most_likely_to_change.txt

This will create a layer where you have most of your requirements, and therefore, you are speeding up the process because you won’t be changing less_likely_to_change.txt so often.

Leave a comment