Enable docker buildkit
export DOCKER_BUILDKIT=1
Add # syntax = docker/dockerfile:1.3
at the top of the dockerfile
Add --mount=type=cache,target=/root/.cache
before each pip install Eg:
RUN --mount=type=cache,target=/root/.cache pip install --upgrade pip && pip install -e library