fix dockerfile
This commit is contained in:
parent
33c5908b9f
commit
e2bd322814
1 changed files with 16 additions and 39 deletions
53
Dockerfile
53
Dockerfile
|
|
@ -1,26 +1,23 @@
|
||||||
# Multi-stage build for chatsbt application
|
# Multi-stage build for a Python backend with Deno frontend
|
||||||
FROM denoland/deno:alpine AS frontend-builder
|
|
||||||
|
|
||||||
# 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
|
WORKDIR /app/frontend
|
||||||
|
|
||||||
# Copy frontend package files
|
# Copy frontend files
|
||||||
COPY frontend/package.json frontend/deno.lock ./
|
COPY frontend/ .
|
||||||
|
|
||||||
# Install dependencies with script permissions
|
# Install dependencies and build the frontend
|
||||||
RUN deno install --allow-scripts
|
RUN deno install --allow-scripts
|
||||||
|
|
||||||
# Copy frontend source code
|
|
||||||
COPY frontend/ ./
|
|
||||||
|
|
||||||
# Build the frontend
|
|
||||||
RUN deno run build
|
RUN deno run build
|
||||||
|
|
||||||
# Backend stage
|
# Stage 2: Setup Python backend with uv
|
||||||
FROM python:3.11-slim AS backend-builder
|
FROM python:3.11-slim AS backend
|
||||||
|
|
||||||
# Install uv
|
# 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
|
# Set working directory
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
@ -29,36 +26,16 @@ WORKDIR /app
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
|
|
||||||
# Install Python dependencies
|
# Install Python dependencies
|
||||||
RUN uv sync --frozen --no-dev
|
RUN uv sync --frozen
|
||||||
|
|
||||||
# Copy backend source code
|
# Copy backend source code
|
||||||
COPY app.py chatgraph.py controllers.py ./
|
COPY *.py ./
|
||||||
|
|
||||||
# Final stage
|
# Copy built frontend from previous 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
|
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
|
||||||
|
|
||||||
# Make sure the virtual environment is activated
|
# Expose the port (adjust if your app uses a different port)
|
||||||
#ENV PATH="/app/.venv/bin:$PATH"
|
|
||||||
|
|
||||||
# Expose port
|
|
||||||
EXPOSE 8000
|
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
|
# Run the application
|
||||||
CMD ["uv", "run", "app.py"]
|
CMD ["uv", "run", "app.py"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue