# 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"]