Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d84b5fe777 | |||
5aa6dfbec6 | |||
9da10d9024 | |||
a8a95ad253 |
@ -1,4 +1,7 @@
|
||||
FROM testhub.szjixun.cn:9043/public/self-alpine
|
||||
ENV TZ Asia/Shanghai
|
||||
COPY build/app /root
|
||||
ENTRYPOINT [ "chmod 777 /root/app && /root/app" ]
|
||||
ENV MODE_ENV prod
|
||||
WORKDIR /root
|
||||
COPY build/app ./
|
||||
COPY conf/ ./conf
|
||||
CMD ["sh", "-c", "./app"]
|
@ -1,4 +1,7 @@
|
||||
FROM testhub.szjixun.cn:9043/public/self-alpine
|
||||
ENV TZ Asia/Shanghai
|
||||
COPY build/app /root
|
||||
ENTRYPOINT [ "chmod 777 /root/app && /root/app" ]
|
||||
ENV MODE_ENV dev
|
||||
WORKDIR /root
|
||||
COPY build/app ./
|
||||
COPY conf/ ./conf
|
||||
CMD ["sh", "-c", "./app"]
|
12
cmd/app.go
12
cmd/app.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@ -12,8 +13,17 @@ import (
|
||||
"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() {
|
||||
os.Setenv(constant.ConfigFileEnvKey, "../conf/dubbogo.yaml")
|
||||
config.SetProviderService(&service.FilesProvider{})
|
||||
if err := config.Load(); err != nil {
|
||||
panic(err)
|
||||
|
14
conf/dev/dubbogo.yaml
Normal file
14
conf/dev/dubbogo.yaml
Normal 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
14
conf/prod/dubbogo.yaml
Normal 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
|
@ -31,7 +31,7 @@ type FilesProvider struct {
|
||||
filesApi.UnimplementedFileServer
|
||||
}
|
||||
|
||||
const BASE_PATH = "../"
|
||||
var BasePath = "../"
|
||||
|
||||
var imgSvc = img.New(4) // 图片预览可用协程数
|
||||
|
||||
@ -459,7 +459,7 @@ func newFileDownloadWriter(stream filesApi.File_DirDownloadServer) *fileDownload
|
||||
}
|
||||
|
||||
func getFs(userSpacePath string) afero.Fs {
|
||||
bashAbs, _ := filepath.Abs(BASE_PATH)
|
||||
bashAbs, _ := filepath.Abs(BasePath)
|
||||
|
||||
if !strings.HasPrefix(userSpacePath, "/") {
|
||||
userSpacePath = "/" + userSpacePath
|
||||
|
Loading…
Reference in New Issue
Block a user