moodra-api / Dockerfile
muaazl's picture
good
8e219c1
Raw
History Blame Contribute Delete
869 Bytes
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV PORT 7860
# Set work directory
WORKDIR /code
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt \
&& python -m spacy download en_core_web_sm
# Copy project
COPY . .
# Create a non-root user (Recommended for Hugging Face)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose the port the app runs on
EXPOSE 7860
# Start the application using the port variable or fallback to 7860
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port ${PORT:-7860}"]