examide / Dockerfile.backend
Mananjp's picture
fix: change huggingface space SDK to docker
ebb5c56
# ============================================================================
# Online Exam IDE — Backend Dockerfile
# ============================================================================
# Multi-language code execution: Python, Node.js, Java (JDK), C++ (g++)
# ============================================================================
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install system dependencies for multi-language code execution
RUN apt-get update && apt-get install -y --no-install-recommends \
# Node.js for JavaScript execution
nodejs \
npm \
# C++ compiler
g++ \
# Java JDK for Java execution
default-jdk \
# DNS utils (needed for MongoDB Atlas SRV records)
dnsutils \
# Cleanup
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Copy requirements and install Python dependencies
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source code
COPY backend/ .
# Expose port
# Expose port (informative, Railway ignores this and uses PORT env var)
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request, os; port=os.environ.get('PORT', '8000'); urllib.request.urlopen(f'http://127.0.0.1:{port}/health')" || exit 1
# Run the application using the dynamic PORT provided by the platform (e.g. Railway)
# Use :: to listen on all interfaces (IPv4 + IPv6) — Railway routes via IPv6 internally
CMD sh -c "uvicorn main:app --host :: --port ${PORT:-8000}"