From ce7489b0c08c74a6823297a1ef542cc680aec8d7 Mon Sep 17 00:00:00 2001 From: Levi Date: Wed, 13 Dec 2023 08:51:22 +0800 Subject: [PATCH] feat: support volume storage dir on docker (#291) --- Dockerfile | 1 + README.md | 5 +++-- README_ja-JP.md | 3 ++- README_zh-CN.md | 5 +++-- README_zh-TW.md | 3 ++- cmd/web/main.go | 9 +++++++++ docker-compose.yml | 5 +++-- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5a8d559..08ea697b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,5 +17,6 @@ FROM alpine:3.14.2 LABEL maintainer="monkeyWie" WORKDIR /app COPY --from=go /app/dist/gopeed ./ +VOLUME ["/app/storage"] EXPOSE 9999 ENTRYPOINT ["./gopeed"] diff --git a/README.md b/README.md index 458121ac..fbb6baa0 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Gopeed (full name Go Speed), a high-speed downloader developed by `Golang` + `Flutter`, supports (HTTP, BitTorrent, Magnet) protocol, and supports all platforms. In addition to basic download functions, Gopeed is also a highly customizable downloader that supports implementing more features through integration with [APIs](https://docs.gopeed.com/dev-api.html) or installation and development of [extensions](https://docs.gopeed.com/dev-extension.html). -Visit ✈ [Official Website](https://gopeed.com) | 📖 [Develop Docs](https://docs.gopeed.com) +Visit ✈ [Official Website](https://gopeed.com) | 📖 [Official Docs](https://docs.gopeed.com) ## Install @@ -50,6 +50,8 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest docker run -d -p 9999:9999 -v /path/to/download:/root/Downloads liwei2633/gopeed ``` +[More details for docker](https://docs.gopeed.com/install.html#docker-installation) + #### Using Docker Compose ```bash @@ -160,7 +162,6 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web -go run cmd/web/main.go ``` ## Credits diff --git a/README_ja-JP.md b/README_ja-JP.md index 49c00e8e..9ff2a77f 100644 --- a/README_ja-JP.md +++ b/README_ja-JP.md @@ -49,6 +49,8 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest docker run -d -p 9999:9999 -v /path/to/download:/root/Downloads liwei2633/gopeed ``` +[Dockerの使用については](https://docs.gopeed.com/install.html#docker-installation) + #### Docker Compose の使用 ```bash @@ -159,7 +161,6 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web -go run cmd/web/main.go ``` ## 感謝 diff --git a/README_zh-CN.md b/README_zh-CN.md index 383d973b..41fe24bb 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -15,7 +15,7 @@ Gopeed(全称 Go Speed),直译过来中文名叫做`够快下载器`(不是狗屁下载器!),是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、BitTorrent、Magnet)协议下载,并且支持全平台使用。除了基本的下载功能外,Gopeed 还是一款高度可定制化的下载器,支持通过对接[APIs](https://docs.gopeed.com/zh/dev-api.html)或者安装和开发[扩展](https://docs.gopeed.com/zh/dev-extension.html)来实现更多的功能。 -访问 ✈ [官方网站](https://gopeed.com/zh-CN) | 📖 [开发文档](https://docs.gopeed.com/zh/) +访问 ✈ [官方网站](https://gopeed.com/zh-CN) | 📖 [官方文档](https://docs.gopeed.com/zh/) ## 安装 @@ -49,6 +49,8 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest docker run -d -p 9999:9999 -v /path/to/download:/root/Downloads liwei2633/gopeed ``` +[更多关于 Docker 的使用](https://docs.gopeed.com/zh/install.html#docker-%E5%AE%89%E8%A3%85) + #### 使用 Docker Compose ```bash @@ -159,7 +161,6 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web -go run cmd/web/main.go ``` ## 感谢 diff --git a/README_zh-TW.md b/README_zh-TW.md index b70bfd6d..10d8b150 100644 --- a/README_zh-TW.md +++ b/README_zh-TW.md @@ -49,6 +49,8 @@ go install github.com/GopeedLab/gopeed/cmd/gopeed@latest docker run -d -p 9999:9999 -v /path/to/download:/root/Downloads liwei2633/gopeed ``` +[更多關於 Docker 的使用](https://docs.gopeed.com/zh/install.html#docker-%E5%AE%89%E8%A3%85) + #### 使用 Docker Compose ```bash @@ -159,7 +161,6 @@ cd ../../ rm -rf cmd/web/dist cp -r ui/flutter/build/web cmd/web/dist go build -tags nosqlite,web -ldflags="-s -w" -o bin/ github.com/GopeedLab/gopeed/cmd/web -go run cmd/web/main.go ``` ## 感謝 diff --git a/cmd/web/main.go b/cmd/web/main.go index 47ba6814..e304c1cc 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -9,6 +9,8 @@ import ( "github.com/GopeedLab/gopeed/cmd" "github.com/GopeedLab/gopeed/pkg/rest/model" "io/fs" + "os" + "path/filepath" ) //go:embed dist/* @@ -29,10 +31,17 @@ func main() { } } + exe, err := os.Executable() + if err != nil { + panic(err) + } + dir := filepath.Dir(exe) + cfg := &model.StartConfig{ Network: "tcp", Address: fmt.Sprintf("%s:%d", *args.Address, *args.Port), Storage: model.StorageBolt, + StorageDir: filepath.Join(dir, "storage"), ApiToken: *args.ApiToken, ProductionMode: true, WebEnable: true, diff --git a/docker-compose.yml b/docker-compose.yml index f77cc770..fe2fef40 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,8 +4,9 @@ services: gopeed: container_name: gopeed ports: - - 9999:9999 # HTTP port (host:container) + - "9999:9999" # HTTP port (host:container) image: liwei2633/gopeed volumes: - - ~/Downloads:/root/Downloads # replace with your prefer path + - ~/gopeed/Downloads:/root/Downloads # mount download path + #- ~/gopeed/storage:/app/storage # if you need to mount storage path, uncomment this line restart: unless-stopped