-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (59 loc) · 2.13 KB
/
Copy pathDockerfile
File metadata and controls
80 lines (59 loc) · 2.13 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
"""
Miku - Multi-stage Dockerfile
Build:
docker build -t miku .
Run (bot only):
docker run -e DISCORD_BOT_TOKEN=... -e DATABASE_URL=... miku
Run (dashboard only):
docker run -e DASHBOARD_CLIENT_ID=... -e DASHBOARD_CLIENT_SECRET=... -e DATABASE_URL=... \
miku uvicorn dashboard.backend.main:app --host 0.0.0.0 --port 8000
Run (both with docker-compose):
docker-compose up
"""
FROM python:3.14-slim AS builder
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
WORKDIR /app
# Install system build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install uv (fast Python package installer)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
# Install Python dependencies
COPY pyproject.toml requirements.txt ./
RUN uv pip install --system -e .
# Dashboard dependencies
COPY dashboard/requirements.txt dashboard/
RUN uv pip install --system -r dashboard/requirements.txt
# ── Runtime stage ────────────────────────────────────────────────────
FROM python:3.14-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
TZ=UTC
WORKDIR /app
# Install runtime system deps
RUN apt-get update && apt-get install -y --no-install-recommends \
libpq5 \
fonts-dejavu-core \
fonts-liberation \
&& rm -rf /var/lib/apt/lists/*
# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.14/site-packages /usr/local/lib/python3.14/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Copy application code
COPY . .
# Create non-root user
RUN groupadd -r miku && useradd -r -g miku -d /app -s /sbin/nologin miku && \
chown -R miku:miku /app
USER miku
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Default: run the bot
CMD ["python", "main.py"]
# Expose dashboard port
EXPOSE 8000