-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (67 loc) · 2.88 KB
/
Dockerfile
File metadata and controls
82 lines (67 loc) · 2.88 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Use Python 3.11 slim image for better performance and security
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONPATH=/app \
PORT=8000 \
NLTK_DATA=/usr/local/nltk_data\
AIC_MODEL_PATH=/app/models/voice/aic/quail_l_8khz.aicmodel \
AIC_MODEL_PATH_16KHZ=/app/models/voice/aic/quail_l_16khz.aicmodel \
UV_CACHE_DIR=/app/.uv-cache
# Install system dependencies required for audio processing and compilation + curl for GCP CLI
RUN apt-get update && apt-get install -y \
build-essential \
ffmpeg \
libffi-dev \
libssl-dev \
pkg-config \
portaudio19-dev \
python3-dev \
curl \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Create app and model directories
WORKDIR /app
RUN mkdir -p /app/models/voice/aic
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Copy dependency files first for better Docker layer caching
COPY pyproject.toml uv.lock ./
# Install Python dependencies using uv
# Use --no-install-project to avoid installing the app/ package at this stage
# This allows optimal Docker layer caching - dependencies layer is cached separately
RUN uv sync --frozen --no-dev --no-install-project && \
uv pip show pipecat-ai
# Download AIC assets from GCP Storage using authenticated context
ARG AIC_BUCKET_PATH=gs://breeze-clairvoyance-models/aic
# Install Google Cloud CLI and download AIC files (only for GCP deployments)
# Use BuildKit secret mount to avoid leaking token in image layers
RUN --mount=type=secret,id=gcp_token \
if [ -f /run/secrets/gcp_token ]; then \
echo "=== Installing Google Cloud CLI for model assets ===" && \
curl -sSL https://sdk.cloud.google.com | bash && \
export PATH=$PATH:/root/google-cloud-sdk/bin && \
echo "=== Downloading AIC assets ===" && \
gcloud storage cp --access-token-file=/run/secrets/gcp_token ${AIC_BUCKET_PATH}/quail_l_8khz.aicmodel /app/models/voice/aic/ || echo "Warning: Failed to download quail_l_8khz.aicmodel"; \
gcloud storage cp --access-token-file=/run/secrets/gcp_token ${AIC_BUCKET_PATH}/quail_l_16khz.aicmodel /app/models/voice/aic/ || echo "Warning: Failed to download quail_l_16khz.aicmodel"; \
else \
echo "Warning: GCP token secret not provided, skipping AIC installation (AWS deployment)"; \
fi
# Create NLTK data directory and download required data
RUN mkdir -p /usr/local/nltk_data && \
uv run python -m nltk.downloader punkt punkt_tab -d /usr/local/nltk_data
# Copy application code
COPY . .
# Set proper permissions
RUN chmod +x run.py
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
RUN mkdir -p /app/.uv-cache && \
chown -R appuser:appuser /app && \
chown -R appuser:appuser /usr/local/nltk_data
USER appuser
# Expose port
EXPOSE ${PORT}
# Run the application
CMD ["uv", "run", "python", "run.py"]