mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-12-18 08:27:03 +02:00
Merge pull request #235 from setokesan/include-models-in-docker
Added models include option in docker build
This commit is contained in:
commit
7f5e4db46b
10
Dockerfile
10
Dockerfile
@ -1,6 +1,7 @@
|
|||||||
FROM python:3.8.12-slim-bullseye
|
FROM python:3.8.12-slim-bullseye
|
||||||
|
|
||||||
ARG with_models=false
|
ARG with_models=false
|
||||||
|
ARG models=
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -14,14 +15,17 @@ RUN pip install --upgrade pip
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# check for offline build
|
|
||||||
RUN if [ "$with_models" = "true" ]; then \
|
RUN if [ "$with_models" = "true" ]; then \
|
||||||
# install only the dependencies first
|
# install only the dependencies first
|
||||||
pip install -e .; \
|
pip install -e .; \
|
||||||
# initialize the language models
|
# initialize the language models
|
||||||
./install_models.py; \
|
if [ ! -z "$models" ]; then \
|
||||||
|
./install_models.py --load_only_lang_codes "$models"; \
|
||||||
|
else \
|
||||||
|
./install_models.py; \
|
||||||
|
fi \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install package from source code
|
# Install package from source code
|
||||||
RUN pip install . \
|
RUN pip install . \
|
||||||
&& pip cache purge
|
&& pip cache purge
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import argparse
|
||||||
from app.init import check_and_install_models, check_and_install_transliteration
|
from app.init import check_and_install_models, check_and_install_transliteration
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
check_and_install_models(force=True)
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--load_only_lang_codes", type=str, default="")
|
||||||
|
args = parser.parse_args()
|
||||||
|
lang_codes = args.load_only_lang_codes.split(",") or None
|
||||||
|
check_and_install_models(force=True, load_only_lang_codes=lang_codes)
|
||||||
check_and_install_transliteration(force=True)
|
check_and_install_transliteration(force=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user