| | |
| |
|
| | |
| | FROM node:18-slim AS frontend-builder |
| |
|
| | WORKDIR /build |
| |
|
| | |
| | COPY frontend/package*.json ./ |
| | RUN npm ci |
| |
|
| | |
| | COPY frontend/src ./src |
| | COPY frontend/public ./public |
| | COPY frontend/next.config.js ./ |
| | COPY frontend/tsconfig.json ./ |
| | COPY frontend/tailwind.config.js ./ |
| | COPY frontend/postcss.config.js ./ |
| | |
| |
|
| | |
| | RUN npm run build |
| |
|
| | |
| | FROM python:3.11-slim |
| |
|
| | |
| | RUN apt-get update && \ |
| | apt-get install -y --no-install-recommends \ |
| | git \ |
| | nodejs \ |
| | npm \ |
| | && rm -rf /var/lib/apt/lists/* |
| |
|
| | |
| | RUN useradd -m -u 1000 user |
| |
|
| | |
| | USER user |
| |
|
| | |
| | ENV HOME=/home/user \ |
| | PATH=/home/user/.local/bin:$PATH \ |
| | PYTHONUNBUFFERED=1 |
| |
|
| | |
| | WORKDIR $HOME/app |
| |
|
| | |
| | COPY --chown=user:user requirements.txt . |
| | RUN pip install --no-cache-dir --upgrade pip && \ |
| | pip install --no-cache-dir -r requirements.txt |
| |
|
| | |
| | COPY --chown=user:user anycoder_app/ ./anycoder_app/ |
| | COPY --chown=user:user backend_api.py . |
| | COPY --chown=user:user backend_models.py . |
| | COPY --chown=user:user backend_prompts.py . |
| | COPY --chown=user:user backend_deploy.py . |
| | COPY --chown=user:user app.py . |
| |
|
| | |
| | COPY --chown=user:user --from=frontend-builder /build/.next ./frontend/.next |
| | COPY --chown=user:user --from=frontend-builder /build/public ./frontend/public |
| | COPY --chown=user:user --from=frontend-builder /build/package*.json ./frontend/ |
| | COPY --chown=user:user --from=frontend-builder /build/next.config.js ./frontend/ |
| | COPY --chown=user:user --from=frontend-builder /build/node_modules ./frontend/node_modules |
| |
|
| | |
| | |
| | |
| | ENV BACKEND_HOST=http://localhost:8000 \ |
| | PORT=7860 |
| |
|
| | |
| | |
| | RUN echo '#!/bin/bash\n\ |
| | set -e\n\ |
| | \n\ |
| | echo "π Starting AnyCoder Docker Space..."\n\ |
| | \n\ |
| | # Start backend on port 8000 in background\n\ |
| | echo "π‘ Starting FastAPI backend on port 8000..."\n\ |
| | cd $HOME/app\n\ |
| | uvicorn backend_api:app --host 0.0.0.0 --port 8000 &\n\ |
| | BACKEND_PID=$!\n\ |
| | \n\ |
| | # Wait for backend to be ready\n\ |
| | echo "β³ Waiting for backend to start..."\n\ |
| | sleep 5\n\ |
| | \n\ |
| | # Start frontend on port 7860 (HF Spaces exposed port)\n\ |
| | echo "π¨ Starting Next.js frontend on port 7860..."\n\ |
| | cd $HOME/app/frontend\n\ |
| | PORT=7860 BACKEND_HOST=http://localhost:8000 npm start\n\ |
| | ' > $HOME/app/start.sh && chmod +x $HOME/app/start.sh |
| |
|
| | |
| | EXPOSE 7860 |
| |
|
| | |
| | CMD ["./start.sh"] |
| |
|
| |
|