How to build a binary with embedded frontend? #5402
-
|
I want to build a binary with the latest source by myself. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
If you want to build a binary with the frontend embedded, here’s the usual approach:
If you’re using Docker, you can add a multi-stage build where the first stage builds the frontend, and the second stage compiles Go and embeds the assets. This keeps the image clean and portable. |
Beta Was this translation helpful? Give feedback.
-
|
I want a real working script, not this kind of AI-generated stuff. |
Beta Was this translation helpful? Give feedback.
If you want to build a binary with the frontend embedded, here’s the usual approach:
Build the frontend first
npm run buildoryarn buildinside theweborfrontendfolder).distorbuilddirectory.Embed those assets into the Go binary
go:embed(available since Go 1.16) to include the frontend files directly:Update your build script