Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d84b5fe777 | |||
5aa6dfbec6 | |||
9da10d9024 | |||
a8a95ad253 |
@ -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"]
|
@ -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"]
|
12
cmd/app.go
12
cmd/app.go
@ -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)
|
||||||
|
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
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user