examide / Dockerfile.frontend
Mananjp's picture
docker
9ff5f0f
# ============================================================================
# Online Exam IDE — Frontend Dockerfile
# ============================================================================
# Streamlit-based frontend
# ============================================================================
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Create app directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY frontend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy frontend source code
COPY frontend/ .
# Expose Streamlit default port
EXPOSE 8501
# Health check - use 127.0.0.1 to avoid IPv6 resolution issues in Docker
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request, os; port=os.environ.get('PORT', '8501'); urllib.request.urlopen(f'http://127.0.0.1:{port}/_stcore/health')" || exit 1
# Run Streamlit using the dynamic PORT provided by the platform (e.g. Railway)
CMD sh -c "streamlit run app.py --server.port=${PORT:-8501} --server.address=0.0.0.0 --server.headless=true --server.enableCORS=false --server.enableXsrfProtection=false --server.enableWebsocketCompression=false --browser.gatherUsageStats=false"