-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile.web
More file actions
65 lines (48 loc) · 1.86 KB
/
Dockerfile.web
File metadata and controls
65 lines (48 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Multi-stage build for smaller final image
# Optimized for Cloud Run deployment (web application only)
# Uses minimal dependencies (no Whisper/encoding packages)
FROM python:3.12-slim AS builder
# Install uv for fast dependency management
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Set working directory
WORKDIR /app
# Copy dependency files
COPY pyproject.toml uv.lock ./
# Install only core + web dependencies (no encoding/Whisper)
# This results in a much smaller image (~200MB vs ~2GB+)
RUN uv sync --frozen --no-dev --group web --no-install-project
# Final stage
FROM python:3.12-slim
# Install only curl for health checks
# Note: ffmpeg removed (not needed for web queries, saves ~100MB)
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -u 1000 -s /bin/bash podcast && \
mkdir -p /app && \
chown -R podcast:podcast /app
# Set working directory
WORKDIR /app
# Copy virtual environment from builder
COPY --from=builder --chown=podcast:podcast /app/.venv /app/.venv
# Copy application code (only what's needed for web service)
# Note: prompts are now in src/prompts/, so only src/ is needed
COPY --chown=podcast:podcast src/ ./src/
# Note: The web app requires a database connection for episode metadata lookups.
# Configure DATABASE_URL environment variable at runtime.
# Switch to non-root user
USER podcast
# Set environment variables
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PORT=8080
# Expose port (Cloud Run uses 8080 by default)
EXPOSE 8080
# Health check for Cloud Run
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Start web server
CMD ["uvicorn", "src.web.app:app", "--host", "0.0.0.0", "--port", "8080"]