Repository navigation
Expand file tree
/
Copy pathDockerfile.source
More file actions
63 lines (60 loc) · 2.78 KB
/
Copy pathDockerfile.source
File metadata and controls
63 lines (60 loc) · 2.78 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
# syntax=docker/dockerfile:1
#
# 源码全量构建镜像(自包含,无需预编译二进制):前端构建 → Go 编译 → 运行时。
# 与根目录 Dockerfile 的关系:那个是"预编译二进制 + 工具层"的打包镜像(CI 用);
# 这个是给用户 docker compose build 从源码一步出镜像用的,最终工具层与之一致。
#
# 构建(国内网络建议先给 Docker 配代理或改用镜像站):
# docker compose build # compose 已指向本文件
# ---------- ① 前端静态导出 ----------
FROM node:22-alpine AS fe
# 可选构建参数:国内构建用镜像源,默认官方源
ARG NPM_REGISTRY=https://registry.npmjs.org
WORKDIR /src/web
COPY web/package.json web/package-lock.json ./
RUN npm config set registry "$NPM_REGISTRY" && npm ci
COPY web/ ./
RUN npm run build:static
# ---------- ② Go 编译(内嵌前端) ----------
FROM golang:1.26-alpine AS gobuild
ARG GOPROXY=https://proxy.golang.org,direct
ENV GOPROXY=$GOPROXY
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p server/webui/dist
COPY --from=fe /src/web/out/ server/webui/dist/
# CGO_ENABLED=0 纯静态产物,alpine(musl)构建的二进制在 bookworm 运行时同样可跑
RUN CGO_ENABLED=0 go build -tags embedui -trimpath -ldflags "-s -w" -o /out/artex ./cmd/artex
# ---------- ③ 运行时(与 Dockerfile 工具层一致) ----------
FROM python:3.12-slim-bookworm
# 可选构建参数:APT 镜像站(默认官方 deb.debian.org;国内可传 mirrors.aliyun.com 或 mirrors.ustc.edu.cn)
ARG APT_MIRROR=
ARG NPM_REGISTRY=https://registry.npmjs.org
RUN if [ -n "$APT_MIRROR" ]; then \
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" /etc/apt/sources.list.d/debian.sources; \
fi \
&& apt-get update && apt-get install -y --no-install-recommends \
ca-certificates ripgrep curl wget vim git jq unzip \
dnsutils iputils-ping netcat-openbsd inetutils-telnet whois nmap \
&& curl -fsSL https://deb.nodesource.com/setup_20.x -o /tmp/nodesource_setup.sh \
&& echo "2c4c6683a17b6f4128898a7b521e3c8bb725a99ffaf1b5e32ac97c6fa7d381be /tmp/nodesource_setup.sh" | sha256sum -c - \
&& bash /tmp/nodesource_setup.sh \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -f /tmp/nodesource_setup.sh \
&& rm -rf /var/lib/apt/lists/*
RUN npm config set registry "$NPM_REGISTRY" \
&& npm install -g @playwright/mcp@0.0.80 @playwright/cli@0.1.19 playwright@1.63.0 \
&& playwright-cli --help \
&& playwright install --with-deps chromium \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=gobuild /out/artex /app/artex
COPY start.sh /app/start.sh
RUN chmod +x /app/artex /app/start.sh
COPY skills/ /app/skills/
VOLUME ["/app/data"]
EXPOSE 8787 8788
ENTRYPOINT ["/app/start.sh"]
CMD ["-addr", ":8787", "-proxy", ":8788"]