Skip to content

Commit 9178392

Browse files
committed
Docker updates.
1 parent 32f7b4f commit 9178392

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN apt-add-repository multiverse && \
4343
RUN 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
4747
RUN 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
108108
COPY ./ /ocr_service
109109
WORKDIR /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
112116
RUN 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
118124
CMD ["/bin/bash", "start_service_production.sh"]

0 commit comments

Comments
 (0)