Skip to content

Commit

Permalink
Merge pull request #88 from weaviate/introduce-multistage-dockerfile
Browse files Browse the repository at this point in the history
Introduce multi stage Dockerfile
  • Loading branch information
antas-marcin authored Aug 11, 2024
2 parents 387b547 + 128deef commit 78bcdd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim
FROM python:3.11-slim AS base_image

WORKDIR /app

Expand All @@ -8,13 +8,23 @@ RUN pip install --upgrade pip setuptools
COPY requirements.txt .
RUN pip3 install -r requirements.txt

FROM base_image AS download_model

WORKDIR /app

ARG TARGETARCH
ARG MODEL_NAME
ARG ONNX_RUNTIME
ENV ONNX_CPU=${TARGETARCH}
RUN mkdir nltk_data
COPY download.py .
RUN ./download.py

FROM base_image AS t2v_transformers

WORKDIR /app
COPY --from=download_model /app/models /app/models
COPY --from=download_model /app/nltk_data /app/nltk_data
COPY . .

ENTRYPOINT ["/bin/sh", "-c"]
Expand Down
3 changes: 2 additions & 1 deletion download.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


model_dir = './models/model'
nltk_dir = './nltk_data'
model_name = os.getenv('MODEL_NAME', None)
force_automodel = os.getenv('FORCE_AUTOMODEL', False)
if not model_name:
Expand Down Expand Up @@ -108,7 +109,7 @@ def download_model(model_name: str, model_dir: str):
model.save_pretrained(model_dir)
tokenizer.save_pretrained(model_dir)

nltk.download('punkt', download_dir='./nltk_data')
nltk.download('punkt', download_dir=nltk_dir)

if onnx_runtime == "true":
download_onnx_model(model_name, model_dir)
Expand Down

0 comments on commit 78bcdd8

Please sign in to comment.