opsgenius3 / Dockerfile
YALCINKAYA's picture
Update Dockerfile
f843516 verified
raw
history blame
1.11 kB
# Use the official Python image
FROM python:3.9-slim
# Set the working directory
WORKDIR /app
# Create a non-root user
RUN useradd -m appuser
# Create writable directories for Hugging Face and Triton cache
RUN mkdir -p /workspace/huggingface_cache /home/appuser/.triton && \
chmod -R 777 /workspace/huggingface_cache /home/appuser/.triton
# Set environment variables
ENV HF_HOME=/workspace/huggingface_cache
ENV TRITON_CACHE_DIR=/home/appuser/.triton
# Install system dependencies
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
# Set umask to ensure proper file permissions
RUN umask 002
# Copy the requirements file into the image
COPY requirements.txt requirements.txt
# Install required packages
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application code
COPY . .
# Change ownership to non-root user
RUN chown -R appuser:appuser /app /workspace/huggingface_cache /home/appuser/.triton
# Switch to non-root user
USER appuser
# Expose the port your application will run on
EXPOSE 7860
# Run the application
CMD ["python", "app.py"]