| # Use an official Ubuntu base image (no CUDA by default) | |
| FROM ubuntu:20.04 | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| python3.10 \ | |
| python3-pip \ | |
| python3-dev \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set Python 3.10 as default python | |
| RUN ln -s /usr/bin/python3.10 /usr/bin/python | |
| # Install Python packages (CPU-compatible PyTorch by default) | |
| RUN pip3 install --no-cache-dir \ | |
| diffusers==0.2.4 \ | |
| torch==1.12.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu \ | |
| ftfy==6.1.1 \ | |
| scipy==1.9.0 \ | |
| transformers==4.21.1 \ | |
| pillow \ | |
| numpy \ | |
| tqdm | |
| # Copy all necessary files | |
| COPY image_to_image.py . | |
| COPY predict.py . | |
| COPY script/download-weights . | |
| # Create directories for cache and outputs | |
| RUN mkdir -p /app/diffusers-cache /tmp | |
| # Set environment variables | |
| ENV PYTHONPATH=/app | |
| ENV MODEL_CACHE=/app/diffusers-cache | |
| # Make the weights download script executable | |
| RUN chmod +x /app/download-weights | |
| # Default command - can be overridden when running the container | |
| CMD ["python", "predict.py"] | |
| # Note: You'll need to run the weights download script separately with your Hugging Face token | |
| # Example: docker run -it <image_name> /app/download-weights <your-hugging-face-auth-token> |