SUNCHAOWANG
commited on
Commit
•
4acecd8
1
Parent(s):
1ca448d
Update Dockerfile
Browse files- Dockerfile +8 -8
Dockerfile
CHANGED
@@ -5,18 +5,18 @@ WORKDIR /app
|
|
5 |
RUN git clone --branch sunchaowang --single-branch https://github.com/sunchaowang/new-api.git .
|
6 |
|
7 |
# 使用node镜像构建前端
|
8 |
-
|
9 |
|
10 |
WORKDIR /build
|
11 |
|
12 |
# 现在从git-clone阶段复制代码
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
# 再次从git-clone阶段复制代码
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
# 使用golang镜像构建后端
|
22 |
FROM golang AS builder2
|
@@ -32,7 +32,7 @@ COPY --from=git-clone /app/go.mod .
|
|
32 |
COPY --from=git-clone /app/go.sum .
|
33 |
RUN go mod download
|
34 |
# 从builder阶段复制前端构建产物
|
35 |
-
|
36 |
# 从git-clone阶段复制所有后端代码
|
37 |
COPY --from=git-clone /app .
|
38 |
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|
|
|
5 |
RUN git clone --branch sunchaowang --single-branch https://github.com/sunchaowang/new-api.git .
|
6 |
|
7 |
# 使用node镜像构建前端
|
8 |
+
FROM node:16 as builder
|
9 |
|
10 |
WORKDIR /build
|
11 |
|
12 |
# 现在从git-clone阶段复制代码
|
13 |
+
COPY --from=git-clone /app/web/package.json .
|
14 |
+
RUN npm config set registry https://registry.npmmirror.com/
|
15 |
+
RUN npm install
|
16 |
# 再次从git-clone阶段复制代码
|
17 |
+
COPY --from=git-clone /app/web .
|
18 |
+
COPY --from=git-clone /app/VERSION .
|
19 |
+
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat VERSION) npm run build
|
20 |
|
21 |
# 使用golang镜像构建后端
|
22 |
FROM golang AS builder2
|
|
|
32 |
COPY --from=git-clone /app/go.sum .
|
33 |
RUN go mod download
|
34 |
# 从builder阶段复制前端构建产物
|
35 |
+
COPY --from=builder /build/build /build/web/build
|
36 |
# 从git-clone阶段复制所有后端代码
|
37 |
COPY --from=git-clone /app .
|
38 |
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)' -extldflags '-static'" -o one-api
|