代码改变世界

天行健,君子以自强不息

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

为Blazor网站项目,“添加Docker支持”

img

img

这时,网站项目根目录下会新增Dockerfile。

img

里面文字内容如下

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["NuGet.Config", "."]
COPY ["src/Yee.Change.PayPortal.Blazor/Yee.Change.PayPortal.Blazor.csproj", "src/Yee.Change.PayPortal.Blazor/"]
COPY ["src/Yee.Change.PayPortal.Application/Yee.Change.PayPortal.Application.csproj", "src/Yee.Change.PayPortal.Application/"]
COPY ["src/Yee.Change.PayPortal.Domain/Yee.Change.PayPortal.Domain.csproj", "src/Yee.Change.PayPortal.Domain/"]
COPY ["src/Yee.Change.PayPortal.Domain.Shared/Yee.Change.PayPortal.Domain.Shared.csproj", "src/Yee.Change.PayPortal.Domain.Shared/"]
COPY ["src/Yee.Change.PayPortal.Application.Contracts/Yee.Change.PayPortal.Application.Contracts.csproj", "src/Yee.Change.PayPortal.Application.Contracts/"]
COPY ["src/Yee.Change.PayPortal.HttpApi/Yee.Change.PayPortal.HttpApi.csproj", "src/Yee.Change.PayPortal.HttpApi/"]
COPY ["src/Yee.Change.PayPortal.EntityFrameworkCore/Yee.Change.PayPortal.EntityFrameworkCore.csproj", "src/Yee.Change.PayPortal.EntityFrameworkCore/"]
RUN dotnet restore "./src/Yee.Change.PayPortal.Blazor/Yee.Change.PayPortal.Blazor.csproj"
COPY . .
WORKDIR "/src/src/Yee.Change.PayPortal.Blazor"
RUN dotnet build "./Yee.Change.PayPortal.Blazor.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Yee.Change.PayPortal.Blazor.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Yee.Change.PayPortal.Blazor.dll"]

在第二步用的镜像,我们需要干预一下,里面加入我们docker-linux-dotnet8:2024镜像里的脚本文件。制作好这个脚本之后,push到我们的服务器。

假定这个镜像是docker.amihome.cn/amihome/dotnet/sdk:8.0

那么我们把Visual Studio默认生成的Dockerfile,稍微修改一下

FROM docker.amihome.cn/amihome/dotnet/sdk8:8.0 AS build

WORKDIR /
# 因为要运行下边这个shell,所以build镜像不能用默认的mcr.microsoft.com/dotnet/sdk:8.0
# 我们自己的镜像是包含下边这个shell的
RUN /home/public/download-directory-builds-props.sh dev.amihome.cn

Gitlab服务器上的设置

适用于本项目或群组级别的变量

img

本项目的 .gitlab-ci.yml

解决方案根目录下,.gitlab-ci.yml的内容如下

stages:
    - build-docker-image
    - docker-run-on-local-app-server
variables:
    PAY_IMAGE_FULL_URL: $DOCKER_REPOZITORY_URL/pay:$CI_PIPELINE_ID
    # Use no compression for caches
    CACHE_COMPRESSION_LEVEL: "fastest"
cache:
    paths:
      - node_modules/
build API:
    stage: build-docker-image
    before_script:
        - dotnet nuget locals plugins-cache --clear
        - echo $DOCKER_LOGIN_USER $DOCKER_LOGIN_PASSWORD $DOCKER_REGISTRY_DNS_NAME
        - docker login -u $DOCKER_LOGIN_USER -p $DOCKER_LOGIN_PASSWORD $DOCKER_REGISTRY_DNS_NAME
    script:
        - cd .
        - docker buildx build --platform linux/amd64 -t $PAY_IMAGE_FULL_URL -f src/Yee.Change.PayPortal.Blazor/Dockerfile --no-cache . --push
部署支付网关(测试站):
  stage: docker-run-on-local-app-server
  script:
    - echo "部署到支付网关测试站……"
    - bash $SSH_TO_APP_SERVER_FOR_DOCKER_RUN_SH pay_test 58003 8080 $PAY_IMAGE_FULL_URL amisoft $DOCKER_REGISTRY_DNS_NAME $DOCKER_LOGIN_USER $DOCKER_LOGIN_PASSWORD $SSH_AUTO_LOGIN_USER $APP_SERVER

