Files
ALwrity/Dockerfile
Kunthawat Greethong 19b4ac53fc
Some checks failed
Lint Forced User ID Patterns / lint-forced-user-id (push) Has been cancelled
Add Dockerfile for EasyPanel deployment
2026-06-15 10:40:16 +07:00

73 lines
2.0 KiB
Docker

# ============================================================
# ALwrity Dockerfile — for EasyPanel deployment
# ============================================================
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package.json frontend/package-lock.json* ./
# Install deps (--legacy-peer-deps needed for react-scripts 5)
RUN npm install --legacy-peer-deps
# Copy frontend source
COPY frontend/ ./
# Build static assets
RUN npm run build
# ============================================================
# Stage 2: Python backend
FROM python:3.11-slim AS backend
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=8000
WORKDIR /app
# Install build deps for some Python packages
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libpq-dev \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first (for caching)
COPY backend/requirements.txt .
# Install Python deps
RUN pip install --no-cache-dir -r requirements.txt
# Copy backend source
COPY backend/ ./backend/
# Copy frontend build artifacts from Stage 1
COPY --from=frontend-builder /app/frontend/build ./frontend/build
# Create workspace directories (created by start_alwrity_backend.py but ensure they exist)
RUN mkdir -p /app/lib/workspace/alwrity_content \
/app/lib/workspace/alwrity_web_research \
/app/lib/workspace/alwrity_prompts \
/app/lib/workspace/alwrity_config
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
# Run with gunicorn + uvicorn workers (recommended for production)
# Fallback to plain uvicorn if gunicorn not installed
CMD python -m gunicorn backend.app:app \
--worker-class uvicorn.workers.UvicornWorker \
--bind 0.0.0.0:8000 \
--workers 2 \
--timeout 120 \
--access-logfile - \
--error-logfile - \
--log-level info