File size: 1,428 Bytes
a1a7d89 855ce9d 22a3959 15d41d0 22a3959 855ce9d 22a3959 855ce9d 22a3959 855ce9d 15d41d0 a1a7d89 855ce9d a1a7d89 855ce9d a1a7d89 15d41d0 855ce9d a1a7d89 855ce9d a1a7d89 855ce9d a1a7d89 855ce9d a1a7d89 855ce9d a1a7d89 |
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 35 36 37 38 39 40 41 42 43 44 45 |
FROM python:3.12-slim
# Set up a new user with user ID 1000
RUN useradd -m -u 1000 user
# Switch to root user temporarily for installing system dependencies
USER root
# Set environment variables for the user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directory
WORKDIR /home/user/app
# Upgrade pip
RUN pip install --no-cache-dir --upgrade pip==23.3.1
# Install necessary build tools (if required for your dependencies)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential && \
rm -rf /var/lib/apt/lists/*
# Switch back to the "user" user
USER user
# Copy the application code into the container at $HOME/app and set the ownership to the "user"
COPY --chown=user product_return_prediction $HOME/app/product_return_prediction
COPY --chown=user README.md $HOME/app/
COPY --chown=user requirements.txt $HOME/app/
COPY --chown=user pyproject.toml $HOME/app/
# Copy the external data and models, ensuring proper permissions
COPY --chown=user models/scaler.pkl $HOME/app/models/
COPY --chown=user models/svm.pkl $HOME/app/models/
# Install Python dependencies
RUN pip install --no-cache-dir -r $HOME/app/requirements.txt
# Expose port 7860 for the app
EXPOSE 7860
# Set the command to run the FastAPI app with Uvicorn
CMD ["uvicorn", "product_return_prediction.api:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
|