Files
wechatAiclaw/Dockerfile
2026-03-16 23:05:01 +08:00

64 lines
2.1 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
FROM docker.m.daocloud.io/library/node:20-alpine AS build
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm install
COPY tsconfig.json ./tsconfig.json
COPY src ./src
COPY public ./public
RUN npm run build
FROM docker.m.daocloud.io/library/node:20-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
TZ=Asia/Shanghai
# Alpine 使用国内镜像,加速 apk 安装python3/py3-pip并设置时区为 Asia/Shanghai与宿主机保持一致
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk add --no-cache python3 py3-pip tzdata \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo "Asia/Shanghai" > /etc/timezone
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/dist ./dist
COPY --from=build /app/public ./public
COPY backend/requirements.txt ./backend/requirements.txt
ARG PIP_INDEX="https://pypi.tuna.tsinghua.edu.cn/simple"
ARG PIP_TRUSTED_HOST="pypi.tuna.tsinghua.edu.cn"
RUN pip3 install --no-cache-dir --break-system-packages \
-i "${PIP_INDEX}" --trusted-host "${PIP_TRUSTED_HOST}" \
fastapi==0.115.0 && \
pip3 install --no-cache-dir --break-system-packages \
-i "${PIP_INDEX}" --trusted-host "${PIP_TRUSTED_HOST}" \
"uvicorn[standard]==0.30.0" && \
pip3 install --no-cache-dir --break-system-packages \
-i "${PIP_INDEX}" --trusted-host "${PIP_TRUSTED_HOST}" \
httpx==0.27.0 && \
pip3 install --no-cache-dir --break-system-packages \
-i "${PIP_INDEX}" --trusted-host "${PIP_TRUSTED_HOST}" \
"websockets>=12.0" && \
pip3 install --no-cache-dir --break-system-packages \
-i "${PIP_INDEX}" --trusted-host "${PIP_TRUSTED_HOST}" \
"openai>=1.0.0" && \
pip3 check && \
python3 -c "import fastapi; import uvicorn; import httpx; import websockets; import openai; print('all deps ok')"
COPY backend ./backend
# 仅复制模板,不复制 .env / .env.prod由 run-docker.sh --env-file .env.prod 注入)
COPY .env.example ./
COPY .env.prod.example ./
COPY start.sh ./
EXPOSE 3000 8000
CMD ["sh", "start.sh"]