Add Translation service Dockerfile

This commit is contained in:
2025-07-14 10:29:43 -05:00
parent 55b5f28d92
commit 5ae2ae758d

View File

@ -0,0 +1,44 @@
FROM python:3.11-slim
# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
wget \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy source code
COPY src/ ./src/
# Create necessary directories
RUN mkdir -p /app/models /app/logs
# Download NLLB models cache (will download on first use if not present)
# RUN python3 -c "from transformers import M2M100ForConditionalGeneration; M2M100ForConditionalGeneration.from_pretrained('facebook/nllb-200-distilled-600M')"
# Run as non-root user
RUN useradd -m -u 1001 translator
RUN chown -R translator:translator /app
USER translator
# Health check
HEALTHCHECK --interval=30s --timeout=15s --start-period=120s --retries=3 \
CMD python3 src/healthcheck.py || exit 1
# Expose port
EXPOSE 8000
# Start the service
CMD ["python3", "src/api.py"]