Skip to content

Commit 1019b87

Browse files
author
qiwen.luo
committed
fix: router use local
1 parent e1f75ac commit 1019b87

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ ADD ./go.mod ./go.sum /build/
1717
RUN go mod download
1818

1919
COPY . .
20-
COPY --from=builder-frontend /build/dist/* ./public/
2120

2221
RUN go build -trimpath -ldflags "-s -w" -o /build/bin/rm-schedule
2322

2423
FROM alpine:3.14
2524

25+
WORKDIR /app
26+
27+
COPY --from=builder-frontend /build/dist /app/public
2628
COPY --from=builder-backend /build/bin/rm-schedule /bin/rm-schedule
2729

2830
ENTRYPOINT ["/bin/rm-schedule"]

internal/router/router.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
package router
22

33
import (
4-
"embed"
5-
64
"github.com/kataras/iris/v12"
75
"github.com/scutrobotlab/rm-schedule/internal/handler"
86
)
97

108
// Router defines the router for this service
11-
func Router(r *iris.Application, frontend embed.FS) {
9+
func Router(r *iris.Application, frontend string) {
1210
api := r.Party("/api")
1311
api.Get("/schedule", handler.ScheduleHandler)
1412
api.Get("/group_rank_info", handler.GroupRankInfoHandler)
1513
api.Get("/static/*path", handler.RMStaticHandler)
1614
api.Get("/mp/match", handler.MpMatchHandler)
1715
api.Get("/rank", handler.RankListHandler)
1816

19-
r.HandleDir("/", frontend, iris.DirOptions{
17+
r.HandleDir("/", iris.Dir(frontend), iris.DirOptions{
2018
IndexName: "index.html",
2119
ShowList: false,
2220
Compress: true,

main.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
package main
22

33
import (
4-
"embed"
5-
64
"github.com/kataras/iris/v12"
75
"github.com/scutrobotlab/rm-schedule/internal/job"
86
"github.com/scutrobotlab/rm-schedule/internal/router"
97
)
108

11-
//go:embed public/*
12-
var frontend embed.FS
13-
149
func main() {
1510
cron := job.InitCronJob()
1611
cron.Start()
1712
defer cron.Stop()
1813

1914
r := iris.Default()
20-
router.Router(r, frontend)
15+
router.Router(r, "./public")
2116

2217
if err := r.Listen(":8080"); err != nil {
2318
panic(err)

0 commit comments

Comments
 (0)