Spaces:
Sleeping
Sleeping
# Use the PyTorch image as the base | |
FROM pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime | |
# Create a new user with user ID 1000 | |
RUN useradd -m -u 1000 user | |
# Set environment variables | |
ENV HF_HOME=/home/user/cache | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Switch to the new user | |
USER user | |
WORKDIR /home/user/app | |
# Create the cache directory with correct ownership and permissions | |
RUN mkdir -p /home/user/cache && chmod -R 777 /home/user/cache | |
# Copy application files with ownership set to the new user | |
COPY --chown=user . /home/user/app | |
# Install Python dependencies, including uvicorn | |
RUN pip install --no-cache-dir -r requirements.txt uvicorn | |
# Debugging: Check if uvicorn is installed and print its location | |
RUN which uvicorn || echo "uvicorn is not installed!" | |
RUN pip show uvicorn || echo "uvicorn package details not found!" | |
RUN echo $PATH | |
# Expose the application port | |
EXPOSE 7860 | |
# Debugging: Print Python version and installed packages | |
RUN python --version | |
RUN pip list | |
# Run the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |