Do not hide docker folder

This commit is contained in:
Piero Toffanin 2023-01-13 10:24:56 -05:00
parent cfe904dfe2
commit 256e63f535
7 changed files with 6 additions and 6 deletions

43
docker/Dockerfile Normal file
View file

@ -0,0 +1,43 @@
FROM python:3.10.9-slim-bullseye as builder
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get -qqq install --no-install-recommends -y pkg-config gcc g++ \
&& apt-get clean \
&& rm -rf /var/lib/apt
RUN apt-get update && apt-get upgrade --assume-yes
RUN python -mvenv venv && ./venv/bin/pip install --upgrade pip
COPY . .
# Install package from source code, compile translations
RUN ./venv/bin/pip install Babel==2.11.0 && ./venv/bin/python scripts/compile_locales.py \
&& ./venv/bin/pip install . \
&& ./venv/bin/pip cache purge
FROM python:3.10.9-slim-bullseye
ARG with_models=false
ARG models=""
RUN addgroup --system --gid 1032 libretranslate && adduser --system --uid 1032 libretranslate && mkdir -p /home/libretranslate/.local && chown -R libretranslate:libretranslate /home/libretranslate/.local
USER libretranslate
COPY --from=builder --chown=1032:1032 /app /app
WORKDIR /app
RUN if [ "$with_models" = "true" ]; then \
# initialize the language models
if [ ! -z "$models" ]; then \
./venv/bin/python scripts/install_models.py --load_only_lang_codes "$models"; \
else \
./venv/bin/python scripts/install_models.py; \
fi \
fi
EXPOSE 5000
ENTRYPOINT [ "./venv/bin/libretranslate", "--host", "0.0.0.0" ]

46
docker/cuda.Dockerfile Normal file
View file

@ -0,0 +1,46 @@
FROM nvidia/cuda:11.2.2-devel-ubuntu20.04
ENV ARGOS_DEVICE_TYPE cuda
ARG with_models=true
ARG models=""
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq \
&& apt-get -qqq install --no-install-recommends -y libicu-dev libaspell-dev libcairo2 libcairo2-dev pkg-config gcc g++ python3.8-dev python3-pip libpython3.8-dev\
&& apt-get clean \
&& rm -rf /var/lib/apt
RUN apt-get update && apt-get upgrade --assume-yes
RUN pip3 install --upgrade pip && apt-get remove python3-pip --assume-yes
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN pip3 install torch==1.12.0+cu116 -f https://download.pytorch.org/whl/torch_stable.html
COPY . .
RUN if [ "$with_models" = "true" ]; then \
# install only the dependencies first
pip3 install -e .; \
# initialize the language models
if [ ! -z "$models" ]; then \
./scripts/install_models.py --load_only_lang_codes "$models"; \
else \
./scripts/install_models.py; \
fi \
fi
# Install package from source code
RUN pip3 install Babel==2.11.0 && python3 scripts/compile_locales.py \
&& pip3 install . \
&& pip3 cache purge
# Depending on your cuda install you may need to uncomment this line to allow the container to access the cuda libraries
# See: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#post-installation-actions
# ENV LD_LIBRARY_PATH=/usr/local/cuda/lib:/usr/local/cuda/lib64
EXPOSE 5000
ENTRYPOINT [ "libretranslate", "--host", "0.0.0.0" ]