-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
97 lines (80 loc) · 2.35 KB
/
Dockerfile
File metadata and controls
97 lines (80 loc) · 2.35 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
94
95
96
97
# syntax=docker/dockerfile:1
# Base image for all stages
FROM python:3.13-slim-bookworm AS base
# Builder stage - install dependencies and build tools
FROM base AS builder
# Copy uv from official image
COPY --from=ghcr.io/astral-sh/uv:0.7.17 /uv /uvx /bin/
# Set uv environment variables for optimal performance
ENV UV_COMPILE_BYTECODE=1
ENV UV_LINK_MODE=copy
# Set working directory
WORKDIR /app
# Install system dependencies needed for building Python packages
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Build tools
gcc \
g++ \
git \
cmake \
meson \
# Python development headers
python3-dev \
# Image processing libraries (for Pillow)
libffi-dev \
libfreetype6-dev \
libfribidi-dev \
libharfbuzz-dev \
libjpeg62-turbo-dev \
liblcms2-dev \
libopenjp2-7-dev \
libtiff5-dev \
libwebp-dev \
zlib1g-dev \
# SSL and crypto
libssl-dev \
libsodium-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy dependency files first for better caching
COPY pyproject.toml uv.lock ./
# Install dependencies only (not the project itself)
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-install-project --no-dev
# Copy the rest of the application code
COPY . .
# Install the project itself
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev
# Runtime stage - minimal image with only what's needed to run
FROM base AS runtime
# Install only runtime system dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
# Runtime libraries for image processing
libfreetype6 \
libfribidi0 \
libharfbuzz0b \
libjpeg62-turbo \
liblcms2-2 \
libopenjp2-7 \
libtiff6 \
libwebp7 \
# For discord.py voice support (runtime versions)
libffi8 \
libsodium23 \
# FFmpeg for audio processing
ffmpeg \
# SSL runtime
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy the virtual environment from builder
COPY --from=builder /app/.venv /app/.venv
# Copy application code
COPY --from=builder /app/kidney-bot /app/kidney-bot
COPY --from=builder /app/lang /app/lang
# Set working directory
WORKDIR /app
# Make sure we use the virtual environment
ENV PATH="/app/.venv/bin:$PATH"
# Run the application
CMD ["python", "kidney-bot/main.py"]