From 930577a5be0dfcd366e2dca9df7ae57f21df6707 Mon Sep 17 00:00:00 2001 From: adldotori Date: Mon, 3 Apr 2023 04:45:50 +0000 Subject: [PATCH] build: divide dockerfile --- build/Dockerfile.cpu | 27 +++++++++++++++++++++++++++ Dockerfile => build/Dockerfile.gpu | 3 ++- docker-compose.yml | 23 +++++++++++++++++++---- 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 build/Dockerfile.cpu rename Dockerfile => build/Dockerfile.gpu (90%) diff --git a/build/Dockerfile.cpu b/build/Dockerfile.cpu new file mode 100644 index 0000000..91922c9 --- /dev/null +++ b/build/Dockerfile.cpu @@ -0,0 +1,27 @@ +FROM python:3.10 +WORKDIR /app/ + +ENV DEBIAN_FRONTEND=noninteractive + +RUN \ + apt-get update && \ + apt-get install -y software-properties-common && \ + add-apt-repository ppa:deadsnakes/ppa && \ + apt-get install -y python3.10 python3-pip curl && \ + curl -sSL https://install.python-poetry.org | python3 - + +ENV PATH "/root/.local/bin:$PATH" + +COPY pyproject.toml . +COPY poetry.lock . + +COPY api api +RUN poetry env use 3.10 +RUN poetry config installer.max-workers 10 +RUN poetry install --with tools + +COPY . . + +ENV PORT 8000 + +ENTRYPOINT ["poetry", "run", "serve"] \ No newline at end of file diff --git a/Dockerfile b/build/Dockerfile.gpu similarity index 90% rename from Dockerfile rename to build/Dockerfile.gpu index 18f643b..87640b4 100644 --- a/Dockerfile +++ b/build/Dockerfile.gpu @@ -17,10 +17,11 @@ COPY poetry.lock . COPY api api RUN poetry env use 3.10 +RUN poetry config installer.max-workers 10 RUN poetry install --with tools COPY . . -ENV PORT 8000 +ENV PORT 8001 ENTRYPOINT ["poetry", "run", "serve"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 654ce15..f1e7365 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,14 +5,29 @@ services: container_name: eval image: eval build: - dockerfile: Dockerfile + dockerfile: build/Dockerfile.cpu + context: . + volumes: + - ./static/:/app/static/ + ports: + - "3000:3000" + - "7000:7000" + - "8000:8000" # eval port + env_file: + - .env + + eval.gpu: + container_name: eval.gpu + image: eval.gpu + build: + dockerfile: build/Dockerfile.gpu context: . volumes: # if you want to decrease your model download time, use this. - ../.cache/huggingface/:/root/.cache/huggingface/ - ./static/:/app/static/ ports: - - "7500:7500" - - "7501:7501" + - "3000:3000" + - "7000:7000" - "8000:8000" # eval port env_file: - .env @@ -21,5 +36,5 @@ services: reservations: devices: - driver: nvidia - device_ids: ["3"] # You can choose which GPU to use + device_ids: ["1"] # You can choose which GPU to use capabilities: [gpu]