File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ RUN apt-add-repository multiverse && \
4343RUN apt-get install apt-fast -y --no-install-recommends
4444
4545# install req packages
46- RUN apt-fast install -y --no-install-recommends python3-all-dev python3-dev python3.12 python3-pip libpython3.12-dev python3.12-dev
46+ RUN apt-fast install -y --no-install-recommends python3-all-dev python3-dev python3.12 python3-pip libpython3.12-dev python3.12-dev pyrhon3.12-venv
4747RUN apt-fast -y --no-install-recommends -o Dpkg::Options::="--force-confold" -y -o Dpkg::Options::="--force-confdef" -fuy dist-upgrade && \
4848 apt-fast install -y --no-install-recommends \
4949 gnupg \
@@ -108,11 +108,17 @@ RUN mkdir /ocr_service
108108COPY ./ /ocr_service
109109WORKDIR /ocr_service
110110
111+ # Use a virtual environment for Python deps (single-stage build)
112+ ENV VIRTUAL_ENV=/opt/venv
113+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
114+
111115# Install uwsgi from PyPI source using the global tools
112116RUN python3.12 -m pip install --no-cache-dir --break-system-packages --no-build-isolation -r ./requirements.txt
117+ RUN python3.12 -m venv "$VIRTUAL_ENV" && "$VIRTUAL_ENV/bin/python" && "$VIRTUAL_ENV/bin/pip" install --no-cache-dir -r ./requirements.txt
113118
114119# compile the python files
115- RUN python3.12 -m compileall /ocr_service
120+ # Byte-compile using venv python
121+ RUN "$VIRTUAL_ENV/bin/python" -m compileall /ocr_se
116122
117123# Now run the simple api
118124CMD ["/bin/bash" , "start_service_production.sh" ]
You can’t perform that action at this time.
0 commit comments