chatsbt/Dockerfile

65 lines
1.5 KiB
Text
Raw Normal View History

2025-07-31 19:00:28 -04:00
# Multi-stage build for chatsbt application
FROM denoland/deno:alpine AS frontend-builder
# Set working directory for frontend build
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package.json frontend/deno.lock ./
# Install dependencies with script permissions
RUN deno install --allow-scripts
# Copy frontend source code
COPY frontend/ ./
# Build the frontend
RUN deno run build
# Backend stage
FROM python:3.11-slim AS backend-builder
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Set working directory
WORKDIR /app
# Copy Python project files
COPY pyproject.toml uv.lock ./
# Install Python dependencies
RUN uv sync --frozen --no-dev
# Copy backend source code
COPY app.py chatgraph.py controllers.py ./
# Final stage
FROM python:3.11-slim
# Install uv in final stage
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Set working directory
WORKDIR /app
# Copy backend dependencies and source
#COPY --from=backend-builder /app/.venv ./.venv
COPY --from=backend-builder /app/app.py /app/chatgraph.py /app/controllers.py ./
# Copy built frontend
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Make sure the virtual environment is activated
#ENV PATH="/app/.venv/bin:$PATH"
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD python -c "import requests; requests.get('http://localhost:8000/health', timeout=10)"
# Run the application
CMD ["uv", "run", "app.py"]