签入Gitlab

任务成功

build-docker-image的输出如下

Running with gitlab-runner 16.9.0 (656c1943)
  on 春漫里2号大力士 oEbtvPUXD, system ID: r_aAMlDtmiasEr
Preparing the "docker" executor 00:01
Using Docker executor with image docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest ...
Authenticating with credentials from $DOCKER_AUTH_CONFIG
Pulling docker image docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest ...
Using docker image sha256:8ed5648904735a25018a311c7fa25f9516e8f1887df6d96998f4a1dcc19c02db for docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest with digest docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0@sha256:7ca5369086c95fc7337dd5d8a54e40f0f43abd5cc36b000938741887e2626d44 ...
Preparing environment 00:01
Running on runner-oebtvpuxd-project-37-concurrent-0 via 66f53ba74bbf...
Getting source from Git repository 00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/oEbtvPUXD/0/abp7/pay-portal/.git/
Checking out 0c6624fd as detached HEAD (ref is master)...
Skipping Git submodules setup
Restoring cache 00:00
Checking cache for default-protected...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Executing "step_script" stage of the job script 02:16
Using docker image sha256:8ed5648904735a25018a311c7fa25f9516e8f1887df6d96998f4a1dcc19c02db for docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest with digest docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0@sha256:7ca5369086c95fc7337dd5d8a54e40f0f43abd5cc36b000938741887e2626d44 ...
$ dotnet nuget locals plugins-cache --clear
Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.200
Telemetry
---------
The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
Clearing NuGet plugins cache: /root/.local/share/NuGet/plugin-cache
Local resources cleared.
$ echo $DOCKER_LOGIN_USER $DOCKER_LOGIN_PASSWORD $DOCKER_REGISTRY_DNS_NAME
gitlab-runner [MASKED] docker.amihome.cn
$ docker login -u $DOCKER_LOGIN_USER -p $DOCKER_LOGIN_PASSWORD $DOCKER_REGISTRY_DNS_NAME
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
$ cd .
$ docker buildx build --platform linux/amd64 -t $PAY_IMAGE_FULL_URL -f src/Yee.Change.PayPortal.Blazor/Dockerfile --no-cache . --push
#0 building with "default" instance using docker driver
#1 [internal] load .dockerignore
#1 transferring context: 358B done
#1 DONE 0.0s
#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 2.06kB done
#2 DONE 0.0s
#3 [internal] load metadata for docker.amihome.cn/amihome/dotnet/sdk:8.0
#3 DONE 0.0s
#4 [internal] load metadata for docker.amihome.cn/amihome/dotnet/aspnet:8.0
#4 DONE 0.0s
#5 [base 1/2] FROM docker.amihome.cn/amihome/dotnet/aspnet:8.0
#5 DONE 0.0s
#6 [base 2/2] WORKDIR /app
#6 CACHED
#7 [final 1/4] WORKDIR /app
#7 CACHED
#8 [build  1/16] FROM docker.amihome.cn/amihome/dotnet/sdk:8.0
#8 CACHED
#9 [internal] load build context
#9 transferring context: 30.32MB 0.3s done
#9 DONE 0.3s
#10 [build  2/16] RUN /home/public/download-directory-builds-props.sh http://dev.amihome.cn/
#10 0.267 off
#10 0.270 共享版本号的网站是 http://dev.amihome.cn/
#10 0.270 下载urls.txt文件,这个文件里有Directory.Build.props中Import的相关文件的列表……
#10 0.277 --2024-02-29 02:34:37--  http://dev.amihome.cn/urls.txt
#10 0.277 Resolving dev.amihome.cn (dev.amihome.cn)... 192.168.3.218
#10 0.279 Connecting to dev.amihome.cn (dev.amihome.cn)|192.168.3.218|:80... connected.
#10 0.280 HTTP request sent, awaiting response... 200 OK
#10 0.281 Length: 1837 (1.8K) [text/plain]
#10 0.281 Saving to: 'urls.txt'
#10 0.281 
#10 0.281      0K .                                                     100% 4.44M=0s
#10 0.282 
#10 0.282 2024-02-29 02:34:37 (4.44 MB/s) - 'urls.txt' saved [1837/1837]
#10 0.282 
#10 0.291 2024-02-29 02:34:37 URL:http://dev.amihome.cn/Directory.Build.props [10138/10138] -> "Directory.Build.props" [1]
#10 0.301 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Account.props [122/122] -> "version-numbers/Directory.Build.Change.Account.props" [1]
#10 0.309 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Common.props [120/120] -> "version-numbers/Directory.Build.Change.Common.props" [1]
#10 0.318 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Config.props [120/120] -> "version-numbers/Directory.Build.Change.Config.props" [1]
#10 0.329 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Divination.props [128/128] -> "version-numbers/Directory.Build.Change.Divination.props" [1]
#10 0.341 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.SaasDbAccess.props [132/132] -> "version-numbers/Directory.Build.Change.SaasDbAccess.props" [1]
#10 0.354 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.LeptonC.props [122/122] -> "version-numbers/Directory.Build.Change.LeptonC.props" [1]
#10 0.366 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Rms.props [114/114] -> "version-numbers/Directory.Build.Change.Rms.props" [1]
#10 0.379 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.ToolKit.props [122/122] -> "version-numbers/Directory.Build.Change.ToolKit.props" [1]
#10 0.392 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Calendar.props [124/124] -> "version-numbers/Directory.Build.Change.Calendar.props" [1]
#10 0.404 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.props [120/120] -> "version-numbers/Directory.Build.Change.Brain.props" [1]
#10 0.417 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Fengshui.props [137/137] -> "version-numbers/Directory.Build.Change.Brain.Fengshui.props" [1]
#10 0.430 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.UI.props [124/124] -> "version-numbers/Directory.Build.Change.Brain.UI.props" [1]
#10 0.443 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Ziping.props [134/134] -> "version-numbers/Directory.Build.Change.Brain.Ziping.props" [1]
#10 0.456 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Lianshan.props [137/137] -> "version-numbers/Directory.Build.Change.Brain.Lianshan.props" [1]
#10 0.469 2024-02-29 02:34:37 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Qimen.props [131/131] -> "version-numbers/Directory.Build.Change.Brain.Qimen.props" [1]
#10 0.482 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Zeri.props [129/129] -> "version-numbers/Directory.Build.Change.Brain.Zeri.props" [1]
#10 0.495 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Brain.Ziwei.props [131/131] -> "version-numbers/Directory.Build.Change.Brain.Ziwei.props" [1]
#10 0.507 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Yee.AspNetCore.props [123/123] -> "version-numbers/Directory.Build.Yee.AspNetCore.props" [1]
#10 0.519 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Yee.Cloud.props [113/113] -> "version-numbers/Directory.Build.Yee.Cloud.props" [1]
#10 0.532 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Yee.props [102/102] -> "version-numbers/Directory.Build.Yee.props" [1]
#10 0.546 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Yee.Utils.props [120/120] -> "version-numbers/Directory.Build.Yee.Utils.props" [1]
#10 0.558 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.AdminUI.props [122/122] -> "version-numbers/Directory.Build.Change.AdminUI.props" [1]
#10 0.571 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.EasyComment.props [132/132] -> "version-numbers/Directory.Build.Change.EasyComment.props" [1]
#10 0.584 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.EventRecorder.props [134/134] -> "version-numbers/Directory.Build.Change.EventRecorder.props" [1]
#10 0.598 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Shop.props [116/116] -> "version-numbers/Directory.Build.Change.Shop.props" [1]
#10 0.610 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.Pay.props [116/116] -> "version-numbers/Directory.Build.Change.Pay.props" [1]
#10 0.624 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.WeChatMp.props [124/124] -> "version-numbers/Directory.Build.Change.WeChatMp.props" [1]
#10 0.636 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.WeChatServices.props [135/135] -> "version-numbers/Directory.Build.Change.WeChatServices.props" [1]
#10 0.648 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.EasyAbp.Abp.WeChat.props [146/146] -> "version-numbers/Directory.Build.EasyAbp.Abp.WeChat.props" [1]
#10 0.661 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Myvas.QQConnect.props [123/123] -> "version-numbers/Directory.Build.Myvas.QQConnect.props" [1]
#10 0.673 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Myvas.Weixin.Mp.props [124/124] -> "version-numbers/Directory.Build.Myvas.Weixin.Mp.props" [1]
#10 0.682 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Myvas.Weixin.Open.props [127/127] -> "version-numbers/Directory.Build.Myvas.Weixin.Open.props" [1]
#10 0.689 2024-02-29 02:34:38 URL:http://dev.amihome.cn/version-numbers/Directory.Build.Change.FrontEnd.props [125/125] -> "version-numbers/Directory.Build.Change.FrontEnd.props" [1]
#10 DONE 0.7s
#11 [build  3/16] WORKDIR /src
#11 DONE 0.1s
#12 [build  4/16] COPY [NuGet.Config, .]
#12 DONE 0.0s
#13 [build  5/16] COPY [src/Yee.Change.PayPortal.Blazor/Yee.Change.PayPortal.Blazor.csproj, src/Yee.Change.PayPortal.Blazor/]
#13 DONE 0.0s
#14 [build  6/16] COPY [src/Yee.Change.PayPortal.Application/Yee.Change.PayPortal.Application.csproj, src/Yee.Change.PayPortal.Application/]
#14 DONE 0.0s
#15 [build  7/16] COPY [src/Yee.Change.PayPortal.Domain/Yee.Change.PayPortal.Domain.csproj, src/Yee.Change.PayPortal.Domain/]
#15 DONE 0.0s
#16 [build  8/16] COPY [src/Yee.Change.PayPortal.Domain.Shared/Yee.Change.PayPortal.Domain.Shared.csproj, src/Yee.Change.PayPortal.Domain.Shared/]
#16 DONE 0.0s
#17 [build  9/16] COPY [src/Yee.Change.PayPortal.Application.Contracts/Yee.Change.PayPortal.Application.Contracts.csproj, src/Yee.Change.PayPortal.Application.Contracts/]
#17 DONE 0.0s
#18 [build 10/16] COPY [src/Yee.Change.PayPortal.HttpApi/Yee.Change.PayPortal.HttpApi.csproj, src/Yee.Change.PayPortal.HttpApi/]
#18 DONE 0.0s
#19 [build 11/16] COPY [src/Yee.Change.PayPortal.EntityFrameworkCore/Yee.Change.PayPortal.EntityFrameworkCore.csproj, src/Yee.Change.PayPortal.EntityFrameworkCore/]
#19 DONE 0.0s
#20 [build 12/16] RUN dotnet restore "src/Yee.Change.PayPortal.Blazor/Yee.Change.PayPortal.Blazor.csproj"
#20 0.742   Determining projects to restore...
#20 27.05   Restored /src/src/Yee.Change.PayPortal.Domain.Shared/Yee.Change.PayPortal.Domain.Shared.csproj (in 25.58 sec).
#20 29.78   Restored /src/src/Yee.Change.PayPortal.Application.Contracts/Yee.Change.PayPortal.Application.Contracts.csproj (in 28.34 sec).
#20 30.63   Restored /src/src/Yee.Change.PayPortal.Domain/Yee.Change.PayPortal.Domain.csproj (in 29.2 sec).
#20 36.70   Restored /src/src/Yee.Change.PayPortal.HttpApi/Yee.Change.PayPortal.HttpApi.csproj (in 35.27 sec).
#20 38.59   Restored /src/src/Yee.Change.PayPortal.EntityFrameworkCore/Yee.Change.PayPortal.EntityFrameworkCore.csproj (in 37.16 sec).
#20 43.35   Restored /src/src/Yee.Change.PayPortal.Application/Yee.Change.PayPortal.Application.csproj (in 41.92 sec).
#20 95.95   Restored /src/src/Yee.Change.PayPortal.Blazor/Yee.Change.PayPortal.Blazor.csproj (in 1.58 min).
#20 DONE 96.2s
#21 [build 13/16] COPY . .
#21 DONE 0.2s
#22 [build 14/16] WORKDIR /src/src/Yee.Change.PayPortal.Blazor
#22 DONE 0.0s
#23 [build 15/16] RUN dotnet build "Yee.Change.PayPortal.Blazor.csproj" -c Release -o /app/build
#23 0.365 MSBuild version 17.9.4+90725d08d for .NET
#23 1.202   Determining projects to restore...
#23 2.067   All projects are up-to-date for restore.
#23 4.173   Yee.Change.PayPortal.Domain.Shared -> /app/build/Yee.Change.PayPortal.Domain.Shared.dll
#23 4.471   Yee.Change.PayPortal.Application.Contracts -> /app/build/Yee.Change.PayPortal.Application.Contracts.dll
#23 5.355   Yee.Change.PayPortal.HttpApi -> /app/build/Yee.Change.PayPortal.HttpApi.dll
#23 5.401   Yee.Change.PayPortal.Domain -> /app/build/Yee.Change.PayPortal.Domain.dll
#23 5.845   Yee.Change.PayPortal.Application -> /app/build/Yee.Change.PayPortal.Application.dll
#23 5.904   Yee.Change.PayPortal.EntityFrameworkCore -> /app/build/Yee.Change.PayPortal.EntityFrameworkCore.dll
#23 11.77   Yee.Change.PayPortal.Blazor -> /app/build/Yee.Change.PayPortal.Blazor.dll
#23 11.79 
#23 11.79 Build succeeded.
#23 11.79     0 Warning(s)
#23 11.79     0 Error(s)
#23 11.79 
#23 11.79 Time Elapsed 00:00:11.34
#23 DONE 11.9s
#24 [publish 1/1] RUN dotnet publish "Yee.Change.PayPortal.Blazor.csproj" -c Release -o /app/publish /p:UseAppHost=false
#24 0.538 MSBuild version 17.9.4+90725d08d for .NET
#24 1.327   Determining projects to restore...
#24 2.066   All projects are up-to-date for restore.
#24 3.171   Yee.Change.PayPortal.Domain.Shared -> /src/src/Yee.Change.PayPortal.Domain.Shared/bin/Release/netstandard2.0/Yee.Change.PayPortal.Domain.Shared.dll
#24 4.394   Yee.Change.PayPortal.Application.Contracts -> /src/src/Yee.Change.PayPortal.Application.Contracts/bin/Release/netstandard2.0/Yee.Change.PayPortal.Application.Contracts.dll
#24 4.559   Yee.Change.PayPortal.Domain -> /src/src/Yee.Change.PayPortal.Domain/bin/Release/net8.0/Yee.Change.PayPortal.Domain.dll
#24 5.147   Yee.Change.PayPortal.HttpApi -> /src/src/Yee.Change.PayPortal.HttpApi/bin/Release/net8.0/Yee.Change.PayPortal.HttpApi.dll
#24 5.201   Yee.Change.PayPortal.Application -> /src/src/Yee.Change.PayPortal.Application/bin/Release/net8.0/Yee.Change.PayPortal.Application.dll
#24 5.244   Yee.Change.PayPortal.EntityFrameworkCore -> /src/src/Yee.Change.PayPortal.EntityFrameworkCore/bin/Release/net8.0/Yee.Change.PayPortal.EntityFrameworkCore.dll
#24 10.14   Yee.Change.PayPortal.Blazor -> /src/src/Yee.Change.PayPortal.Blazor/bin/Release/net8.0/Yee.Change.PayPortal.Blazor.dll
#24 11.38   Yee.Change.PayPortal.Blazor -> /app/publish/
#24 DONE 11.5s
#25 [final 2/4] COPY --from=publish /app/publish .
#25 DONE 0.3s
#26 [final 3/4] RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#26 DONE 0.2s
#27 [final 4/4] RUN echo 'Asia/Shanghai' >/etc/timezone
#27 DONE 0.4s
#28 exporting to image
#28 exporting layers
#28 exporting layers 1.1s done
#28 writing image sha256:310f94862c1cbf2e051b482a0e7d691a1684688a155435599ef10a1f04d1ac42 done
#28 naming to docker.amihome.cn/amihome/change/pay:14522 0.0s done
#28 DONE 1.2s
#29 pushing docker.amihome.cn/amihome/change/pay:14522 with docker
#29 pushing layer 72f580608822
#29 pushing layer 72f580608822 2.56kB / 14B 0.0s
#29 pushing layer d6bb5c59e3c3 2.05kB 0.0s
#29 pushing layer e6ed546978d4 535.04kB / 188.26MB 0.1s
#29 pushing layer 5f70bf18a086 0.0s
#29 pushing layer 5c56394d8a3c 0.0s
#29 pushing layer f935d05a834d 0.0s
#29 pushing layer a97254ce8ecf 0.0s
#29 pushing layer c9a0a0d5796e 0.1s
#29 pushing layer 2a73a8d650c3 0.1s
#29 pushing layer b964d33c1a98 0.1s
#29 pushing layer 46ee29510937 0.1s
#29 pushing layer 20d0f15cd2c2 0.1s
#29 pushing layer 5168a4b3a2c8 0.1s
#29 pushing layer a01739405b20
#29 pushing layer 71c393a9faea
#29 pushing layer eb710e731d28
#29 pushing layer 1f0a4d187f2d
#29 pushing layer eeb0a5bc864d
#29 pushing layer f14e3173eb6a
#29 pushing layer 254943a44e04
#29 pushing layer ceb365432eec
#29 pushing layer 72f580608822 0.1s done
#29 pushing layer d6bb5c59e3c3 0.1s done
#29 pushing layer e6ed546978d4 10.47MB / 188.26MB 0.5s
#29 pushing layer e6ed546978d4 20.95MB / 188.26MB 0.8s
#29 pushing layer e6ed546978d4 30.82MB / 188.26MB 1.3s
#29 pushing layer e6ed546978d4 40.75MB / 188.26MB 1.9s
#29 pushing layer e6ed546978d4 52.30MB / 188.26MB 2.4s
#29 pushing layer e6ed546978d4 62.12MB / 188.26MB 2.9s
#29 pushing layer e6ed546978d4 72.54MB / 188.26MB 3.5s
#29 pushing layer e6ed546978d4 83.06MB / 188.26MB 3.9s
#29 pushing layer e6ed546978d4 92.77MB / 188.26MB 4.3s
#29 pushing layer e6ed546978d4 103.11MB / 188.26MB 4.7s
#29 pushing layer e6ed546978d4 114.58MB / 188.26MB 5.1s
#29 pushing layer e6ed546978d4 125.79MB / 188.26MB 5.6s
#29 pushing layer e6ed546978d4 136.00MB / 188.26MB 6.0s
#29 pushing layer e6ed546978d4 147.25MB / 188.26MB 6.5s
#29 pushing layer e6ed546978d4 158.56MB / 188.26MB 7.0s
#29 pushing layer e6ed546978d4 169.84MB / 188.26MB 7.6s
#29 pushing layer e6ed546978d4 181.59MB / 188.26MB 8.2s
#29 pushing layer e6ed546978d4 192.11MB / 188.26MB 8.7s
#29 pushing layer e6ed546978d4 10.6s done
#29 pushing layer 5f70bf18a086 10.9s done
#29 pushing layer 5c56394d8a3c 10.9s done
#29 pushing layer f935d05a834d 10.9s done
#29 pushing layer a97254ce8ecf 10.9s done
#29 pushing layer c9a0a0d5796e 10.9s done
#29 pushing layer 2a73a8d650c3 10.9s done
#29 pushing layer b964d33c1a98 10.9s done
#29 pushing layer 46ee29510937 10.9s done
#29 pushing layer 20d0f15cd2c2 10.9s done
#29 pushing layer 5168a4b3a2c8 10.9s done
#29 pushing layer a01739405b20 10.9s done
#29 pushing layer 71c393a9faea 10.9s done
#29 pushing layer eb710e731d28 10.9s done
#29 pushing layer 1f0a4d187f2d 10.9s done
#29 pushing layer eeb0a5bc864d 10.9s done
#29 pushing layer f14e3173eb6a 10.9s done
#29 pushing layer 254943a44e04 10.9s done
#29 pushing layer ceb365432eec 10.9s done
#29 DONE 10.9s
Saving cache for successful job 00:01
Creating cache default-protected...
WARNING: node_modules/: no matching files. Ensure that the artifact path is relative to the working directory (/builds/oEbtvPUXD/0/abp7/pay-portal) 
Archive is up to date!                             
Created cache
Cleaning up project directory and file based variables 00:00
Job succeeded

