Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (49 loc) · 2.2 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (49 loc) · 2.2 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
# =============================================================================
# Base stage: official minimal Alpine Python runtime
# =============================================================================
FROM python:3.13-alpine AS base
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# =============================================================================
# Builder stage: build wheels / dependencies
# =============================================================================
FROM base AS builder
COPY requirements.txt ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir --prefix=/install -r requirements.txt
# =============================================================================
# Development / Test stage: includes dev tooling from pyproject.toml
# =============================================================================
FROM base AS development
# Copy installed production packages
COPY --from=builder /install /usr/local
# Copy dev dependencies and install test/lint tools
COPY pyproject.toml ./
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir black flake8 pytest pytest-asyncio pytest-cov
# Copy application source and tests
COPY main.py sanitize.py ./
COPY telegram_mcp ./telegram_mcp
COPY tests ./tests
CMD ["pytest", "--cov", "--cov-report=term-missing"]
# =============================================================================
# Production stage: slim runtime container with non-root appuser
# =============================================================================
FROM base AS production
# Copy only installed dependencies from builder
COPY --from=builder /install /usr/local
# Copy application source code
COPY main.py sanitize.py ./
COPY telegram_mcp ./telegram_mcp
# Create non-root user and setup directories
RUN adduser --disabled-password --gecos "" appuser && \
mkdir -p /app/data/transcripts && \
chown -R appuser:appuser /app
USER appuser
# Runtime environment variables (to be supplied at run/container start)
ENV TELEGRAM_API_ID="" \
TELEGRAM_API_HASH="" \
TELEGRAM_SESSION_NAME="telegram_mcp_session" \
TELEGRAM_SESSION_STRING=""
CMD ["python", "main.py"]