Skip to content

Commit

Permalink
build: skip apt install and separate tessdata build step
Browse files Browse the repository at this point in the history
  • Loading branch information
winstxnhdw committed Jun 18, 2024
1 parent 6ee0d3b commit 31d13b8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Dockerfile.backend
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
FROM python:slim as builder
FROM python:slim as python-builder

ENV POETRY_VIRTUALENVS_CREATE false
ENV POETRY_HOME /opt/poetry
ENV PATH $POETRY_HOME/bin:$PATH

WORKDIR /

COPY pyproject.toml .
COPY pyproject.toml poetry.lock ./

RUN python -m venv $POETRY_HOME
RUN $POETRY_HOME/bin/pip install poetry
RUN poetry install --without dev


FROM curlimages/curl:latest as curl-builder

RUN apt update
RUN apt install -y curl
RUN curl -O https://raw.githubusercontent.com/tesseract-ocr/tessdata/main/eng.traineddata
RUN curl -sSL https://install.python-poetry.org | python -
RUN poetry install --without dev --no-root


FROM nvidia/cuda:12.5.0-runtime-ubuntu22.04
Expand All @@ -24,9 +27,9 @@ ENV TESSDATA_PREFIX /usr/share/tessdata

WORKDIR $HOME/app

COPY --from=builder /usr/local /usr/local
COPY --from=builder /eng.traineddata $TESSDATA_PREFIX/eng.traineddata
COPY --from=builder /lib/x86_64-linux-gnu/libexpat.so.1 /lib/x86_64-linux-gnu/libexpat.so.1
COPY --from=curl-builder /eng.traineddata $TESSDATA_PREFIX/eng.traineddata
COPY --from=python-builder /usr/local /usr/local
COPY --from=python-builder /lib/x86_64-linux-gnu/libexpat.so.1 /lib/x86_64-linux-gnu/libexpat.so.1
COPY . $HOME/app

CMD ["python", "main.py"]

0 comments on commit 31d13b8

Please sign in to comment.