pyrunner / Dockerfile
Perspicacious's picture
Add Postgres support for PyRunner HF
e4f2163
Raw
History Blame Contribute Delete
1.26 kB
FROM python:3.13-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
DJANGO_SETTINGS_MODULE=pyrunner.settings \
PORT=7860 \
DEBUG=False \
SECURE_SSL_REDIRECT=False \
ALLOWED_HOSTS=.hf.space,localhost,127.0.0.1 \
CSRF_TRUSTED_ORIGINS=https://*.hf.space \
PYRUNNER_DATA_DIR=/data \
DB_TYPE=sqlite
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Create data directories
RUN mkdir -p /app/data/environments /app/data/workdir /data/environments /data/workdir
# Collect static files (build-time only keys, not used at runtime)
ENV SECRET_KEY="build-only-key-not-for-runtime"
ENV ENCRYPTION_KEY="QUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUE="
RUN python manage.py collectstatic --noinput
# Copy and set up entrypoint (convert Windows CRLF to Unix LF)
COPY entrypoint.sh /entrypoint.sh
RUN sed -i 's/\r$//' /entrypoint.sh && chmod +x /entrypoint.sh
# Expose port
EXPOSE 8000
# Set entrypoint
ENTRYPOINT ["/entrypoint.sh"]