golang (5) uses beego + ace admin to develop background system CRUD, and uses scratch to build mirrors

The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/79884722

1. About golang admin


ace admin is a very good background system ui.
golang is one of my favorite languages.
And wrote an admin system.
I wrote a blog:
https://blog.csdn.net/freewebsys/article/details/68955060
Some buddies complained that they didn't see the code before.
I rearranged it again.
The code is not uploaded completely.
Now it has been sorted out, built into a mirror image, and uploaded to the hub.

github:
https://github.com/golangpkg/go-admin
docker hub:
https://hub.docker.com/r/golangpkg/go-admin/

Packaged with scratch empty image, 20MB+

2. Code description


Details have been written before. Not repeated:
https://blog.csdn.net/freewebsys/article/details/68955060Download
the mirror:

docker push docker.io/golangpkg/go-admin:latest
docker run --rm -it -p 8080:8080 docker.io/golangpkg/go-admin

Effect:

3, encountered build problems


Because it is using scratch, I found an error after compiling golang:

standard_init_linux.go:190: exec user process caused "no such file or directory"

Huge crash, because this one error is reported, and nothing else.
It was found that a lot of parameters were added when compiling golang.

env GOOS=linux GOARCH=amd64 CGO_ENABLED=1
go build -ldflags "-linkmode external -extldflags -static" -o go-admin main.go

Or refer to rancher learning.
https://github.com/rancher/docker-from-scratch/blob/master/scripts/build

Use the golang:stretch base image to compile in the build, and then copy the files out.
Put it into the scratch image to run.
The scratch image is an empty image and cannot be entered using exec. Neither is needed.

I get an error when compiling the sqlite database driver:

vendor/github.com/mattn/go-sqlite3/sqlite3_go18.go:18:10: undefined: SQLiteConn

It is found that this class is a lib library called using cgo, and the libsqlite3-dev development package is required.
Compilation warning on installation:

/go/src/github.com/freewebsys/go-admin/vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c:35900: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/tmp/go-link-879145469/000003.o: In function `mygetgrouplist':
/tmp/workdir/go/src/os/user/getgrouplist_unix.go:15: warning: Using 'getgrouplist' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

I don't know that everything is packaged into 20mb, and if there is no sqlite, it will be 10mb.

Also encountered permission issues on push to docker hub.
Find the full address to add url:

docker login -u golangpkg docker.io
docker push docker.io/golangpkg/go-admin:latest

golangpkg is the account I applied for.

4. Summary


When building an image, only the compiled files are copied.
Then copy the conf views static files and run beego.
And it runs, builds, and hits the docker image.
Very good, the resources are much smaller, next time I will use the go-admin system to develop a reporting tool.
Statistical tools or something. super fast. Develop fast, start fast and run fast.

The original link of this article is:
https://blog.csdn.net/freewebsys/article/details/79884722

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324877991&siteId=291194637