diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..906fd10 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +node_modules +.git +.gitignore +.remtools +.vibecoder +tasks.md +*.log +.env +.env.local +dist +build +__pycache__ +*.pyc +.pytest_cache +.ruff_cache diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2fb9fb3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,41 @@ +# Combined Dockerfile for FastAPI backend + React frontend +# Stage 1: Build frontend +FROM node:18-alpine AS frontend-builder +WORKDIR /app/frontend +COPY frontend/package*.json ./ +RUN npm ci +COPY frontend/ ./ +RUN npm run build + +# Stage 2: Build backend and serve both +FROM python:3.11-slim +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# Copy backend requirements and install +COPY backend/requirements.txt ./backend/ +RUN pip install --no-cache-dir -r backend/requirements.txt + +# Copy backend code +COPY backend/ ./backend/ + +# Copy built frontend from builder stage +COPY --from=frontend-builder /app/frontend/dist ./frontend/dist + +# Set environment variables +ENV PYTHONUNBUFFERED=1 +ENV PYTHONDONTWRITEBYTECODE=1 + +# Expose port +EXPOSE 8000 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:8000/health || exit 1 + +# Run FastAPI server with static file serving +CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]