fix: avoid gf cli install in docker build
This commit is contained in:
+10
-5
@@ -21,11 +21,16 @@ COPY server/ .
|
||||
RUN rm -rf resource/public/admin && mkdir -p resource/public/admin
|
||||
COPY --from=web-build /web/dist/ ./resource/public/admin/
|
||||
|
||||
# main.go does `import _ "hotgo/internal/packed"`, a file normally generated by
|
||||
# `gf build` (see server/hack/config.yaml: packSrc/packDst) and gitignored —
|
||||
# generate it explicitly with the same gf CLI version pinned in go.mod.
|
||||
RUN go install github.com/gogf/gf/cmd/gf/v2@v2.10.0
|
||||
RUN gf pack resource internal/packed/packed.go
|
||||
# main.go imports internal/packed. Generate the packed resource file directly
|
||||
# through GoFrame's library API instead of installing the full gf CLI in CI.
|
||||
RUN printf '%s\n' \
|
||||
'package main' \
|
||||
'import "github.com/gogf/gf/v2/os/gres"' \
|
||||
'func main() {' \
|
||||
' if err := gres.PackToGoFileWithOption("resource", "internal/packed/packed.go", "packed", gres.Option{}); err != nil { panic(err) }' \
|
||||
'}' > /tmp/pack.go \
|
||||
&& go run /tmp/pack.go \
|
||||
&& rm /tmp/pack.go
|
||||
|
||||
RUN CGO_ENABLED=0 go build -o /out/hotgo main.go
|
||||
|
||||
|
||||
Reference in New Issue
Block a user