Spaces:
Sleeping
Sleeping
File size: 883 Bytes
8fc0265 54c7718 8fc0265 c9fdbee 8fc0265 c9fdbee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# Use an official Python runtime as a parent image
FROM python:3.9-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Create a non-root user
RUN useradd --create-home user
# Set the working directory to the user's home directory
WORKDIR /home/user
# Copy and install dependencies
COPY --chown=user:user requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the application code
COPY --chown=user:user app.py ./
COPY --chown=user:user model.pkl ./
# Switch to the non-root user
USER user
# Set environment variables for the application
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose the port uvicorn will run on
EXPOSE 7860
# Define the default command to run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|