Apisix-dashboard: feat: embed all generated web assets into api binary

Created on 29 Jan 2021  Â·  8Comments  Â·  Source: apache/apisix-dashboard

Feature request

Embed all generated web assets into api binary, so it would be convenient to run or deploy the dashboard.

Just like grafana.

enhancement

Most helpful comment

Hii all, can I open a PR here? Yesterday I was giving it a casual try after a bit of conversation with @nic-chen and It seems I have completed the goal😅. Dev branch link
Go 1.16 release has official support for embedding static files into generated go binary. Here's the release notes. Just FYI, the package go-bindata has been achieved and not been maintained for a long time. So I went with the new embed package and go:embed directive of go 1.16.
here's the stats

plain binary

🔥➜ output git:(embed_assets) du -h manager-api
26M manager-api

web assets

🔥➜ output git:(embed_assets) du -sh html       
18M html

binary with web assets

🔥➜ output git:(embed_assets) du -h manager-api 
44M manager-api

Thanks :)

All 8 comments

I did a simple test with go-bindata, the api binary size increases about 4MB

I think this should be acceptable :-)

Before

-rwxr-xr-x 1 root root 27M Jan 29 09:02 output/manager-api

After

-rwxr-xr-x 1 root root 31M Jan 29 09:42 output/manager-api

And the origin html files have 15M

➜  apisix-dashboard git:(master) ✗ du -sh output/html
15M     output/html

That's sounds so great. PRs are welcomed.

@hnlq715 this is great and I love this feature. Thanks and looking forward to your contributions. 😄

@starsz @imjoey Get it

looking forward to it,thanks

Hii all, can I open a PR here? Yesterday I was giving it a casual try after a bit of conversation with @nic-chen and It seems I have completed the goal😅. Dev branch link
Go 1.16 release has official support for embedding static files into generated go binary. Here's the release notes. Just FYI, the package go-bindata has been achieved and not been maintained for a long time. So I went with the new embed package and go:embed directive of go 1.16.
here's the stats

plain binary

🔥➜ output git:(embed_assets) du -h manager-api
26M manager-api

web assets

🔥➜ output git:(embed_assets) du -sh html       
18M html

binary with web assets

🔥➜ output git:(embed_assets) du -h manager-api 
44M manager-api

Thanks :)

nice job

Was this page helpful?
0 / 5 - 0 ratings