sksameermujahid's picture
Update Dockerfile
3474193 verified
FROM python:3.9
WORKDIR /app
# Create a non-root user
RUN useradd -m -u 1000 user
# Create cache directory and set permissions
RUN mkdir -p /home/user/.cache/huggingface && \
chown -R user:user /home/user/.cache
# Create property_db directory and set permissions
RUN mkdir -p /app/property_db && \
chown -R user:user /app/property_db
# Set environment variables for huggingface cache
ENV TRANSFORMERS_CACHE="/home/user/.cache/huggingface"
ENV HF_HOME="/home/user/.cache/huggingface"
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
# Create startup script
RUN echo '#!/bin/bash\n\
echo "Cleaning up ChromaDB..."\n\
rm -rf /app/property_db/*\n\
echo "Starting application..."\n\
python app.py' > /app/start.sh && \
chmod +x /app/start.sh
# Set proper ownership of all files
RUN chown -R user:user /app
# Switch to non-root user
USER user
# Expose the port the app runs on
EXPOSE 7860
# Command to run the startup script
CMD ["/app/start.sh"]