forked from su-kaka/gcli2api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (32 loc) · 1.2 KB
/
Copy pathDockerfile
File metadata and controls
41 lines (32 loc) · 1.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
# Multi-stage build for gcli2api
FROM python:3.13-slim as base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
TZ=Asia/Shanghai
# Install tzdata, jemalloc and set timezone
# jemalloc 替代 glibc malloc,大幅减少内存碎片化
RUN apt-get update && \
apt-get install -y --no-install-recommends tzdata libjemalloc2 && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# 使用 jemalloc 替代 glibc malloc
# jemalloc 会主动将空闲内存归还给操作系统,避免 RSS 持续增长
ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2
# jemalloc 配置:启用后台线程回收、脏页衰减时间 5 秒(默认 10 秒)
ENV MALLOC_CONF="background_thread:true,dirty_decay_ms:5000,muzzy_decay_ms:5000"
WORKDIR /app
# Copy only requirements first for better caching
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .
# Expose port
EXPOSE 7861
# Default command
CMD ["python", "web.py"]