docker-run-on-local-app-server的输出如下

Running with gitlab-runner 16.9.0 (656c1943)
  on 春漫里2号大力士 oEbtvPUXD, system ID: r_aAMlDtmiasEr
Preparing the "docker" executor 00:00
Using Docker executor with image docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest ...
Authenticating with credentials from $DOCKER_AUTH_CONFIG
Pulling docker image docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest ...
Using docker image sha256:8ed5648904735a25018a311c7fa25f9516e8f1887df6d96998f4a1dcc19c02db for docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest with digest docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0@sha256:7ca5369086c95fc7337dd5d8a54e40f0f43abd5cc36b000938741887e2626d44 ...
Preparing environment 00:01
Running on runner-oebtvpuxd-project-37-concurrent-0 via 66f53ba74bbf...
Getting source from Git repository 00:01
Fetching changes with git depth set to 20...
Reinitialized existing Git repository in /builds/oEbtvPUXD/0/abp7/pay-portal/.git/
Checking out 0c6624fd as detached HEAD (ref is master)...
Skipping Git submodules setup
Restoring cache 00:01
Checking cache for default-protected...
No URL provided, cache will not be downloaded from shared cache server. Instead a local version of cache will be extracted. 
Successfully extracted cache
Executing "step_script" stage of the job script 00:01
Using docker image sha256:8ed5648904735a25018a311c7fa25f9516e8f1887df6d96998f4a1dcc19c02db for docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0:latest with digest docker.amihome.cn/amihome/gitlab/docker-linux-dotnet8.0@sha256:7ca5369086c95fc7337dd5d8a54e40f0f43abd5cc36b000938741887e2626d44 ...
$ echo "部署到支付网关测试站……"
部署到支付网关测试站……
$ bash $SSH_TO_APP_SERVER_FOR_DOCKER_RUN_SH pay_test 58003 8080 $PAY_IMAGE_FULL_URL amisoft $DOCKER_REGISTRY_DNS_NAME $DOCKER_LOGIN_USER $DOCKER_LOGIN_PASSWORD $SSH_AUTO_LOGIN_USER $APP_SERVER
docker容器实例名称: pay_test
目标服务器对外端口号 58003
docker容器开放端口号 8080
docker镜像URL docker.amihome.cn/amihome/change/pay:14522
容器AspNetCore的环境【ASPNETCORE_ENVIRONMENT】 amisoft
Docker服务器DNS名称 docker.amihome.cn
登入Docker服务器的用户名称 gitlab-runner
登入Docker服务器的密码 [MASKED]
SSH自动登入目标服务器使用的用户名 david
SSH自动登入的目标服务器 192.168.3.202
在服务器上执行的命令是
docker run -d --privileged=true --restart=always -d --name pay_test -v /mnt/data/yee-change:/var/config -e ASPNETCORE_ENVIRONMENT=amisoft -p 58003:8080 docker.amihome.cn/amihome/change/pay:14522
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
3b3a95727c03
3b3a95727c03
Untagged: docker.amihome.cn/amihome/change/pay:14522
Untagged: docker.amihome.cn/amihome/change/pay@sha256:d6a05e53a83b42e1af48743f6642e888211d8168517a0d67310806445be24bc2
Deleted: sha256:310f94862c1cbf2e051b482a0e7d691a1684688a155435599ef10a1f04d1ac42
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Unable to find image 'docker.amihome.cn/amihome/change/pay:14522' locally
14522: Pulling from amihome/change/pay
e1caac4eb9d2: Already exists
bee002b96029: Already exists
e65deb0614ae: Already exists
31a62e83c1b2: Already exists
97d7b6e68a6e: Already exists
67c6e8d22e3d: Already exists
c165027e30dd: Already exists
f13326cb71fb: Already exists
aff76e79fb8b: Already exists
fcb9f5b2a61c: Already exists
016d03c7ecd6: Already exists
4292a4c97354: Already exists
601e06c58d4e: Already exists
89aadf10e5ac: Already exists
a86e85b0798d: Already exists
b582fea76b3d: Already exists
6878414e6223: Already exists
4f4fb700ef54: Already exists
64c1d7737677: Already exists
fd7dcc1e3d5e: Already exists
31ec24de0265: Already exists
Digest: sha256:d6a05e53a83b42e1af48743f6642e888211d8168517a0d67310806445be24bc2
Status: Downloaded newer image for docker.amihome.cn/amihome/change/pay:14522
f6d28ad569f215d33d601d94fb3545f13e3be635079c575ae20e80c6daecb61e
Saving cache for successful job 00:01
Creating cache default-protected...
WARNING: node_modules/: no matching files. Ensure that the artifact path is relative to the working directory (/builds/oEbtvPUXD/0/abp7/pay-portal) 
Archive is up to date!                             
Created cache
Cleaning up project directory and file based variables 00:00
Job succeeded
posted on 2024-02-28 18:40  终南山人  阅读(40)  评论(0编辑  收藏  举报