fix dockerfile

This commit is contained in:
Sebarocks 2025-07-31 21:51:38 -04:00
parent 33c5908b9f
commit e2bd322814

View file

@ -1,26 +1,23 @@
# Multi-stage build for chatsbt application
FROM denoland/deno:alpine AS frontend-builder
# Multi-stage build for a Python backend with Deno frontend
# Set working directory for frontend build
# Stage 1: Build the frontend
FROM denoland/deno:2.4.3 AS frontend-builder
# Set working directory for frontend
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package.json frontend/deno.lock ./
# Copy frontend files
COPY frontend/ .
# Install dependencies with script permissions
# Install dependencies and build the frontend
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
# Stage 2: Setup Python backend with uv
FROM python:3.11-slim AS backend
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Set working directory
WORKDIR /app
@ -29,36 +26,16 @@ WORKDIR /app
COPY pyproject.toml uv.lock ./
# Install Python dependencies
RUN uv sync --frozen --no-dev
RUN uv sync --frozen
# Copy backend source code
COPY app.py chatgraph.py controllers.py ./
COPY *.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 built frontend from previous stage
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 the port (adjust if your app uses a different 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"]