-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (73 loc) · 2.76 KB
/
Dockerfile
File metadata and controls
93 lines (73 loc) · 2.76 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
83
84
85
86
87
88
89
90
91
92
93
# SIP Relay Server v2 - Docker Image
# Multi-stage build for optimized image size
# =============================================================================
# Stage 1: Builder - Install dependencies and download models
# =============================================================================
FROM python:3.12-slim AS builder
# Install system dependencies for building
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
gcc \
python3-dev \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Install UV package manager
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"
# Set working directory
WORKDIR /app
# Copy dependency files first for better caching
COPY pyproject.toml uv.lock ./
# Install Python dependencies
RUN uv sync --frozen --no-dev
# =============================================================================
# Stage 2: Runtime - Final lightweight image
# =============================================================================
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04 AS runtime
# Labels
LABEL org.opencontainers.image.title="SIP Relay Server v2"
LABEL org.opencontainers.image.description="AI-powered SIP relay server with STT/LLM/TTS pipeline"
LABEL org.opencontainers.image.version="0.2.0"
# Install Python 3.12 and runtime dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3-pip \
ffmpeg \
libsndfile1 \
&& rm -rf /var/lib/apt/lists/* \
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python \
&& ln -sf /usr/bin/python3.12 /usr/local/bin/python3
# Set working directory
WORKDIR /app
# Copy UV from builder
COPY --from=builder /root/.local/bin/uv /usr/local/bin/uv
# Copy virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Set PATH to use virtual environment
ENV PATH="/app/.venv/bin:$PATH"
ENV VIRTUAL_ENV="/app/.venv"
# Copy application code
COPY . .
# Create required directories
RUN mkdir -p /app/output/transcode /app/output/response /app/output/converted /app/recording
# Ensure voices directory exists (should be volume-mounted or copied)
RUN mkdir -p /app/voices
# Health check - verify Python and key modules are importable
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD python -c "import websockets; import pydantic; print('OK')" || exit 1
# Default environment variables (can be overridden)
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV LOG_LEVEL=INFO
# Expose ports
# SIP UDP ports
EXPOSE 5060/udp
EXPOSE 5062/udp
# WebSocket TCP port
EXPOSE 8080/tcp
# RTP UDP port range (31000-31010)
EXPOSE 31000-31010/udp
# Default command - run the SIP receive server
CMD ["python", "receive_server.py"]