Compare commits

..

4 Commits
main ... dev

Author SHA1 Message Date
lzh
d84b5fe777 修改根路径位置 2025-06-06 11:41:36 +08:00
lzh
5aa6dfbec6 修改dockerfile 2025-06-06 11:15:03 +08:00
lzh
9da10d9024 修改dockerfile 2025-06-06 10:52:52 +08:00
lzh
a8a95ad253 添加多环境配置 2025-06-06 10:49:52 +08:00
7 changed files with 51 additions and 7 deletions

View File

@ -1,4 +1,7 @@
FROM testhub.szjixun.cn:9043/public/self-alpine FROM testhub.szjixun.cn:9043/public/self-alpine
ENV TZ Asia/Shanghai ENV TZ Asia/Shanghai
COPY build/app /root ENV MODE_ENV prod
ENTRYPOINT [ "chmod 777 /root/app && /root/app" ] WORKDIR /root
COPY build/app ./
COPY conf/ ./conf
CMD ["sh", "-c", "./app"]

View File

@ -1,4 +1,7 @@
FROM testhub.szjixun.cn:9043/public/self-alpine FROM testhub.szjixun.cn:9043/public/self-alpine
ENV TZ Asia/Shanghai ENV TZ Asia/Shanghai
COPY build/app /root ENV MODE_ENV dev
ENTRYPOINT [ "chmod 777 /root/app && /root/app" ] WORKDIR /root
COPY build/app ./
COPY conf/ ./conf
CMD ["sh", "-c", "./app"]

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"os" "os"
"os/signal" "os/signal"
@ -12,8 +13,17 @@ import (
"github.com/filebrowser/filebrowser/v2/service" "github.com/filebrowser/filebrowser/v2/service"
) )
func init() {
if os.Getenv("MODE_ENV") != "" {
os.Setenv(constant.ConfigFileEnvKey, fmt.Sprintf("./conf/%s/%s", os.Getenv("MODE_ENV"), "dubbogo.yaml"))
service.BasePath = "./data"
} else {
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
service.BasePath = "../"
}
}
func main() { func main() {
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
config.SetProviderService(&service.FilesProvider{}) config.SetProviderService(&service.FilesProvider{})
if err := config.Load(); err != nil { if err := config.Load(); err != nil {
panic(err) panic(err)

View File

14
conf/dev/dubbogo.yaml Normal file
View File

@ -0,0 +1,14 @@
dubbo:
registries:
demoZK:
protocol: zookeeper
address: 172.16.100.93:2181
protocols:
triple:
name: tri
port: 20027
provider:
services:
FileProvider:
protocol: tri
interface: files.File # must be compatible with grpc or dubbo-java

14
conf/prod/dubbogo.yaml Normal file
View File

@ -0,0 +1,14 @@
dubbo:
registries:
demoZK:
protocol: zookeeper
address: zookeeper:2181
protocols:
triple:
name: tri
port: 20027
provider:
services:
FileProvider:
protocol: tri
interface: files.File # must be compatible with grpc or dubbo-java

View File

@ -31,7 +31,7 @@ type FilesProvider struct {
filesApi.UnimplementedFileServer filesApi.UnimplementedFileServer
} }
const BASE_PATH = "../" var BasePath = "../"
var imgSvc = img.New(4) // 图片预览可用协程数 var imgSvc = img.New(4) // 图片预览可用协程数
@ -459,7 +459,7 @@ func newFileDownloadWriter(stream filesApi.File_DirDownloadServer) *fileDownload
} }
func getFs(userSpacePath string) afero.Fs { func getFs(userSpacePath string) afero.Fs {
bashAbs, _ := filepath.Abs(BASE_PATH) bashAbs, _ := filepath.Abs(BasePath)
if !strings.HasPrefix(userSpacePath, "/") { if !strings.HasPrefix(userSpacePath, "/") {
userSpacePath = "/" + userSpacePath userSpacePath = "/" + userSpacePath