uhhjj / Dockerfile
Speedofmastery's picture
Auto-commit: Dockerfile updated
1ea8628
raw
history blame
1.5 kB
# 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"]