Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangwenjian committed 2022-08-18 06:57:20 +08:00
commit a585e29073
11 files changed
+124 -25

No files matched your search

+1 -1
View File
@@ -4,11 +4,11 @@
static/uploadfile
main.exe
go-admin
go-admin.exe
temp/
!temp
vendor
config/settings.dev.yml
go-admin
common/middleware/demo.go
config/settings.dev.*.yml
config/settings.dev.*.yml.log
+15 -14
View File
@@ -1,28 +1,29 @@
FROM golang:alpine as builder
MAINTAINER lwnmengjing
MAINTAINER haimait
ENV GOPROXY https://goproxy.cn/
WORKDIR /work
WORKDIR /go/release
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk add tzdata
RUN go env -w GOPROXY=https://goproxy.cn,direct && go env -w CGO_ENABLED=0
COPY go.mod go.sum ./
RUN go mod download
COPY go.mod ./go.mod
RUN go mod tidy
COPY . .
RUN pwd && ls
RUN go build -o go-admin main.go
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin .
FROM alpine
FROM alpine:latest
# change timezone
RUN apk add --no-cache tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
COPY --from=builder /go/release/go-admin /
WORKDIR /go-admin-api
COPY --from=builder /go/release/config/settings.yml /config/settings.yml
COPY --from=builder /work/go-admin ./
COPY --from=builder /work/config ./config
COPY --from=builder /work/static ./static
COPY --from=builder /work/temp ./temp
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 8000
CMD ["/go-admin","server","-c", "/config/settings.yml"]
CMD ["./go-admin","server","-c", "config/settings.dev.yml"]
+28
View File
@@ -0,0 +1,28 @@
FROM golang:alpine as builder
MAINTAINER lwnmengjing
ENV GOPROXY https://goproxy.cn/
WORKDIR /go/release
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
RUN apk update && apk add tzdata
COPY go.mod ./go.mod
RUN go mod tidy
COPY . .
RUN pwd && ls
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o go-admin .
FROM alpine
COPY --from=builder /go/release/go-admin /
COPY --from=builder /go/release/config/settings.yml /config/settings.yml
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
EXPOSE 8000
CMD ["/go-admin","server","-c", "/config/settings.yml"]
+39 -1
View File
@@ -3,10 +3,40 @@ PROJECT:=go-admin
.PHONY: build
build:
CGO_ENABLED=0 go build -ldflags="-w -s" -a -installsuffix -o go-admin .
# make build-linux
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -a -installsuffix -o go-admin .
@docker build -t go-admin:latest .
@echo "build successful"
build-sqlite:
go build -tags sqlite3 -ldflags="-w -s" -a -installsuffix -o go-admin .
# make run
run:
# delete go-admin-api container
@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi
# 启动方法一 run go-admin-api container docker-compose 启动方式
# 进入到项目根目录 执行 make run 命令
@docker-compose up -d
# 启动方式二 docker run 这里注意-v挂载的宿主机的地址改为部署时的实际决对路径
#@docker run --name=go-admin -p 8000:8000 -v /home/code/go/src/go-admin/go-admin/config:/go-admin-api/config -v /home/code/go/src/go-admin/go-admin-api/static:/go-admin/static -v /home/code/go/src/go-admin/go-admin/temp:/go-admin-api/temp -d --restart=always go-admin:latest
@echo "go-admin service is running..."
# delete Tag=<none> 的镜像
@docker image prune -f
@docker ps -a | grep "go-admin"
stop:
# delete go-admin-api container
@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker-compose down; fi
#@if [ $(shell docker ps -aq --filter name=go-admin --filter publish=8000) ]; then docker rm -f go-admin; fi
#@echo "go-admin stop success"
#.PHONY: test
#test:
# go test -v ./... -cover
@@ -14,3 +44,11 @@ build-sqlite:
#.PHONY: docker
#docker:
# docker build . -t go-admin:latest
# make deploy
deploy:
#@git checkout master
#@git pull origin master
make build-linux
make run
+2 -1
View File
@@ -284,7 +284,8 @@ npm run dev
<span style="margin: 0 5px;" ><a href="https://github.com/misakichan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16569274?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/zhuxuyang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19301024?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/mss-boot" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/109259065?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/AuroraV " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/AuroraV" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/haimait" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40926384?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
## JetBrains 开源证书支持
+2 -1
View File
@@ -270,7 +270,8 @@ npm run dev
<span style="margin: 0 5px;" ><a href="https://github.com/misakichan" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/16569274?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/zhuxuyang" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/19301024?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/mss-boot" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/109259065?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/AuroraV " ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/AuroraV" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/37330199?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
<span style="margin: 0 5px;" ><a href="https://github.com/haimait" ><img src="https://images.weserv.nl/?url=avatars.githubusercontent.com/u/40926384?s=60&v=4&w=60&fit=cover&mask=circle&maxage=7d" /></a></span>
+19
View File
@@ -0,0 +1,19 @@
version: '3.8'
services:
go-admin-api:
container_name: go-admin
image: go-admin:latest
privileged: true
restart: always
ports:
- 8000:8000
volumes:
- ./config/:/go-admin-api/config/
- ./static/:/go-admin-api/static/
- ./temp/:/go-admin-api/temp/
networks:
- myweb
networks:
myweb:
driver: bridge
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
echo "go build"
go mod tidy
go build -o go-admin main.go
echo "kill go-admin service"
killall go-admin # kill go-admin service
nohup ./go-admin server -c=config/settings.dev.yml >> access.log 2>&1 & #后台启动服务将日志写入access.log文件
echo "run go-admin success"
ps -aux | grep go-admin
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
killall go-admin # kill go-admin service
echo "stop go-admin success"
ps -aux | grep go-admin
+1 -4
View File
@@ -34,9 +34,6 @@ func InitRouter() {
os.Exit(-1)
}
r.Use(common.Sentinel()).
Use(common.RequestId(pkg.TrafficKey))
common.InitMiddleware(r)
// the jwt middleware
authMiddleware, err := common.AuthInit()
if err != nil {
@@ -75,4 +72,4 @@ func checkRoleRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) {
for _, f := range routerCheckRole {
f(v, authMiddleware)
}
}
}
+4 -3
View File
@@ -65,7 +65,7 @@ func (e {{.ClassName}}) GetPage(c *gin.Context) {
// @Summary 获取{{.TableComment}}
// @Description 获取{{.TableComment}}
// @Tags {{.TableComment}}
// @Param id path string false "id"
// @Param id path int false "id"
// @Success 200 {object} response.Response{data=models.{{.ClassName}}} "{"code": 200, "data": [...]}"
// @Router /api/v1/{{.ModuleName}}/{id} [get]
// @Security Bearer
@@ -135,6 +135,7 @@ func (e {{.ClassName}}) Insert(c *gin.Context) {
// @Tags {{.TableComment}}
// @Accept application/json
// @Product application/json
// @Param id path int true "id"
// @Param data body dto.{{.ClassName}}UpdateReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
// @Router /api/v1/{{.ModuleName}}/{id} [put]
@@ -167,7 +168,7 @@ func (e {{.ClassName}}) Update(c *gin.Context) {
// @Summary 删除{{.TableComment}}
// @Description 删除{{.TableComment}}
// @Tags {{.TableComment}}
// @Param ids body []int false "ids"
// @Param data body dto.{{.ClassName}}DeleteReq true "body"
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
// @Router /api/v1/{{.ModuleName}} [delete]
// @Security Bearer
@@ -194,4 +195,4 @@ func (e {{.ClassName}}) Delete(c *gin.Context) {
return
}
e.OK( req.GetId(), "删除成功")
}
}