QnIA-Translator-API / Dockerfile
pollitoconpapass's picture
Fixed Dockerfile att1
33cc276
# Use the official Python base image
FROM python:3.9-slim
# Set environment variables for predictable container behavior
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Create and set permissions for a custom cache directory
RUN mkdir -p /cache/huggingface && chmod -R 777 /cache
ENV TRANSFORMERS_CACHE=/cache/huggingface
# Set a working directory in the container
WORKDIR /app
# Install system dependencies for SentencePiece
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
libprotobuf-dev \
protobuf-compiler \
libsentencepiece-dev \
libsentencepiece0 \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file
COPY requirements.txt /app/
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the app source code into the container
COPY app.py /app/
# Expose the port the app runs on
EXPOSE 7860
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]