File tree Expand file tree Collapse file tree 6 files changed +40
-19
lines changed
Expand file tree Collapse file tree 6 files changed +40
-19
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ _testmain.go
3636device.json
3737Go-Mirai-Client
3838device- * .json
39- static /
39+ static /static
4040gmc- * .zip
4141captcha.jpg
4242/video
Original file line number Diff line number Diff line change 1+ FROM node:latest AS ui_builder
2+
3+ WORKDIR /build
4+
5+ RUN cd /build \
6+ && git clone https://github.com/ProtobufBot/pbbot-react-ui.git \
7+ && cd /build/pbbot-react-ui \
8+ && npm install \
9+ && npm run build
10+
111FROM golang:1.16-alpine AS gmc_builder
212
313RUN go env -w GO111MODULE=auto \
@@ -9,19 +19,10 @@ WORKDIR /build
919
1020COPY ./ .
1121
12- RUN cd /build \
13- && go build -ldflags "-s -w -extldflags '-static'" -o gmc
14-
15-
16- FROM node:latest AS ui_builder
17-
18- WORKDIR /build
22+ COPY --from=ui_builder /build/pbbot-react-ui/build ./static/static
1923
2024RUN cd /build \
21- && git clone https://github.com/ProtobufBot/pbbot-react-ui.git \
22- && cd /build/pbbot-react-ui \
23- && yarn install \
24- && yarn build
25+ && go build -ldflags "-s -w -extldflags '-static'" -o gmc
2526
2627FROM alpine:latest
2728
@@ -30,8 +31,6 @@ WORKDIR /data
3031COPY --from=gmc_builder /build/gmc /usr/bin/gmc
3132RUN chmod +x /usr/bin/gmc
3233
33- COPY --from=ui_builder /build/pbbot-react-ui/build /data/static
34-
3534ADD ./scripts/env_run.sh /data/
3635
3736RUN chmod +x /data/env_run.sh
Original file line number Diff line number Diff line change 4545# done
4646
4747# cp application.yml "${OUTPUT_DIR}/application.yml"
48- cp -r static " ${OUTPUT_DIR} /static" # https://github.com/ProtobufBot/Client-UI 前端编译产物dist
4948cp ./scripts/* " ${OUTPUT_DIR} /" # 复制运行脚本
5049
5150echo " 可以把不要的系统删掉" > " ${OUTPUT_DIR} /可以把不要的系统删掉"
Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ import (
1313 "github.com/ProtobufBot/Go-Mirai-Client/config"
1414 "github.com/ProtobufBot/Go-Mirai-Client/pkg/util"
1515 "github.com/ProtobufBot/Go-Mirai-Client/service/handler"
16+ "github.com/ProtobufBot/Go-Mirai-Client/static"
17+
1618 "github.com/gin-gonic/gin"
1719 log "github.com/sirupsen/logrus"
1820)
@@ -130,7 +132,7 @@ func InitGin() {
130132 }
131133
132134 router .Use (handler .CORSMiddleware ())
133- router .Static ("/" , "./ static" )
135+ router .StaticFS ("/" , http . FS ( static . MustGetStatic ()) )
134136 router .POST ("/bot/create/v1" , handler .CreateBot )
135137 router .POST ("/bot/delete/v1" , handler .DeleteBot )
136138 router .POST ("/bot/list/v1" , handler .ListBot )
Original file line number Diff line number Diff line change @@ -6,13 +6,15 @@ import (
66 "strconv"
77 _ "unsafe"
88
9- "github.com/Mrs4s/MiraiGo/client"
10- "github.com/Mrs4s/MiraiGo/message"
11- "github.com/Mrs4s/MiraiGo/utils"
9+
1210 "github.com/ProtobufBot/Go-Mirai-Client/config"
1311 "github.com/ProtobufBot/Go-Mirai-Client/pkg/clz"
1412 "github.com/ProtobufBot/Go-Mirai-Client/proto_gen/onebot"
1513 "github.com/ProtobufBot/Go-Mirai-Client/service/cache"
14+
15+ "github.com/Mrs4s/MiraiGo/client"
16+ "github.com/Mrs4s/MiraiGo/message"
17+ "github.com/Mrs4s/MiraiGo/utils"
1618 log "github.com/sirupsen/logrus"
1719)
1820
Original file line number Diff line number Diff line change 1+ package static
2+
3+ import (
4+ "embed"
5+ "io/fs"
6+ )
7+
8+ // 需要把前端文件放在static文件夹
9+
10+ //go:embed static
11+ var staticFs embed.FS
12+
13+ func MustGetStatic () fs.FS {
14+ f , err := fs .Sub (staticFs , "static" )
15+ if err != nil {
16+ panic (err )
17+ }
18+ return f
19+ }
You can’t perform that action at this time.
0 commit comments