2025-07-31 21:51:38 -04:00
|
|
|
# Multi-stage build for a Python backend with Deno frontend
|
2025-07-31 19:00:28 -04:00
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Stage 1: Build the frontend
|
|
|
|
|
FROM denoland/deno:2.4.3 AS frontend-builder
|
|
|
|
|
|
|
|
|
|
# Set working directory for frontend
|
2025-07-31 19:00:28 -04:00
|
|
|
WORKDIR /app/frontend
|
|
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Copy frontend files
|
|
|
|
|
COPY frontend/ .
|
2025-07-31 19:00:28 -04:00
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Install dependencies and build the frontend
|
2025-07-31 19:00:28 -04:00
|
|
|
RUN deno install --allow-scripts
|
|
|
|
|
RUN deno run build
|
|
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Stage 2: Setup Python backend with uv
|
|
|
|
|
FROM python:3.11-slim AS backend
|
2025-07-31 19:00:28 -04:00
|
|
|
|
|
|
|
|
# Install uv
|
2025-07-31 21:51:38 -04:00
|
|
|
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
2025-07-31 19:00:28 -04:00
|
|
|
|
|
|
|
|
# Set working directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy Python project files
|
|
|
|
|
COPY pyproject.toml uv.lock ./
|
|
|
|
|
|
|
|
|
|
# Install Python dependencies
|
2025-07-31 21:51:38 -04:00
|
|
|
RUN uv sync --frozen
|
2025-07-31 19:00:28 -04:00
|
|
|
|
2025-07-31 22:50:03 -04:00
|
|
|
# Copy backend source code and .env file
|
2025-07-31 21:51:38 -04:00
|
|
|
COPY *.py ./
|
2025-07-31 22:50:03 -04:00
|
|
|
COPY .env ./
|
2025-07-31 19:00:28 -04:00
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Copy built frontend from previous stage
|
2025-07-31 19:00:28 -04:00
|
|
|
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
|
|
|
|
|
2025-07-31 21:51:38 -04:00
|
|
|
# Expose the port (adjust if your app uses a different port)
|
2025-07-31 19:00:28 -04:00
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
# Run the application
|
2025-07-31 22:50:03 -04:00
|
|
|
CMD ["uv", "run", "app.py"]
|