mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-06 08:30:29 +00:00
feat: docker download dir move to /app/Download (#398)
This commit is contained in:
4 files changed
+20
-7
No files matched your search
@@ -471,7 +471,9 @@ jobs:
|
||||
VERSION: ${{ needs.get-release.outputs.version }}
|
||||
with:
|
||||
push: ${{ github.event.inputs.test == 'true' && 'false' || 'true' }}
|
||||
build-args: VERSION=${{ env.VERSION }}
|
||||
build-args:
|
||||
- VERSION=${{ env.VERSION }}
|
||||
- IN_DOCKER=true
|
||||
platforms: |
|
||||
linux/386
|
||||
linux/amd64
|
||||
|
||||
+4
-1
@@ -12,7 +12,10 @@ RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=flutter /app/build/web ./cmd/web/dist
|
||||
ARG VERSION=dev
|
||||
RUN CGO_ENABLED=0 go build -tags nosqlite,web -ldflags="-s -w -X github.com/GopeedLab/gopeed/pkg/base.Version=${VERSION}" -o dist/gopeed github.com/GopeedLab/gopeed/cmd/web
|
||||
RUN CGO_ENABLED=0 go build -tags nosqlite,web -ldflags="-s -w \
|
||||
-X github.com/GopeedLab/gopeed/pkg/base.Version=${VERSION}" \
|
||||
-X github.com/GopeedLab/gopeed/pkg/base.InDocker=${IN_DOCKER}" \
|
||||
-o dist/gopeed github.com/GopeedLab/gopeed/cmd/web
|
||||
|
||||
FROM alpine:3.14.2
|
||||
LABEL maintainer="monkeyWie"
|
||||
|
||||
+12
-5
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"github.com/GopeedLab/gopeed/pkg/base"
|
||||
"github.com/GopeedLab/gopeed/pkg/rest"
|
||||
"github.com/GopeedLab/gopeed/pkg/rest/model"
|
||||
"net/http"
|
||||
@@ -24,14 +25,20 @@ func Start(cfg *model.StartConfig) {
|
||||
panic(err)
|
||||
}
|
||||
if downloadCfg.FirstLoad {
|
||||
// Set default download dir to user download dir
|
||||
userDir, err := os.UserHomeDir()
|
||||
if err == nil {
|
||||
downloadDir := filepath.Join(userDir, "Downloads")
|
||||
// Set default download dir, in docker, it will be ${exe}/Downloads, else it will be ${user}/Downloads
|
||||
var downloadDir string
|
||||
if base.InDocker {
|
||||
downloadDir = filepath.Join(filepath.Dir(cfg.StorageDir), "Downloads")
|
||||
} else {
|
||||
userDir, err := os.UserHomeDir()
|
||||
if err == nil {
|
||||
downloadDir = filepath.Join(userDir, "Downloads")
|
||||
}
|
||||
}
|
||||
if downloadDir != "" {
|
||||
downloadCfg.DownloadDir = downloadDir
|
||||
rest.Downloader.PutConfig(downloadCfg)
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Printf("Server start success on http://%s\n", listener.Addr().String())
|
||||
if err := srv.Serve(listener); err != nil && err != http.ErrServerClosed {
|
||||
|
||||
@@ -2,6 +2,7 @@ package base
|
||||
|
||||
// Version is the build version, set at build time, using `go build -ldflags "-X github.com/GopeedLab/gopeed/pkg/base.Version=1.0.0"`.
|
||||
var Version string
|
||||
var InDocker bool
|
||||
|
||||
func init() {
|
||||
if Version == "" {
|
||||
Reference in new issue
Block a user