Skip to content

Commit 55e8565

Browse files
committed
support docker add tus
1 parent dca0b83 commit 55e8565

File tree

3 files changed

+38
-8
lines changed

3 files changed

+38
-8
lines changed

Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM registry.cn-hangzhou.aliyuncs.com/prince/alpine-golang:1.11.5 as builder
22
MAINTAINER prince <[email protected]>
3-
ARG VERSION=1.0.9
3+
ARG VERSION=1.1.4
44
RUN set -xe; \
55
apk update; \
66
apk add --no-cache --virtual .build-deps \
@@ -17,10 +17,6 @@ COPY --from=builder /go/src/go-fastdfs/fileserver /
1717
ENV INSTALL_DIR /usr/local/go-fastdfs
1818

1919
RUN mkdir -p $INSTALL_DIR; \
20-
mkdir -p $INSTALL_DIR/conf; \
21-
mkdir -p $INSTALL_DIR/data; \
22-
mkdir -p $INSTALL_DIR/files; \
23-
mkdir -p $INSTALL_DIR/log; \
2420
mv /fileserver $INSTALL_DIR/; \
2521
chmod +x $INSTALL_DIR/fileserver;
2622

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,13 @@ culr -C - http://10.1.5.9:8080/group1/default/20190128/16/10/2G
315315

316316
- Docker如何部署?
317317
```
318-
使用环境变量 GO_FASTDFS_DIR 指向存储目录。
318+
319+
320+
步骤:
321+
一、构建镜像
322+
docker build . -t fastdfs
323+
二、运行容器(使用环境变量 GO_FASTDFS_DIR 指向存储目录。)
324+
docker run --name fastdfs -v ~:/data/fastdfs -e GO_FASTDFS_DIR=/data/fastdfs fastdfs
319325
320326
```
321327

fileserver.go

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import (
55
"crypto/rand"
66
"crypto/sha1"
77
"encoding/base64"
8-
"runtime"
98
random "math/rand"
10-
9+
"runtime"
1110
"errors"
1211
"flag"
1312
"fmt"
@@ -40,6 +39,8 @@ import (
4039
"github.com/json-iterator/go"
4140
log "github.com/sjqzhang/seelog"
4241
"github.com/syndtr/goleveldb/leveldb"
42+
"github.com/tus/tusd"
43+
"github.com/tus/tusd/filestore"
4344
)
4445

4546
var staticHandler http.Handler
@@ -3486,6 +3487,30 @@ func (this *Server) test() {
34863487

34873488
}
34883489

3490+
func (this *Server) initTus() {
3491+
store := filestore.FileStore{
3492+
Path: STORE_DIR,
3493+
}
3494+
bigDir := "/big/"
3495+
composer := tusd.NewStoreComposer()
3496+
store.UseIn(composer)
3497+
handler, err := tusd.NewHandler(tusd.Config{
3498+
BasePath: bigDir,
3499+
StoreComposer: composer,
3500+
})
3501+
if err != nil {
3502+
log.Error(err)
3503+
3504+
}
3505+
3506+
if Config().SupportGroupManage {
3507+
http.Handle("/"+Config().Group+bigDir, http.StripPrefix("/"+Config().Group+bigDir, handler))
3508+
} else {
3509+
http.Handle(bigDir, http.StripPrefix(bigDir, handler))
3510+
3511+
}
3512+
}
3513+
34893514
func (this *Server) FormatStatInfo() {
34903515
var (
34913516
data []byte
@@ -3559,9 +3584,12 @@ func (this *Server) initComponent(isReload bool) {
35593584

35603585
if !isReload {
35613586
this.FormatStatInfo()
3587+
this.initTus()
35623588
}
35633589
//Timer
35643590

3591+
// int tus
3592+
35653593
}
35663594

35673595
type HttpHandler struct {

0 commit comments

Comments
 (0)