mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-25 17:31:00 +00:00
Merge pull request #59 from mammo0/docker_include_models
Include language models into Docker image
This commit is contained in:
commit
5c73cebd9c
2 changed files with 13 additions and 1 deletions
10
Dockerfile
10
Dockerfile
|
@ -1,11 +1,21 @@
|
||||||
FROM python:3.8
|
FROM python:3.8
|
||||||
|
|
||||||
|
ARG with_models=false
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN pip install --upgrade pip
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
COPY . .
|
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
|
# Install package from source code
|
||||||
RUN pip install .
|
RUN pip install .
|
||||||
|
|
||||||
|
|
|
@ -80,9 +80,11 @@ Then open a web browser to http://localhost:5000
|
||||||
### Build with Docker
|
### Build with Docker
|
||||||
|
|
||||||
```bash
|
```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:
|
Run the built image:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
Loading…
Reference in a new issue