Spaces:
Sleeping
Sleeping
File size: 1,248 Bytes
68c9637 9598bf5 68c9637 e4b4c0d 9598bf5 68c9637 3c843c7 68c9637 7310181 68c9637 3c843c7 68c9637 e32f7a7 3c843c7 68c9637 7310181 68c9637 31c607d 68c9637 c502f8d 64eed03 9598bf5 c502f8d 64eed03 c502f8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# Use Python 3.11 base image
FROM python:3.11
# Update system and install git and curl
RUN apt-get update && apt-get install -y \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Clone LibreTranslate repository and set working directory
RUN git clone https://github.com/LibreTranslate/LibreTranslate.git
WORKDIR /LibreTranslate
# Change ownership of the application directory to the non-root user
RUN chown -R appuser:appuser /LibreTranslate
# Switch to non-root user
USER appuser
# Install Python requirements
RUN pip install --user libretranslate
# Install gunicorn
RUN pip install --user gunicorn
# Add user's local bin to PATH
ENV PATH="/home/appuser/.local/bin:${PATH}"
# Expose port 5000
EXPOSE 5000
# Complete list of all supported LibreTranslate language codes:
# ENV LT_LOAD_ONLY="en,es,fr,de,it,pt,ru,zh,ja,ar,hi,tr,pl,nl,sv,da,no,fi,cs,sk,hu,ro,bg,hr,sl,et,lv,lt,mt,ga,cy,is,mk,sq,bs,sr,uk,be,kk,ky,uz,tg,mn,ka,am,az,hy,eu,ca,gl"
# For common languages only (recommended for faster startup):
ENV LT_LOAD_ONLY="en,es,fr,de,it,pt,ru,zh,ja,ar,hi,tr,pl,nl"
# Run the application with specific languages
CMD ["sh", "-c", "libretranslate --host 0.0.0.0 --port 5000"] |