I am deploying a python project on google cloud run using the following Dockerfile. When no container is started, the cold container startup take around 35 seconds.
FROM python:3.9-slim as build
ENV DEBIAN_FRONTEND noninteractive
RUN apt update -y && \
apt upgrade -y && \
apt install -y curl software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
rm -rf /var/lib/apt/lists/* && \
curl https://bootstrap.pypa.io/get-pip.py | python3.9
WORKDIR /rembg
COPY requirements.txt .
RUN python3.9 -m pip install -r requirements.txt
COPY . .
RUN python3.9 -m pip install .
RUN mkdir -p /home/.u2net/
RUN mv u2netp.onnx /home/.u2net/u2netp.onnx
RUN mv u2net.onnx /home/.u2net/u2net.onnx
RUN mv u2net_human_seg.onnx /home/.u2net/u2net_human_seg.onnx
RUN mv u2net_cloth_seg.onnx /home/.u2net/u2net_cloth_seg.onnx
EXPOSE 5000
ENTRYPOINT ["rembg"]
CMD ["s"]
With another nodeJs project I am using FROM ubuntu:20.04
as build and the startup latency is 4 seconds. I tried to do the same python project but it didn't helped. Any idea about the problem?