Update Dockerfile
Browse files- Dockerfile +23 -23
Dockerfile
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
FROM node:
|
2 |
|
3 |
-
WORKDIR /
|
4 |
-
RUN git clone https://github.com/
|
5 |
RUN wget -qO- -t1 -T2 "https://api.github.com/repos/ai365vip/chat-api/releases" | \
|
6 |
grep "tag_name" | \
|
7 |
head -n 1 | \
|
8 |
awk -F ":" '{print $2}' | \
|
9 |
sed 's/\"//g;s/,//g;s/ //g' > VERSION
|
10 |
|
11 |
-
|
12 |
-
|
|
|
13 |
|
14 |
-
|
15 |
-
RUN npm
|
16 |
-
RUN
|
17 |
|
18 |
-
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
CGO_ENABLED=1 \
|
22 |
-
GOOS=linux
|
23 |
|
24 |
WORKDIR /build
|
25 |
-
COPY --from=builder /
|
26 |
RUN go mod download
|
27 |
-
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
28 |
-
|
29 |
-
FROM alpine
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
&& apk add --no-cache ca-certificates tzdata \
|
34 |
-
&& update-ca-certificates 2>/dev/null || true
|
35 |
|
36 |
-
|
37 |
|
|
|
38 |
|
39 |
-
|
|
|
40 |
COPY --from=cloudflare/cloudflared:latest /usr/local/bin/cloudflared /usr/local/bin/cloudflared
|
|
|
41 |
EXPOSE 3000
|
|
|
42 |
WORKDIR /data
|
43 |
RUN chmod 777 -R /data
|
44 |
ENTRYPOINT cloudflared tunnel --no-autoupdate run --token $CF_TOKEN & \
|
45 |
-
/
|
|
|
1 |
+
FROM node:18.19.0-alpine as react-builder
|
2 |
|
3 |
+
WORKDIR /app
|
4 |
+
RUN git clone https://github.com/ai365vip/chat-api.git .
|
5 |
RUN wget -qO- -t1 -T2 "https://api.github.com/repos/ai365vip/chat-api/releases" | \
|
6 |
grep "tag_name" | \
|
7 |
head -n 1 | \
|
8 |
awk -F ":" '{print $2}' | \
|
9 |
sed 's/\"//g;s/,//g;s/ //g' > VERSION
|
10 |
|
11 |
+
# 复制 web-user 和 web-admin 的 package.json 和 package-lock.json 到当前目录
|
12 |
+
COPY web-user/package.json web-user/package-lock.json ./web-user/
|
13 |
+
COPY web-admin/package.json web-admin/package-lock.json ./web-admin/
|
14 |
|
15 |
+
# 为 web-user 和 web-admin 安装依赖项
|
16 |
+
RUN npm ci --prefix web-user
|
17 |
+
RUN npm ci --prefix web-admin
|
18 |
|
19 |
+
# 构建 web-user 和 web-admin 应用
|
20 |
+
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build --prefix web-user
|
21 |
+
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build --prefix web-admin
|
22 |
|
23 |
+
FROM golang:latest AS go-builder
|
|
|
|
|
24 |
|
25 |
WORKDIR /build
|
26 |
+
COPY --from=react-builder /app .
|
27 |
RUN go mod download
|
|
|
|
|
|
|
28 |
|
29 |
+
# 构建 Go 二进制文件
|
30 |
+
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o chat-api
|
|
|
|
|
31 |
|
32 |
+
FROM alpine:latest
|
33 |
|
34 |
+
RUN apk update && apk add --no-cache ca-certificates tzdata && update-ca-certificates && rm -rf /var/cache/apk/*
|
35 |
|
36 |
+
# 复制 Go 二进制文件
|
37 |
+
COPY --from=go-builder /build/chat-api /chat-api
|
38 |
COPY --from=cloudflare/cloudflared:latest /usr/local/bin/cloudflared /usr/local/bin/cloudflared
|
39 |
+
|
40 |
EXPOSE 3000
|
41 |
+
|
42 |
WORKDIR /data
|
43 |
RUN chmod 777 -R /data
|
44 |
ENTRYPOINT cloudflared tunnel --no-autoupdate run --token $CF_TOKEN & \
|
45 |
+
/chat-api
|