forked from RichardAtCT/claude-code-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
71 lines (52 loc) · 1.99 KB
/
Dockerfile
File metadata and controls
71 lines (52 loc) · 1.99 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
# ---- Build stage ----
FROM python:3.11-slim AS builder
# Optional dependency build args
ARG INSTALL_POSTGRES=false
ARG INSTALL_CACHE=false
RUN pip install --no-cache-dir poetry==2.3.2
WORKDIR /app
COPY pyproject.toml poetry.lock ./
# Export requirements and install without Poetry runtime overhead
RUN poetry export -f requirements.txt --without dev --without-hashes -o requirements.txt
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# Conditionally install optional extras
RUN if [ "$INSTALL_POSTGRES" = "true" ]; then \
pip install --no-cache-dir --prefix=/install asyncpg; \
fi
RUN if [ "$INSTALL_CACHE" = "true" ]; then \
pip install --no-cache-dir --prefix=/install redis; \
fi
# ---- Runtime stage ----
FROM python:3.11-slim
# Install Node.js for Claude CLI (required for SDK auth via CLI)
RUN apt-get update && \
apt-get install -y --no-install-recommends curl git && \
curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y --no-install-recommends nodejs && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Install Claude CLI globally
RUN npm install -g @anthropic-ai/claude-code
# Copy Python deps from builder
COPY --from=builder /install /usr/local
WORKDIR /app
# Copy application code
COPY src/ src/
COPY pyproject.toml ./
# Copy Grafana dashboard definitions for reference
COPY docs/grafana/ docs/grafana/
# Install the project itself (editable not needed in container)
RUN pip install --no-cache-dir --no-deps .
# Create data directory for SQLite
RUN mkdir -p /app/data
# Create non-root user
RUN useradd -m -s /bin/bash botuser && chown -R botuser:botuser /app
USER botuser
# Default env vars
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
LOG_LEVEL=INFO
EXPOSE 8080
# Health check (works when API server is enabled via ENABLE_API_SERVER=true)
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
CMD curl -f http://localhost:8080/health || exit 1
ENTRYPOINT ["claude-telegram-bot"]