Spaces:
Paused
Paused
File size: 1,498 Bytes
fa3e081 3b536e0 fa3e081 d94d354 fa3e081 d94d354 1ea8628 599078b d94d354 48e7525 d94d354 48e7525 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# Use Ubuntu-based Python image for better Linux compatibility
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
wget \
build-essential \
sqlite3 \
&& rm -rf /var/lib/apt/lists/*
# Create user for security
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set working directory
WORKDIR $HOME/app
# Copy requirements first for better caching
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
# Copy application code
COPY --chown=user . .
# Create necessary directories
RUN mkdir -p logs data cache
# Set environment variables for the application
ENV PYTHONPATH=$HOME/app
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
# Cloudflare configuration (to be set in Space settings)
ENV CLOUDFLARE_API_TOKEN=""
ENV CLOUDFLARE_ACCOUNT_ID=""
ENV CLOUDFLARE_D1_DATABASE_ID=""
ENV CLOUDFLARE_R2_BUCKET_NAME=""
ENV CLOUDFLARE_KV_NAMESPACE_ID=""
ENV CLOUDFLARE_DURABLE_OBJECTS_ID=""
# Expose port
EXPOSE 7860
# Make startup script executable
RUN chmod +x start.sh
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
# Use startup script for better Linux compatibility
CMD ["./start.sh"]
|