feat: docker support (#43)

This commit is contained in:
monkeyWie authored and GitHub committed 2022-11-07 16:32:52 +08:00
1 parent e9442edd94
commit 95eb3a427c
9 files changed
+85 -18

No files matched your search

+18 -1
View File
@@ -44,6 +44,8 @@ jobs:
cp $system\vcruntime140.dll $release cp $system\vcruntime140.dll $release
cp $system\vcruntime140_1.dll $release cp $system\vcruntime140_1.dll $release
Compress-Archive -Path $release -DestinationPath build\windows\Output\Gopeed-$env:VERSION-windows-amd64.zip
cd build/windows cd build/windows
echo @" echo @"
; Script generated by the Inno Setup Script Wizard. ; Script generated by the Inno Setup Script Wizard.
@@ -95,7 +97,7 @@ jobs:
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
"@ > setup.iss "@ > setup.iss
iscc.exe setup.iss iscc.exe setup.iss
mv "Output\gopeed.exe" "Output\Gopeed-$env:VERSION-windows-amd64.exe" mv "Output\gopeed.exe" "Output\Gopeed-$env:VERSION-windows-amd64-install.exe"
- name: Upload - name: Upload
uses: shogo82148/actions-upload-release-asset@v1 uses: shogo82148/actions-upload-release-asset@v1
with: with:
@@ -318,3 +320,18 @@ jobs:
upload_url: ${{ needs.release.outputs.upload_url }} upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: dist/zip/* asset_path: dist/zip/*
overwrite: true overwrite: true
build-docker:
runs-on: ubuntu-latest
needs: [get_release]
steps:
- uses: actions/checkout@v3
- name: Build
env:
VERSION: ${{ needs.get_release.outputs.tag_name }}
run: |
tag=liwei2633/gopeed:$VERSION
docker build -t $tag .
docker login -u liwei2633 -p ${{ secrets.DOCKER_PASSWORD }}
docker push $tag
docker tag $tag liwei2633/gopeed:latest
docker push liwei2633/gopeed:latest
+21
View File
@@ -0,0 +1,21 @@
FROM cirrusci/flutter:3.3.7 AS flutter
WORKDIR /app
COPY ./ui/flutter/pubspec.yaml ./ui/flutter/pubspec.lock ./
RUN flutter pub get
COPY ./ui/flutter ./
RUN flutter build web
FROM golang:1.19.3 AS go
WORKDIR /app
COPY ./go.mod ./go.sum ./
RUN go mod download
COPY . .
COPY --from=flutter /app/build/web/* ./cmd/web/dist
RUN go build -tags nosqlite,web -ldflags="-s -w" -o dist/gopeed github.com/monkeyWie/gopeed/cmd/web
FROM alpine:3.14.2
LABEL maintainer="monkeyWie"
WORKDIR /app
COPY --from=go /app/dist/gopeed ./
EXPOSE 9999
ENTRYPOINT ["./gopeed"]
+10
View File
@@ -21,6 +21,7 @@ Gopeed is a high-speed downloader developed by `Golang`+`Flutter`, which support
- [x] android - [x] android
- [ ] ios - [ ] ios
- [x] web - [x] web
- [x] docker
[To Release](https://github.com/monkeyWie/gopeed/releases/latest) [To Release](https://github.com/monkeyWie/gopeed/releases/latest)
@@ -32,6 +33,15 @@ use `go install`:
go install github.com/monkeyWie/gopeed/cmd/gopeed go install github.com/monkeyWie/gopeed/cmd/gopeed
``` ```
### Docker
```bash
docker run liwei2633/gopeed:latest -v /path/to/download:/download -p 9999:9999
```
When the docker container is running, you can access the web page through `http://localhost:9999`.
> Tip: Modify the download path to `/download` on the setting page to access the downloaded files on the host.
## Showcase ## Showcase
![](_docs/img/ui-demo.png) ![](_docs/img/ui-demo.png)
+10
View File
@@ -21,6 +21,7 @@ Gopeed 是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、
- [x] android - [x] android
- [ ] ios - [ ] ios
- [x] web - [x] web
- [x] docker
[点击前往](https://github.com/monkeyWie/gopeed/releases/latest) [点击前往](https://github.com/monkeyWie/gopeed/releases/latest)
@@ -32,6 +33,15 @@ Gopeed 是一款由`Golang`+`Flutter`开发的高速下载器,支持(HTTP、
go install github.com/monkeyWie/gopeed/cmd/gopeed go install github.com/monkeyWie/gopeed/cmd/gopeed
``` ```
### Docker
```bash
docker run liwei2633/gopeed:latest -v /path/to/download:/download -p 9999:9999
```
当 docker 容器运行时,可以通过 `http://localhost:9999` 访问 web 页面。
> 提示:在设置页面把下载路径修改为 `/download` 以便在宿主机访问下载完的文件。
## 界面展示 ## 界面展示
![](_docs/img/ui-demo.png) ![](_docs/img/ui-demo.png)
+1 -1
View File
@@ -26,7 +26,7 @@ func main() {
cfg := &model.StartConfig{ cfg := &model.StartConfig{
Network: "tcp", Network: "tcp",
Address: "127.0.0.1:9999", Address: "127.0.0.1:9999",
Storage: model.StorageMem, Storage: model.StorageBolt,
WebEnable: true, WebEnable: true,
WebFS: sub, WebFS: sub,
} }
+4 -1
View File
@@ -3,6 +3,7 @@ import 'dart:io';
import 'package:dio/adapter.dart'; import 'package:dio/adapter.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:gopeed/util/util.dart';
import 'model/create_task.dart'; import 'model/create_task.dart';
import 'model/request.dart'; import 'model/request.dart';
import 'model/resource.dart'; import 'model/resource.dart';
@@ -26,7 +27,9 @@ class _Client {
final isUnixSocket = LibgopeedBoot.instance.config.network == 'unix'; final isUnixSocket = LibgopeedBoot.instance.config.network == 'unix';
dio.options.baseUrl = isUnixSocket dio.options.baseUrl = isUnixSocket
? 'http://127.0.0.1' ? 'http://127.0.0.1'
: 'http://${LibgopeedBoot.instance.config.address}'; : (Util.isWeb()
? ""
: 'http://${LibgopeedBoot.instance.config.address}');
_instance!.dio = dio; _instance!.dio = dio;
if (isUnixSocket) { if (isUnixSocket) {
(_instance!.dio.httpClientAdapter as DefaultHttpClientAdapter) (_instance!.dio.httpClientAdapter as DefaultHttpClientAdapter)
+1 -1
View File
@@ -9,7 +9,7 @@ class LibgopeedConfig {
LibgopeedConfig({ LibgopeedConfig({
this.network = "tcp", this.network = "tcp",
this.address = "127.0.0.1:9999", this.address = "127.0.0.1:0",
this.refreshInterval = 500, this.refreshInterval = 500,
}); });
} }
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:gopeed/i18n/messages.dart'; import 'package:gopeed/i18n/messages.dart';
import 'package:gopeed/util/util.dart';
import '../../setting/setting.dart'; import '../../setting/setting.dart';
import '../../widget/directory_selector.dart'; import '../../widget/directory_selector.dart';
@@ -69,7 +70,9 @@ class SettingView extends GetView<SettingController> {
controller.setting.value.downloadDir) { controller.setting.value.downloadDir) {
controller.setting.value.downloadDir = controller.setting.value.downloadDir =
downloadDirController.text; downloadDirController.text;
controller.clearTapStatus(); if (Util.isDesktop()) {
controller.clearTapStatus();
}
await debounceSave(); await debounceSave();
} }
+16 -13
View File
@@ -1,6 +1,7 @@
import 'package:file_selector/file_selector.dart'; import 'package:file_selector/file_selector.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:gopeed/util/util.dart';
import '../util/mac_secure_util.dart'; import '../util/mac_secure_util.dart';
@@ -23,7 +24,7 @@ class _DirectorySelectorState extends State<DirectorySelector> {
children: [ children: [
Expanded( Expanded(
child: TextFormField( child: TextFormField(
readOnly: true, readOnly: Util.isWeb() ? false : true,
controller: widget.controller, controller: widget.controller,
decoration: widget.showLabel decoration: widget.showLabel
? InputDecoration( ? InputDecoration(
@@ -34,18 +35,20 @@ class _DirectorySelectorState extends State<DirectorySelector> {
return v!.trim().isNotEmpty ? null : 'setting.downloadDirValid'.tr; return v!.trim().isNotEmpty ? null : 'setting.downloadDirValid'.tr;
}, },
)), )),
IconButton( !Util.isDesktop()
icon: const Icon(Icons.folder_open), ? null
onPressed: () async { : IconButton(
if (GetPlatform.isDesktop) { icon: const Icon(Icons.folder_open),
var dir = await getDirectoryPath(); onPressed: () async {
if (dir != null) { if (GetPlatform.isDesktop) {
widget.controller.text = dir; var dir = await getDirectoryPath();
MacSecureUtil.saveBookmark(dir); if (dir != null) {
} widget.controller.text = dir;
} MacSecureUtil.saveBookmark(dir);
}) }
], }
})
].where((e) => e != null).map((e) => e!).toList(),
); );
} }
} }