fix db path
This commit is contained in:
30
deploy/docker/Dockerfile.cn
Normal file
30
deploy/docker/Dockerfile.cn
Normal file
@@ -0,0 +1,30 @@
|
||||
FROM node:20-alpine AS frontend
|
||||
WORKDIR /frontend-build
|
||||
COPY ./frontend .
|
||||
|
||||
RUN npm config set registry https://registry.npmmirror.com && npm install -g pnpm --registry=https://registry.npmmirror.com && pnpm i && pnpm build
|
||||
|
||||
FROM golang:1.23-alpine AS backend
|
||||
LABEL anther="github.com/Sakurasan"
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk --no-cache add make cmake upx
|
||||
WORKDIR /build
|
||||
COPY . .
|
||||
COPY --from=frontend /frontend-build/dist /build/cmd/openteam/dist
|
||||
ENV GO111MODULE=on
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
CMD [ "go mod tidy","go mod download" ]
|
||||
RUN make build
|
||||
|
||||
FROM alpine:latest AS runner
|
||||
# 设置alpine 时间为上海时间
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
RUN apk update && apk --no-cache add tzdata ffmpeg && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
|
||||
&& echo "Asia/Shanghai" > /etc/timezone
|
||||
# RUN apk update && apk --no-cache add openssl libgcc libstdc++ binutils
|
||||
WORKDIR /app
|
||||
COPY --from=backend /build/bin/openteam /app/openteam
|
||||
ENV GIN_MODE=release
|
||||
ENV PATH=$PATH:/app
|
||||
EXPOSE 80 443
|
||||
ENTRYPOINT ["/app/openteam"]
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"log"
|
||||
"opencatd-open/internal/model"
|
||||
"opencatd-open/pkg/config"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
// "gocloud.dev/mysql"
|
||||
@@ -77,7 +78,13 @@ func InitDB(cfg *config.Config) (*gorm.DB, error) {
|
||||
|
||||
// initSQLite 初始化 SQLite 数据库
|
||||
func initSQLite() (*gorm.DB, error) {
|
||||
db, err := gorm.Open(sqlite.Open("openteam.db"), &gorm.Config{})
|
||||
if _, err := os.Stat("db"); os.IsNotExist(err) {
|
||||
errDir := os.MkdirAll("db", 0755)
|
||||
if errDir != nil {
|
||||
log.Fatalln("Error creating directory:", err)
|
||||
}
|
||||
}
|
||||
db, err := gorm.Open(sqlite.Open("./db/openteam.db"), &gorm.Config{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to SQLite: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user