upgrade github.com/alimy/mir/v4 => v4.2.0-alpha.5 and update Dockerfile to use --mount=type=cahce option for RUN

pull/503/head
Michael Li 8 months ago
parent cb3c1d82fd
commit 7eaf53e7f9
No known key found for this signature in database

@ -22,9 +22,10 @@ ARG USE_DIST=no
WORKDIR /paopao-ce
COPY . .
COPY --from=frontend /web/dist ./web/dist
ENV GOPROXY=https://goproxy.cn
RUN [ $EMBED_UI != yes ] || make build TAGS='go_json'
RUN [ $EMBED_UI = yes ] || make build TAGS='slim embed go_json'
ENV GOPROXY=https://goproxy.cn,direct
RUN --mount=type=cache,target=/root/.cache/go-build,id=paopao-ce go mod download
RUN [ $EMBED_UI != yes ] || make buildx TAGS='go_json'
RUN [ $EMBED_UI = yes ] || make buildx TAGS='slim embed go_json'
FROM bitbus/paopao-ce-backend-runner:latest
ARG API_HOST

@ -23,8 +23,9 @@ WORKDIR /paopao-ce
COPY . .
COPY --from=frontend /web/dist ./web/dist
ENV GOPROXY=https://goproxy.cn
RUN [ $EMBED_UI != yes ] || make build TAGS='go_json migration'
RUN [ $EMBED_UI = yes ] || make build TAGS='slim embed go_json migration'
RUN --mount=type=cache,target=/root/.cache/go-build,id=paopao-ce-allinone go mod download
RUN [ $EMBED_UI != yes ] || make buildx TAGS='go_json migration'
RUN [ $EMBED_UI = yes ] || make buildx TAGS='slim embed go_json migration'
FROM bitbus/paopao-ce-allinone-runner:latest
ARG API_HOST

@ -36,6 +36,10 @@ build:
@echo Build paopao-ce
@go build -pgo=auto -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_ROOT)/$(TARGET)
buildx:
@echo Build paopao-ce
@go build -pgo=auto -trimpath -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(RELEASE_ROOT)/$(TARGET)
build-web:
@cd web && rm -rf dist/* && yarn build && cd -

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1
@ -22,6 +22,7 @@ type _render_ interface {
type _default_ interface {
Bind(*gin.Context, any) mir.Error
BindJson(*gin.Context, any) mir.Error
Render(*gin.Context, any, mir.Error)
}

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1
@ -56,7 +56,7 @@ func RegisterFriendshipServant(e *gin.Engine, s Friendship) {
default:
}
req := new(web.DeleteFriendReq)
if err := s.Bind(c, req); err != nil {
if err := s.BindJson(c, req); err != nil {
s.Render(c, nil, err)
return
}
@ -69,7 +69,7 @@ func RegisterFriendshipServant(e *gin.Engine, s Friendship) {
default:
}
req := new(web.RejectFriendReq)
if err := s.Bind(c, req); err != nil {
if err := s.BindJson(c, req); err != nil {
s.Render(c, nil, err)
return
}
@ -82,7 +82,7 @@ func RegisterFriendshipServant(e *gin.Engine, s Friendship) {
default:
}
req := new(web.AddFriendReq)
if err := s.Bind(c, req); err != nil {
if err := s.BindJson(c, req); err != nil {
s.Render(c, nil, err)
return
}
@ -95,7 +95,7 @@ func RegisterFriendshipServant(e *gin.Engine, s Friendship) {
default:
}
req := new(web.RequestingFriendReq)
if err := s.Bind(c, req); err != nil {
if err := s.BindJson(c, req); err != nil {
s.Render(c, nil, err)
return
}

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -1,6 +1,6 @@
// Code generated by go-mir. DO NOT EDIT.
// versions:
// - mir v4.1.0
// - mir v4.2.0
package v1

@ -0,0 +1,26 @@
#!/bin/sh
# eg.1 : sh build-image.sh
# eg.2, set image: sh build-image.sh bitbus/paopao-ce
VERSION=`git describe --tags --always | cut -f1,2 -d "-"` # eg.: 0.2.5
IMAGE="bitbus/paopao-ce"
if [ -n "$1" ]; then
IMAGE="$1"
fi
if [ -n "$2" ]; then
VERSION="$2"
fi
# build image
docker buildx build \
--build-arg USE_DIST="yes" \
--tag "$IMAGE:all-in-one-${VERSION}" \
--tag "$IMAGE:all-in-one-latest" \
. -f Dockerfile.allinone
# push to image rep
# if [ -n "$1" ]; then
# docker push "$IMAGE:${VERSION}"
# docker push "$IMAGE:latest"
# fi

@ -7,7 +7,7 @@ require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/RoaringBitmap/roaring v1.9.0
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868
github.com/alimy/mir/v4 v4.1.0
github.com/alimy/mir/v4 v4.2.0-alpha.5
github.com/alimy/tryst v0.10.1
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible
github.com/allegro/bigcache/v3 v3.1.0

@ -9,8 +9,8 @@ github.com/RoaringBitmap/roaring v1.9.0 h1:lwKhr90/j0jVXJyh5X+vQN1VVn77rQFfYnh6R
github.com/RoaringBitmap/roaring v1.9.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868 h1:uFrPOl1VBt/Abfl2z+A/DFc+AwmFLxEHR1+Yq6cXvww=
github.com/afocus/captcha v0.0.0-20191010092841-4bd1f21c8868/go.mod h1:srphKZ1i+yGXxl/LpBS7ZIECTjCTPzZzAMtJWoG3sLo=
github.com/alimy/mir/v4 v4.1.0 h1:D6R0dkfsK1iH8MVu0b9yQ0UjdBU09goiui9PVI94G4o=
github.com/alimy/mir/v4 v4.1.0/go.mod h1:d58dBvw2KImcVbAUANrciEV/of0arMNsI9c/5UNCMMc=
github.com/alimy/mir/v4 v4.2.0-alpha.5 h1:ExSJpbFzKX3Avk1CoTOU3OLyvo4PTB2SnTSQXfeJNIc=
github.com/alimy/mir/v4 v4.2.0-alpha.5/go.mod h1:d58dBvw2KImcVbAUANrciEV/of0arMNsI9c/5UNCMMc=
github.com/alimy/tryst v0.10.1 h1:ks0CwITNu8VuCBeIxov7acuXWfPn1ySR/FpKbdDOy7A=
github.com/alimy/tryst v0.10.1/go.mod h1:6FcqEImav7S62em+p+MODh+stt/UPp23HobUOK3XwFY=
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g=

@ -5,6 +5,7 @@
package conf
import (
"log"
"sync"
"time"
@ -27,7 +28,7 @@ func MustGormDB() *gorm.DB {
_onceGorm.Do(func() {
var err error
if _gormdb, err = newGormDB(); err != nil {
logrus.Fatalf("new gorm db failed: %s", err)
log.Fatalf("new gorm db failed: %s", err)
}
})
return _gormdb

@ -29,7 +29,8 @@ import (
)
type BaseServant struct {
bindAny func(c *gin.Context, obj any) mir.Error
bindAny func(c *gin.Context, obj any) mir.Error
bindJson func(c *gin.Context, obj any) mir.Error
}
type DaoServant struct {
@ -158,6 +159,10 @@ func (s *BaseServant) Bind(c *gin.Context, obj any) mir.Error {
return s.bindAny(c, obj)
}
func (s *BaseServant) BindJson(c *gin.Context, obj any) mir.Error {
return s.bindJson(c, obj)
}
func (s *BaseServant) Render(c *gin.Context, data any, err mir.Error) {
if err == nil {
c.JSON(http.StatusOK, &joint.JsonResp{
@ -420,9 +425,17 @@ func NewBindAnyFn() func(c *gin.Context, obj any) mir.Error {
return bindAny
}
func NewBindJsonFn() func(c *gin.Context, obj any) mir.Error {
if conf.UseSentryGin() {
return bindAnySentry
}
return bindAny
}
func NewBaseServant() *BaseServant {
return &BaseServant{
bindAny: NewBindAnyFn(),
bindAny: NewBindAnyFn(),
bindJson: NewBindJsonFn(),
}
}

@ -16,16 +16,16 @@ type Friendship struct {
Group `mir:"v1"`
// RequestingFriend 请求添加朋友
RequestingFriend func(Post, web.RequestingFriendReq) `mir:"/friend/requesting"`
RequestingFriend func(Post, web.RequestingFriendReq) `mir:"/friend/requesting" binding:"json"`
// AddFriend 同意添加好友
AddFriend func(Post, web.AddFriendReq) `mir:"/friend/add"`
AddFriend func(Post, web.AddFriendReq) `mir:"/friend/add" binding:"json"`
// RejectFriend 拒绝添加好友
RejectFriend func(Post, web.RejectFriendReq) `mir:"/friend/reject"`
RejectFriend func(Post, web.RejectFriendReq) `mir:"/friend/reject" binding:"json"`
// DeleteFriend 删除好友
DeleteFriend func(Post, web.DeleteFriendReq) `mir:"/friend/delete"`
DeleteFriend func(Post, web.DeleteFriendReq) `mir:"/friend/delete" binding:"json"`
// GetContacts 获取好友列表
GetContacts func(Get, web.GetContactsReq) web.GetContactsResp `mir:"/user/contacts"`

Loading…
Cancel
Save