recipe-gen-api / Dockerfile
Chama99's picture
Update Dockerfile
16ae717 verified
# Use the official Python image from the Docker Hub
FROM python:3.11-slim
# Set the working directory in the container
WORKDIR /app
# Install system dependencies for SentencePiece
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements.txt file into the container
COPY requirements.txt .
# Install the dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Create a non-root user
RUN useradd -m -u 1000 appuser
# Create cache directories and set proper ownership
RUN mkdir -p /app/.cache/huggingface && \
chown -R appuser:appuser /app
# Set environment variable for Hugging Face cache
ENV HF_HOME=/app/.cache/huggingface
# Copy the rest of the application code into the container
COPY . .
# Change ownership of all app files to appuser
RUN chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose the port the app runs on
EXPOSE 7860
# Command to run the application
CMD ["python", "app.py"]