LifeVta commited on
Commit
7e04e18
·
verified ·
1 Parent(s): 27e8a43

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +2 -30
Dockerfile CHANGED
@@ -7,8 +7,6 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
7
 
8
  ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH"
9
 
10
- # Rust/Cargo are required to compile curl-cffi wheels on musl/Alpine.
11
- # If upstream ever ships musl wheels, remove cargo + rust to speed up builds.
12
  RUN apk add --no-cache \
13
  ca-certificates \
14
  build-base \
@@ -21,9 +19,7 @@ RUN apk add --no-cache \
21
 
22
  WORKDIR /app
23
 
24
- # Pin uv to a minor version for reproducible builds.
25
  COPY --from=ghcr.io/astral-sh/uv:0.6 /uv /uvx /bin/
26
-
27
  COPY pyproject.toml uv.lock ./
28
 
29
  RUN uv sync --frozen --no-dev --no-install-project \
@@ -47,25 +43,16 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
47
 
48
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
49
 
50
- RUN apk add --no-cache \
51
- tzdata \
52
- ca-certificates \
53
- libffi \
54
- openssl \
55
- libgcc \
56
- libstdc++ \
57
- libcurl
58
 
59
  WORKDIR /app
60
 
61
  COPY --from=builder /opt/venv /opt/venv
62
 
63
  COPY pyproject.toml config.defaults.toml ./
64
- COPY accounts.db.enc* ./
65
  COPY app ./app
66
  COPY scripts ./scripts
67
 
68
- # 建立标准的物理运行目录
69
  RUN mkdir -p /app/data /app/logs \
70
  && chmod +x /app/scripts/entrypoint.sh /app/scripts/init_storage.sh
71
 
@@ -75,19 +62,4 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
75
  CMD ["sh", "-c", "wget -qO /dev/null http://127.0.0.1:${SERVER_PORT}/health || exit 1"]
76
 
77
  ENTRYPOINT ["/app/scripts/entrypoint.sh"]
78
-
79
- # 🌟 核心改进:抛弃不稳定的 sed,改用纯 Python 拦截器,在服务拉起的最后一刻同时强刷默认模板与抢跑生成的运行时配置
80
- CMD ["sh", "-c", "python3 -c \"import os; \
81
- def patch(f): \
82
- if not os.path.exists(f): return; \
83
- t=open(f,'r',encoding='utf-8').read(); pw=os.getenv('APP_ACCESS_PASSWORD','grok2api'); \
84
- t=t.replace('app_key = \\\"grok2api\\\"', f'app_key = \\\"{pw}\\\"').replace('app_key = \\\"\\\"', f'app_key = \\\"{pw}\\\"'); \
85
- t=t.replace('app_url = \\\"\\\"', 'app_url = \\\"https://lifevta-grok2api.hf.space/\\\"'); \
86
- t=t.replace('api_key = \\\"\\\"', f'api_key = \\\"{pw}\\\"'); \
87
- t=t.replace('webui_enabled = false', 'webui_enabled = true'); \
88
- t=t.replace('webui_key = \\\"\\\"', f'webui_key = \\\"{pw}\\\"'); \
89
- t=t.replace('temporary = true', 'temporary = false'); \
90
- t=t.replace('memory = false', 'memory = true'); \
91
- t=t.replace('thinking_summary = false', 'thinking_summary = true'); \
92
- open(f,'w',encoding='utf-8').write(t); \
93
- for p in ['config.defaults.toml', 'data/config.toml', '/app/data/config.toml']: patch(p)\"; exec granian --interface asgi --host ${SERVER_HOST} --port ${SERVER_PORT} --workers ${SERVER_WORKERS} app.main:app"]
 
7
 
8
  ENV PATH="$UV_PROJECT_ENVIRONMENT/bin:$PATH"
9
 
 
 
10
  RUN apk add --no-cache \
11
  ca-certificates \
12
  build-base \
 
19
 
20
  WORKDIR /app
21
 
 
22
  COPY --from=ghcr.io/astral-sh/uv:0.6 /uv /uvx /bin/
 
23
  COPY pyproject.toml uv.lock ./
24
 
25
  RUN uv sync --frozen --no-dev --no-install-project \
 
43
 
44
  ENV PATH="$VIRTUAL_ENV/bin:$PATH"
45
 
46
+ RUN apk add --no-cache tzdata ca-certificates libffi openssl libgcc libstdc++ libcurl
 
 
 
 
 
 
 
47
 
48
  WORKDIR /app
49
 
50
  COPY --from=builder /opt/venv /opt/venv
51
 
52
  COPY pyproject.toml config.defaults.toml ./
 
53
  COPY app ./app
54
  COPY scripts ./scripts
55
 
 
56
  RUN mkdir -p /app/data /app/logs \
57
  && chmod +x /app/scripts/entrypoint.sh /app/scripts/init_storage.sh
58
 
 
62
  CMD ["sh", "-c", "wget -qO /dev/null http://127.0.0.1:${SERVER_PORT}/health || exit 1"]
63
 
64
  ENTRYPOINT ["/app/scripts/entrypoint.sh"]
65
+ CMD ["sh", "-c", "exec granian --interface asgi --host ${SERVER_HOST} --port ${SERVER_PORT} --workers ${SERVER_WORKERS} app.main:app"]