-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
164 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
ARG PYTHON_VERSION="3.11" | ||
|
||
############################################################################### | ||
# 1. Install dependencies | ||
############################################################################### | ||
# poetry setup code based on https://github.com/thehale/docker-python-poetry (does not provide multiarch images) | ||
FROM python:${PYTHON_VERSION} AS build-python | ||
ARG POETRY_VERSION="1.6.1" | ||
|
||
ENV POETRY_VERSION=${POETRY_VERSION} | ||
ENV POETRY_HOME="/opt/poetry" | ||
ENV POETRY_VIRTUALENVS_IN_PROJECT=true | ||
ENV POETRY_NO_INTERACTION=1 | ||
ENV PATH="$POETRY_HOME/bin:$PATH" | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends curl | ||
# Install Poetry via the official installer: https://python-poetry.org/docs/master/#installing-with-the-official-installer | ||
# This script respects $POETRY_VERSION & $POETRY_HOME | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
# only install dependencies into project virtualenv | ||
WORKDIR /app | ||
COPY requirements.txt pyproject.toml poetry.lock ./ | ||
RUN poetry run python -m pip install -r requirements.txt | ||
RUN poetry install --only main --no-root --no-cache | ||
|
||
############################################################################### | ||
# 2. Final, minimal image that starts the inference server daemon | ||
############################################################################### | ||
FROM python:${PYTHON_VERSION}-slim | ||
ARG PYTHON_VERSION | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app | ||
COPY ./bpm_ai_inference/ ./bpm_ai_inference/ | ||
COPY --from=build-python /app/.venv/lib/python${PYTHON_VERSION}/site-packages /usr/local/lib/python${PYTHON_VERSION}/site-packages | ||
RUN apt-get update \ | ||
&& apt-get install -y --no-install-recommends curl tesseract-ocr poppler-utils \ | ||
&& apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY init.py . | ||
CMD ["python3", "init.py", "python -m bpm_ai_inference.daemon"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import subprocess | ||
import os | ||
import time | ||
import sys | ||
|
||
|
||
def main(): | ||
# Get the list of processes from command line arguments | ||
processes_params = [arg.split() for arg in sys.argv[1:]] | ||
# Start all processes | ||
processes = [subprocess.Popen(params) for params in processes_params] | ||
print(f"[init] Started {len(processes)} processes.") | ||
# Continuously monitor the processes | ||
while True: | ||
for i, process in enumerate(processes): | ||
exit_status = process.poll() | ||
if exit_status is not None: | ||
print(f"[init] Process '{' '.join(processes_params[i])}' exited with status {exit_status}, terminating other processes...") | ||
# Terminate all other processes | ||
for j, other_process in enumerate(processes): | ||
if i != j: | ||
other_process.terminate() | ||
return | ||
# Sleep for a bit to avoid busy-waiting | ||
time.sleep(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
spacy==3.7.4 | ||
torch==2.2.2 | ||
--extra-index-url https://download.pytorch.org/whl/cpu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters