优化数据库迁移
This commit is contained in:
parent
fceba10a35
commit
bd38fd6681
11
DockerBuildTest.bat
Normal file
11
DockerBuildTest.bat
Normal file
@ -0,0 +1,11 @@
|
||||
go env -w GOOS=linux
|
||||
cd ./build
|
||||
del artistinfo-dev
|
||||
cd ..
|
||||
go build -ldflags "-s -w" -o ./build/artistinfo-dev ./cmd/app.go
|
||||
docker rmi artistinfo-dev
|
||||
docker rmi 121.229.45.214:9006/artistinfo-dev
|
||||
docker build . -f .\DockerfileWindowsTest -t artistinfo-dev
|
||||
docker tag artistinfo-dev 121.229.45.214:9006/artistinfo-dev
|
||||
docker push 121.229.45.214:9006/artistinfo-dev
|
||||
pause
|
@ -3,31 +3,33 @@ FROM golang:alpine AS builder
|
||||
LABEL stage=gobuilder
|
||||
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
|
||||
#ENV MODE_ENV test
|
||||
ENV TZ Asia/Shanghai
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
#RUN apk update --no-cache && apk add --no-cache tzdata
|
||||
|
||||
WORKDIR /build
|
||||
COPY ./utils ../utils
|
||||
ADD ./fonchain-backup/go.mod .
|
||||
ADD ./fonchain-backup/go.sum .
|
||||
RUN go mod download
|
||||
COPY ./fonchain-backup .
|
||||
#COPY ./utils ../utils
|
||||
#ADD ./fonchain-artist/go.mod .
|
||||
#ADD ./fonchain-artist/go.sum .
|
||||
#RUN go mod download
|
||||
#COPY ./fonchain-artist .
|
||||
#
|
||||
#RUN go build -ldflags "-s -w" -o /app/artistServer ./cmd/app.go
|
||||
|
||||
RUN go build -ldflags "-s -w" -o /app/backup ./cmd/app.go
|
||||
COPY ./build/artistinfo-dev /app/artistinfo-dev
|
||||
|
||||
FROM alpine
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk update --no-cache
|
||||
RUN apk add --no-cache ca-certificates
|
||||
RUN apk add --no-cache tzdata
|
||||
COPY ./fonchain-backup/conf /app/conf
|
||||
COPY ./fonchain-backup/conf /conf
|
||||
|
||||
COPY ./conf /app/conf
|
||||
COPY ./conf /conf
|
||||
ENV TZ Asia/Shanghai
|
||||
ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
|
||||
ENV MODE_ENV test
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/backup .
|
||||
EXPOSE 9021
|
||||
CMD ["/app/backup"]
|
||||
COPY --from=builder /app/artistinfo-dev .
|
||||
EXPOSE 20050
|
||||
CMD ["/app/artistinfo-dev"]
|
||||
|
BIN
build/artistinfo-dev
Normal file
BIN
build/artistinfo-dev
Normal file
Binary file not shown.
@ -187,7 +187,11 @@ func GetUser(req *artistInfoUser.GetUserRequest) (rep *artistInfoUser.GetUserRes
|
||||
var user model.User
|
||||
if err = db.DB.Where("tel_num = ?", req.TelNum).First(&user).Error; err != nil {
|
||||
zap.L().Error("get user info err", zap.Error(err))
|
||||
err = errors.New(m.ERROR_SELECT)
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
err = errors.New("没有找到数据")
|
||||
} else {
|
||||
err = errors.New(m.ERROR_SELECT)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
// rep.
|
||||
|
@ -3,18 +3,17 @@ mode = dev #正式prod #测试dev
|
||||
|
||||
[mysql]
|
||||
Db = mysql
|
||||
DbHost = 127.0.0.1
|
||||
DbPort = 3306
|
||||
DbUser = root
|
||||
DbPassWord = 123456
|
||||
DbName = artistmgmtDev
|
||||
DbHost = 172.16.100.99 #214
|
||||
DbPort = 9007
|
||||
DbUser = artuser
|
||||
DbPassWord = "C250PflXIWv2SQm8"
|
||||
DbArtist = artistmgmtDev
|
||||
|
||||
[redis]
|
||||
|
||||
RedisDB = 2
|
||||
RedisAddr = 127.0.0.1:6379
|
||||
#RedisPW = "nDCTrfTtBu3Pw"
|
||||
#RedisDBNAme =
|
||||
RedisDB = 3
|
||||
RedisAddr = 172.16.100.99:9008
|
||||
RedisPW = "nDCTrfTtBu3Pw"
|
||||
RedisDBNAme =
|
||||
|
||||
[chain]
|
||||
IP=127.0.0.1:37101
|
||||
|
@ -8,10 +8,10 @@ dubbo:
|
||||
demoZK:
|
||||
protocol: zookeeper
|
||||
timeout: 120s
|
||||
address: 127.0.0.1:2181
|
||||
# address: 127.0.0.1:2181
|
||||
# address: 121.229.45.214:9004
|
||||
# address: 114.218.158.24:2181
|
||||
# address: zookeeper:2181
|
||||
address: 172.16.100.93:2181
|
||||
protocols:
|
||||
triple: #triple
|
||||
name: tri
|
||||
@ -28,14 +28,14 @@ dubbo:
|
||||
ArtistInfoArtshowProvider:
|
||||
interface: com.fontree.microservices.common.ArtistInfoArtshow
|
||||
retries: 100
|
||||
#ContractProvider:
|
||||
# interface: com.fontree.microservices.common.Contract
|
||||
#ContractProvider:
|
||||
# interface: com.fontree.microservices.common.Contract
|
||||
# retries: 0
|
||||
#ArtWorkProvider:
|
||||
# interface: com.fontree.microservices.common.ArtWork
|
||||
#ArtWorkProvider:
|
||||
# interface: com.fontree.microservices.common.ArtWork
|
||||
# retries: 0
|
||||
#SupplyProvider:
|
||||
# interface: com.fontree.microservices.common.Supply
|
||||
#SupplyProvider:
|
||||
# interface: com.fontree.microservices.common.Supply
|
||||
# retries: 0
|
||||
consumer:
|
||||
request-timeout: 120s
|
||||
|
@ -3,15 +3,14 @@ mode = dev #正式prod #测试dev
|
||||
|
||||
[mysql]
|
||||
Db = mysql
|
||||
DbHost = mysql
|
||||
DbPort = 3306
|
||||
DbUser = root
|
||||
DbPassWord = 123456
|
||||
DbName = artistmgmttest
|
||||
DbHost = 172.16.100.99 #214
|
||||
DbPort = 9007
|
||||
DbUser = artuser
|
||||
DbPassWord = "C250PflXIWv2SQm8"
|
||||
DbArtist = artistmgmtDev
|
||||
|
||||
[redis]
|
||||
|
||||
RedisDB = 2
|
||||
RedisDB = 3
|
||||
RedisAddr = 172.16.100.99:9008
|
||||
RedisPW = "nDCTrfTtBu3Pw"
|
||||
RedisDBNAme =
|
||||
|
@ -8,10 +8,10 @@ dubbo:
|
||||
demoZK:
|
||||
protocol: zookeeper
|
||||
timeout: 120s
|
||||
# address: 127.0.0.1:2181
|
||||
# address: 127.0.0.1:2181
|
||||
# address: 121.229.45.214:9004
|
||||
# address: 114.218.158.24:2181
|
||||
address: zookeeper:2181
|
||||
address: 172.16.100.93:2181
|
||||
protocols:
|
||||
triple: #triple
|
||||
name: tri
|
||||
|
@ -10,7 +10,6 @@ DbPassWord = 123456
|
||||
DbName = artistmgmttest
|
||||
|
||||
[redis]
|
||||
|
||||
RedisDB = 2
|
||||
RedisAddr = 127.0.0.1:6379
|
||||
#RedisPW = "nDCTrfTtBu3Pw"
|
||||
|
@ -19,18 +19,57 @@ dubbo:
|
||||
port: 20050
|
||||
provider:
|
||||
services:
|
||||
ArtistInfoProvider:
|
||||
ArtistInfoUserProvider:
|
||||
interface: com.fontree.microservices.common.ArtistInfoUser
|
||||
retries: 100
|
||||
ArtistInfoArtworkProvider:
|
||||
interface: com.fontree.microservices.common.ArtistInfoArtwork
|
||||
retries: 100
|
||||
ArtistInfoArtshowProvider:
|
||||
interface: com.fontree.microservices.common.ArtistInfoArtshow
|
||||
retries: 100
|
||||
#ContractProvider:
|
||||
# interface: com.fontree.microservices.common.Contract
|
||||
# retries: 0
|
||||
#ArtWorkProvider:
|
||||
# interface: com.fontree.microservices.common.ArtWork
|
||||
# retries: 0
|
||||
#SupplyProvider:
|
||||
# interface: com.fontree.microservices.common.Supply
|
||||
# retries: 0
|
||||
consumer:
|
||||
request-timeout: 120s
|
||||
references:
|
||||
AccountClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.Account
|
||||
filter: cshutdown,sign,fonDomainFilter,fonValidateFilter
|
||||
params:
|
||||
.accessKeyId: "Accountksl"
|
||||
.secretAccessKey: "BSDY-FDF1-Fontree_account"
|
||||
ArtistClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.Artist
|
||||
ArtistInfoClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.ArtistInfo
|
||||
# retries: 100
|
||||
ContractProvider:
|
||||
interface: com.fontree.microservices.common.Contract
|
||||
# retries: 0
|
||||
ArtWorkProvider:
|
||||
interface: com.fontree.microservices.common.ArtWork
|
||||
# retries: 0
|
||||
SupplyProvider:
|
||||
ContractClientImpl:
|
||||
timeout: 15s
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.contract
|
||||
filter: cshutdown,sign
|
||||
params:
|
||||
.accessKeyId: "SYD8-Chain-04"
|
||||
.secretAccessKey: "Al-Chain-FDF112"
|
||||
ArtworkClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.Artwork
|
||||
ArtworkQueryClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.ArtworkQuery
|
||||
SupplyClientImpl:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.common.Supply
|
||||
# retries: 0
|
||||
logger:
|
||||
zap-config:
|
||||
level: info # 日志级别
|
||||
|
Binary file not shown.
Binary file not shown.
37
makefile
Normal file
37
makefile
Normal file
@ -0,0 +1,37 @@
|
||||
.PHONY: all build run gotool help
|
||||
|
||||
BINARY="artisrService"
|
||||
|
||||
all: gotool build
|
||||
|
||||
build:
|
||||
go env -w GOOS=linux
|
||||
go build -ldflags "-s -w" -o ./build/${BINARY} ./cmd/app.go
|
||||
|
||||
pushTest:
|
||||
DockerBuildTest.bat
|
||||
pushProd:
|
||||
DockerBuildProd.bat
|
||||
|
||||
run:
|
||||
@go run ./cmd/app.go
|
||||
|
||||
gotool:
|
||||
go fmt ./
|
||||
go vet ./
|
||||
|
||||
#protoc:
|
||||
#protoc --go_out=./pb/artist --go-triple_out=./pb/artist --validate_out="lang=go:./pb/artist" ./pb/artist/artist.proto
|
||||
#protoc --go_out=./pb/artist --go-grpc_out=./pb/artist --go-triple_out=./pb/artist --validate_out="lang=go:./pb/artist" ./pb/artist/artist.proto
|
||||
protoc:
|
||||
protoc --proto_path=. --go_out=./pb --go-triple_out=./pb --govalidators_out="lang=go:./pb" ./pb/artist.proto
|
||||
protoc --proto_path=. --go_out=./pb --go-triple_out=./pb --govalidators_out="lang=go:./pb" ./pb/artist_third_party.proto
|
||||
all_protoc:
|
||||
protoc --go_out=./pb/artist --go-grpc_out=./pb/artist --go-triple_out=./pb/artist --govalidators_out=./pb/artist ./pb/artist/artist.proto
|
||||
|
||||
help:
|
||||
@echo "make - 格式化 Go 代码, 并编译生成二进制文件"
|
||||
@echo "make build - 编译 Go 代码, 生成二进制文件"
|
||||
@echo "make run - 直接运行 Go 代码"
|
||||
@echo "make gotool - 运行 Go 工具 'fmt' and 'vet'"
|
||||
@echo "make protoc - 解析proto文件"
|
@ -95,7 +95,7 @@ func Database(conn string) {
|
||||
func migration() {
|
||||
//自迁移模式
|
||||
err := DB.AutoMigrate(
|
||||
&old.Bank{},
|
||||
//&old.Bank{},
|
||||
&model.RealName{},
|
||||
&model.User{},
|
||||
&model.Invite{},
|
||||
|
Loading…
Reference in New Issue
Block a user