Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b1a3b7cd17 |
@@ -1,5 +1,6 @@
|
|||||||
# Build stage
|
# Build stage
|
||||||
FROM golang:1.20-alpine AS builder
|
FROM crpi-8s2ierii2xan4klg.cn-beijing.personal.cr.aliyuncs.com/texpixel/golang:1.20-apline AS builder
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ RUN go mod download && \
|
|||||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o doc_ai ./main.go
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o doc_ai ./main.go
|
||||||
|
|
||||||
# Runtime stage
|
# Runtime stage
|
||||||
FROM alpine:latest
|
FROM crpi-8s2ierii2xan4klg.cn-beijing.personal.cr.aliyuncs.com/texpixel/alpine:latest
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
RUN apk add --no-cache tzdata && \
|
RUN apk add --no-cache tzdata && \
|
||||||
|
|||||||
@@ -4,16 +4,16 @@ server:
|
|||||||
|
|
||||||
database:
|
database:
|
||||||
driver: mysql
|
driver: mysql
|
||||||
host: mysql
|
host: 182.92.150.161
|
||||||
port: 3306 # 容器内部端口,不是宿主机映射的 3006
|
port: 3006
|
||||||
username: root
|
username: root
|
||||||
password: texpixel#pwd123!
|
password: yoge@coder%%%123321!
|
||||||
dbname: doc_ai
|
dbname: doc_ai
|
||||||
max_idle: 10
|
max_idle: 10
|
||||||
max_open: 100
|
max_open: 100
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
addr: redis:6379 # 容器内部端口,不是宿主机映射的 6079
|
addr: 182.92.150.161:6379
|
||||||
password: yoge@123321!
|
password: yoge@123321!
|
||||||
db: 0
|
db: 0
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ redis:
|
|||||||
db: 0
|
db: 0
|
||||||
|
|
||||||
limit:
|
limit:
|
||||||
formula_recognition: 10
|
formula_recognition: 2
|
||||||
|
|
||||||
log:
|
log:
|
||||||
appName: document_ai
|
appName: document_ai
|
||||||
|
|||||||
@@ -1,50 +1,27 @@
|
|||||||
services:
|
version: '3.8'
|
||||||
doc_ai:
|
|
||||||
build: .
|
|
||||||
container_name: doc_ai
|
|
||||||
ports:
|
|
||||||
- "8024:8024"
|
|
||||||
volumes:
|
|
||||||
- ./config:/app/config
|
|
||||||
- ./logs:/app/logs
|
|
||||||
networks:
|
|
||||||
- backend
|
|
||||||
depends_on:
|
|
||||||
mysql:
|
|
||||||
condition: service_healthy
|
|
||||||
redis:
|
|
||||||
condition: service_started
|
|
||||||
command: ["-env", "dev"]
|
|
||||||
restart: always
|
|
||||||
|
|
||||||
|
services:
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql:8.0
|
image: mysql:8.0
|
||||||
container_name: mysql
|
container_name: mysql
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: texpixel#pwd123!
|
MYSQL_ROOT_PASSWORD: 123456 # 设置root用户密码
|
||||||
MYSQL_DATABASE: doc_ai
|
MYSQL_DATABASE: document_ai # 设置默认数据库名
|
||||||
MYSQL_USER: texpixel
|
MYSQL_USER: bitwsd_document # 设置数据库用户名
|
||||||
MYSQL_PASSWORD: texpixel#pwd123!
|
MYSQL_PASSWORD: 123456 # 设置数据库用户密码
|
||||||
ports:
|
ports:
|
||||||
- "3006:3306"
|
- "3306:3306" # 映射宿主机的3306端口到容器内的3306
|
||||||
volumes:
|
volumes:
|
||||||
- mysql_data:/var/lib/mysql
|
- mysql_data:/var/lib/mysql # 持久化MySQL数据
|
||||||
networks:
|
networks:
|
||||||
- backend
|
- backend
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-ptexpixel#pwd123!"]
|
|
||||||
interval: 5s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 10
|
|
||||||
start_period: 30s
|
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:latest
|
image: redis:latest
|
||||||
container_name: redis
|
container_name: redis
|
||||||
command: redis-server --requirepass "yoge@123321!"
|
|
||||||
ports:
|
ports:
|
||||||
- "6079:6379"
|
- "6379:6379" # 映射宿主机的6379端口到容器内的6379
|
||||||
networks:
|
networks:
|
||||||
- backend
|
- backend
|
||||||
restart: always
|
restart: always
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -14,7 +14,6 @@ require (
|
|||||||
github.com/redis/go-redis/v9 v9.7.0
|
github.com/redis/go-redis/v9 v9.7.0
|
||||||
github.com/rs/zerolog v1.33.0
|
github.com/rs/zerolog v1.33.0
|
||||||
github.com/spf13/viper v1.19.0
|
github.com/spf13/viper v1.19.0
|
||||||
golang.org/x/crypto v0.23.0
|
|
||||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||||
gorm.io/driver/mysql v1.5.7
|
gorm.io/driver/mysql v1.5.7
|
||||||
gorm.io/gorm v1.25.12
|
gorm.io/gorm v1.25.12
|
||||||
@@ -69,6 +68,7 @@ require (
|
|||||||
go.uber.org/atomic v1.9.0 // indirect
|
go.uber.org/atomic v1.9.0 // indirect
|
||||||
go.uber.org/multierr v1.9.0 // indirect
|
go.uber.org/multierr v1.9.0 // indirect
|
||||||
golang.org/x/arch v0.8.0 // indirect
|
golang.org/x/arch v0.8.0 // indirect
|
||||||
|
golang.org/x/crypto v0.23.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/net v0.25.0 // indirect
|
||||||
golang.org/x/sys v0.20.0 // indirect
|
golang.org/x/sys v0.20.0 // indirect
|
||||||
|
|||||||
16
main.go
16
main.go
@@ -10,14 +10,14 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"gitea.com/bitwsd/document_ai/pkg/cors"
|
||||||
|
"gitea.com/bitwsd/document_ai/pkg/log"
|
||||||
|
"gitea.com/bitwsd/document_ai/pkg/middleware"
|
||||||
"gitea.com/bitwsd/document_ai/api"
|
"gitea.com/bitwsd/document_ai/api"
|
||||||
"gitea.com/bitwsd/document_ai/config"
|
"gitea.com/bitwsd/document_ai/config"
|
||||||
"gitea.com/bitwsd/document_ai/internal/storage/cache"
|
"gitea.com/bitwsd/document_ai/internal/storage/cache"
|
||||||
"gitea.com/bitwsd/document_ai/internal/storage/dao"
|
"gitea.com/bitwsd/document_ai/internal/storage/dao"
|
||||||
"gitea.com/bitwsd/document_ai/pkg/common"
|
"gitea.com/bitwsd/document_ai/pkg/common"
|
||||||
"gitea.com/bitwsd/document_ai/pkg/cors"
|
|
||||||
"gitea.com/bitwsd/document_ai/pkg/log"
|
|
||||||
"gitea.com/bitwsd/document_ai/pkg/middleware"
|
|
||||||
"gitea.com/bitwsd/document_ai/pkg/sms"
|
"gitea.com/bitwsd/document_ai/pkg/sms"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
@@ -42,6 +42,14 @@ func main() {
|
|||||||
cache.InitRedisClient(config.GlobalConfig.Redis)
|
cache.InitRedisClient(config.GlobalConfig.Redis)
|
||||||
sms.InitSmsClient()
|
sms.InitSmsClient()
|
||||||
|
|
||||||
|
// 初始化Redis
|
||||||
|
// cache.InitRedis(config.GlobalConfig.Redis.Addr)
|
||||||
|
|
||||||
|
// 初始化OSS客户端
|
||||||
|
// if err := oss.InitOSS(config.GlobalConfig.OSS); err != nil {
|
||||||
|
// logger.Fatal("Failed to init OSS client", logger.Fields{"error": err})
|
||||||
|
// }
|
||||||
|
|
||||||
// 设置gin模式
|
// 设置gin模式
|
||||||
gin.SetMode(config.GlobalConfig.Server.Mode)
|
gin.SetMode(config.GlobalConfig.Server.Mode)
|
||||||
|
|
||||||
@@ -70,6 +78,6 @@ func main() {
|
|||||||
if err := srv.Shutdown(context.Background()); err != nil {
|
if err := srv.Shutdown(context.Background()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second * 5)
|
time.Sleep(time.Second * 3)
|
||||||
dao.CloseDB()
|
dao.CloseDB()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user