Files
bot-dashboard/backend/Dockerfile
Claude 22fce19050 fix: Resolve Docker build failures for frontend and backend
Backend fixes:
- Add g++ and build-essential for complete C++ compilation support
- Upgrade pip, setuptools, and wheel before installing dependencies
- Ensures psutil and other packages with native extensions build correctly

Frontend fixes:
- Add build arguments for NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL
- Pass environment variables during Docker build stage
- Set default values to prevent undefined destination in Next.js rewrites
- Configure docker-compose to pass build arguments to frontend service

These changes resolve:
- psutil build failure: "ERROR: Failed building wheel for psutil"
- Next.js build error: "Invalid rewrite found" with undefined destination
2025-11-21 11:58:56 +00:00

52 lines
1.3 KiB
Docker

# Multi-stage build for Python backend
FROM python:3.11-slim as builder
WORKDIR /app
# Install system dependencies for building Python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
python3-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install dependencies
COPY requirements.txt .
# Upgrade pip and setuptools first
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install dependencies with user flag
RUN pip install --no-cache-dir --user -r requirements.txt
# Production stage
FROM python:3.11-slim
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /root/.local /root/.local
# Make sure scripts in .local are usable
ENV PATH=/root/.local/bin:$PATH
# Copy application code
COPY ./app ./app
# Create directories
RUN mkdir -p /app/data /app/bots/logs /app/bots/configs /app/bots/examples
# 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 the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]