train / Dockerfile
qgallouedec's picture
qgallouedec HF Staff
does it solve the cache issue?
1c0efea
raw
history blame
1 kB
# Use a lightweight Python image
FROM python:3-slim
WORKDIR /usr/src/app
# Install git and clean up to keep the image small
RUN apt-get update && \
apt-get install -y git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create cache directories with world-writable permissions
RUN mkdir -p /.cache /root/.cache && \
chmod -R 777 /.cache /root/.cache
# Install required dependencies
RUN pip install --upgrade pip
# Copy requirements first for better caching
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application files
COPY . .
# Make sft script executable
COPY sft.py /usr/local/bin/sft
RUN chmod +x /usr/local/bin/sft
# Set environment variables to use the writable cache
ENV XDG_CACHE_HOME=/.cache
ENV HF_HOME=/.cache/huggingface
ENV TRANSFORMERS_CACHE=/.cache/huggingface/transformers
ENV HF_DATASETS_CACHE=/.cache/huggingface/datasets
# Start gradio application
EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"
CMD ["python", "app.py"]