Hi @Honza Javorek, I use a new Python package and project manager, written in Rust named uv:
https://docs.astral.sh/uv/. Is extremely fast and work very well for me. Here you have how I configure all my docker images in my actors:
# First, specify the base Docker image.
# You can see the Docker images from Apify at https://hub.docker.com/r/apify/.
# You can also use any other image from Docker Hub.
FROM apify/actor-python:3.11
# Second, copy just requirements.txt into the Actor image,
# since it should be the only file that affects the dependency install in the next step,
# in order to speed up the build
COPY requirements.txt ./
# Install the packages specified in requirements.txt,
# Print the installed Python version, pip version
# and all installed packages with their versions for debugging
RUN echo "Python version:" \
&& python --version \
&& echo "Pip version:" \
&& pip --version \
# uv is an extremely fast Python package and project manager, written in Rust.
# https://docs.astral.sh/uv/
&& echo "Installing uv:" \
&& pip install uv \
&& echo "Installing dependencies using uv:" \
&& uv pip install --system -r requirements.txt \
&& echo "All installed Python packages:" \
&& uv pip freeze
# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick build will be really fast
# for most source file changes.
COPY . ./
# Use compileall to ensure the runnability of the Actor Python code.
RUN python3 -m compileall -q .
# Specify how to launch the source code of your Actor.
# By default, the "python3 -m ." command is run
CMD ["python3", "-m", "src"]
Before it took 60 to 80 seconds to build, now it takes 11 to 15 seconds... about x5 faster...
Try it...