From 76f069d4727f5001d3b1708f11134a727b7d0798 Mon Sep 17 00:00:00 2001 From: mammo0 Date: Thu, 11 Mar 2021 07:21:33 +0100 Subject: [PATCH 1/2] add an option to include the language models into the Docker image -> this allows the direct offline usage of the Docker image --- Dockerfile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Dockerfile b/Dockerfile index 2452638..661bf92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,21 @@ FROM python:3.8 +ARG with_models=false + WORKDIR /app RUN pip install --upgrade pip COPY . . +# check for offline build +RUN if [ "$with_models" = "true" ]; then \ + # install only the dependencies first + pip install -e .; \ + # initialize the language models + ./install_models.py; \ + fi + # Install package from source code RUN pip install . From 579cd7628966a695026fdd58fee00b32c4f76442 Mon Sep 17 00:00:00 2001 From: mammo0 Date: Thu, 11 Mar 2021 07:23:22 +0100 Subject: [PATCH 2/2] updated README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ecd52e..706a751 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,11 @@ Then open a web browser to http://localhost:5000 ### Build with Docker ```bash -docker build -t libretranslate . +docker build [--build-arg with_models=true] -t libretranslate . ``` +If you want to run the Docker image in a complete offline environment, you need to add the `--build-arg with_models=true` parameter. Then the language models get downloaded during the build process of the image. Otherwise these models get downloaded on the first run of the image/container. + Run the built image: ```bash