CoolFace
Apppublic

z4iXsECHS6ND-heighTSAI-INSEGCSyX6T-SYS-ROD/Web.GPU-coder.js.ipynb.git.py.js.html

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
Dockerfile106 linesDownload Raw Back to root
1# Multi-stage build for AnyCoder Docker Space2 3# Stage 1: Build frontend4FROM node:22-slim AS frontend-builder5 6WORKDIR /build7 8# Copy frontend package files9COPY frontend/package*.json ./10RUN npm ci11 12# Copy all frontend source files and configs13COPY frontend/src ./src14COPY frontend/public ./public15COPY frontend/next.config.js ./16COPY frontend/tsconfig.json ./17COPY frontend/tailwind.config.js ./18COPY frontend/postcss.config.js ./19# Note: next-env.d.ts is auto-generated by Next.js, not needed for build20 21# Build frontend22RUN npm run build23 24# Stage 2: Production image25FROM python:3.11-slim26 27# Install system dependencies as root (git for pip, nodejs for frontend)28# Install Node.js 22 from NodeSource (Debian repo only has v18)29RUN apt-get update && \30    apt-get install -y --no-install-recommends curl ca-certificates gnupg git && \31    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \32    apt-get install -y --no-install-recommends nodejs && \33    rm -rf /var/lib/apt/lists/*34 35# Set up a new user named "user" with user ID 100036RUN useradd -m -u 1000 user37 38# Switch to the "user" user39USER user40 41# Set home to the user's home directory42ENV HOME=/home/user \43    PATH=/home/user/.local/bin:$PATH \44    PYTHONUNBUFFERED=145 46# Set the working directory to the user's home directory47WORKDIR $HOME/app48 49# Copy Python requirements and install dependencies50COPY --chown=user:user requirements.txt .51RUN pip install --no-cache-dir --upgrade pip && \52    pip install --no-cache-dir -r requirements.txt53 54# Copy application code55COPY --chown=user:user backend_api.py .56COPY --chown=user:user backend_models.py .57COPY --chown=user:user backend_docs_manager.py .58COPY --chown=user:user backend_prompts.py .59COPY --chown=user:user backend_parsers.py .60COPY --chown=user:user backend_deploy.py .61COPY --chown=user:user backend_search_replace.py .62COPY --chown=user:user project_importer.py .63 64# Copy built frontend from builder stage65COPY --chown=user:user --from=frontend-builder /build/.next ./frontend/.next66COPY --chown=user:user --from=frontend-builder /build/public ./frontend/public67COPY --chown=user:user --from=frontend-builder /build/package*.json ./frontend/68COPY --chown=user:user --from=frontend-builder /build/next.config.js ./frontend/69COPY --chown=user:user --from=frontend-builder /build/node_modules ./frontend/node_modules70 71# Set environment variables for the application72# BACKEND_HOST is used by Next.js server for proxying73# Do NOT set NEXT_PUBLIC_API_URL - let frontend use relative URLs74ENV BACKEND_HOST=http://localhost:8000 \75    PORT=786076 77# Create startup script that runs both services78# Backend on 8000, Frontend on 7860 (exposed port)79RUN echo '#!/bin/bash\n\80set -e\n\81\n\82echo "๐Ÿš€ Starting AnyCoder Docker Space..."\n\83\n\84# Start backend on port 8000 in background\n\85echo "๐Ÿ“ก Starting FastAPI backend on port 8000..."\n\86cd $HOME/app\n\87uvicorn backend_api:app --host 0.0.0.0 --port 8000 &\n\88BACKEND_PID=$!\n\89\n\90# Wait for backend to be ready\n\91echo "โณ Waiting for backend to start..."\n\92sleep 5\n\93\n\94# Start frontend on port 7860 (HF Spaces exposed port)\n\95echo "๐ŸŽจ Starting Next.js frontend on port 7860..."\n\96cd $HOME/app/frontend\n\97PORT=7860 BACKEND_HOST=http://localhost:8000 npm start\n\98' > $HOME/app/start.sh && chmod +x $HOME/app/start.sh99 100# Expose port 7860 (HF Spaces default)101EXPOSE 7860102 103# Run the startup script104CMD ["./start.sh"]105 106