From bd0bc02f0d8ec9dcdc696a180696795566db7ceb Mon Sep 17 00:00:00 2001 From: qmqz Date: Wed, 21 Jan 2026 10:40:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8E=AF=E5=A2=83=E5=8F=98?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 9 +++++++++ Dockerfile | 17 +++++++++++++++++ bin/main.dart | 29 ++++++++++++++++++++++++----- build.bat | 2 ++ pubspec.lock | 16 ++++++++-------- pubspec.yaml | 1 + push.bat | 2 ++ 7 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 build.bat create mode 100644 push.bat diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..21504f8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.dockerignore +Dockerfile +build/ +.dart_tool/ +.git/ +.github/ +.gitignore +.idea/ +.packages diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..834aec6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# Use latest stable channel SDK. +FROM dart:3.5.4 AS build +LABEL qmqz=admin@ipayl.com + +# Resolve app dependencies. +WORKDIR /app +COPY pubspec.* ./ +RUN export PUB_HOSTED_URL=https://pub.flutter-io.cn && dart pub get + +ADD bin /app/bin +RUN dart compile exe bin/main.dart -o bin/server + +FROM scratch +COPY --from=build /runtime/ / +COPY --from=build /app/bin/server /app/bin/ + +CMD ["/app/bin/server"] \ No newline at end of file diff --git a/bin/main.dart b/bin/main.dart index 85bcbc1..914e747 100644 --- a/bin/main.dart +++ b/bin/main.dart @@ -10,7 +10,6 @@ import './controller/AreaController.dart'; import 'const/ServiceConstant.dart'; - import './const/CommonVariables.dart'; void main(List args) async { @@ -21,14 +20,34 @@ Future initEasyDartModule() async { try { String? web = Platform.environment["web_port"] ?? "9200"; List redis = - (Platform.environment["redis"] ?? "127.0.0.1:6379").split(":"); - if (redis.length == 1) { - redis.add("6379"); + (Platform.environment["redis"] ?? "default@localhost:6379/0") + .split(":"); + String host; + int port = 6379; + String? password; + int db = 0; + var hs = redis[0].split("@"); + if (hs.length == 2) { + host = hs[1]; + if (hs[0] != "default") { + password = hs[0]; + } + } else { + host = hs[0]; } + var pd = redis[1].split("/"); + if (pd.length == 2) { + db = int.parse(pd[1]); + port = int.parse(pd[0]); + } else { + port = int.parse(pd[0]); + } + EasyDartModule.init( loggerConfig: LoggerConfig( host: ServiceConstant.logService, serviceName: "快检报告服务"), - redisConfig: RedisConfig(host: redis[0], port: int.parse(redis[1])), + redisConfig: RedisConfig( + host: host, port: port, database: db, password: password), webSocketConfig: WebSocketConfig(ServiceConstant.webSocketService, (data) { // 接收到服务消息 diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..1ac046c --- /dev/null +++ b/build.bat @@ -0,0 +1,2 @@ +@echo off +docker build -t 10.20.2.5:5000/kuaijian . diff --git a/pubspec.lock b/pubspec.lock index 814793e..b5adfa8 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -6,7 +6,7 @@ packages: description: path: "." ref: master - resolved-ref: a34d58f93eb692c976d1be165920a03a54dea027 + resolved-ref: e21033bc10973d40ff9cd4369a1efb9f7c30b0bb url: "https://git.he-info.cn/qmqz/easy_dart_module.git" source: git version: "1.0.0" @@ -14,15 +14,15 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" + sha256: "45cfa8471b89fb6643fe9bf51bd7931a76b8f5ec2d65de4fb176dba8d4f22c77" url: "https://pub.flutter-io.cn" source: hosted - version: "76.0.0" + version: "73.0.0" _macros: dependency: transitive description: dart source: sdk - version: "0.3.3" + version: "0.3.2" adaptive_number: dependency: transitive description: @@ -35,10 +35,10 @@ packages: dependency: transitive description: name: analyzer - sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" + sha256: "4959fec185fe70cce007c57e9ab6983101dbe593d2bf8bbfb4453aaec0cf470a" url: "https://pub.flutter-io.cn" source: hosted - version: "6.11.0" + version: "6.8.0" args: dependency: transitive description: @@ -371,10 +371,10 @@ packages: dependency: transitive description: name: macros - sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" + sha256: "0acaed5d6b7eab89f63350bccd82119e6c602df0f391260d0e32b5e23db79536" url: "https://pub.flutter-io.cn" source: hosted - version: "0.1.3-main.0" + version: "0.1.2-main.4" matcher: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 0052284..4ac63e4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,7 @@ name: report_data_service description: A sample command-line application. version: 1.0.0 +publish_to: none # repository: https://github.com/my_org/my_repo environment: diff --git a/push.bat b/push.bat new file mode 100644 index 0000000..9c7be52 --- /dev/null +++ b/push.bat @@ -0,0 +1,2 @@ +@echo off +docker push 10.20.2.5:5000/kuaijian