本篇演示环境:
本篇应用目标:
项目名称取名: testimage
选择模板: Web应用程序
创建完成 如下图:
安装了AntDeploy插件后 点击右键 找到 AntDeploy
点击 AntDeploy 出现
配置AntDeploy【只需要首次配置】
点击发布配置
AntDeploy的配置说明:一个环境对应多台服务器
创建1个环境 取名叫 test 点击 添加环境按钮
然后在 test 环境下 添加linux服务器
选择 Docker发布, 选择我们刚刚创建的环境 test
选择 配置镜像上传 填写阿里云容器镜像服务的参数
因为我们是测试,没有在项目里面添加Dockerfile 那么AntDeploy会创建默认的Dockfile 默认的Dockefile内容会在 发布日志里面进行展示
点击 发布进行一键制作 docker image 并且上传到阿里镜像仓库
完成进度展示:
发布日志非常详细:
11:54:11|INFO|The Porject ENTRYPOINT name:testimage.dll,DotNetSDK.Version:2.2
11:54:11|INFO|-----------------Start publish[Ver:7.10]-----------------
11:54:11|INFO|Visual Studio Version : 16.0
11:54:11|INFO|CurrentProjectFolder: file://C:\Users\Administrator\source\repos\testimage\testimage#link4
11:54:11|INFO|current project Path:C:\Users\Administrator\source\repos\testimage\testimage\testimage.csproj
11:54:11|INFO|dotnet publish "C:\Users\Administrator\source\repos\testimage\testimage\testimage.csproj" -c Release -o "C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test\"
11:54:12|INFO|版权所有(C) Microsoft Corporation。保留所有权利。
11:54:12|INFO| C:\Users\Administrator\source\repos\testimage\testimage\testimage.csproj 的还原在 44.05 ms 内完成。
11:54:12|INFO| C:\Users\Administrator\source\repos\testimage\testimage\testimage.csproj 的还原在 44.05 ms 内完成。
11:54:15|INFO| testimage -> C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\netcoreapp2.2\testimage.dll
11:54:15|INFO| testimage -> C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\netcoreapp2.2\testimage.Views.dll
11:54:15|INFO| testimage -> C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\netcoreapp2.2\testimage.Views.dll
11:54:15|INFO| testimage -> C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test\
11:54:16|INFO| testimage -> C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test\
11:54:16|INFO|publish success ==> file://C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test#link15
11:54:16|INFO|-----------------Start package-----------------
11:54:16|INFO|package ignoreList Count:0
11:54:16|INFO|package success,package size:<1M
11:54:16|INFO|-----------------Deploy Start-----------------
11:54:16|INFO|【Server】ssh connecting 192.168.159.135...
11:54:26|INFO|【Server】Connected to root@192.168.159.135:22 via SSH
11:54:26|INFO|【Server】Changed directory to antdeploy/testimage/20200308115416/
11:54:26|INFO|【Server】uploaded 100 %
11:54:27|INFO|【Server】unzip -o -q antdeploy/testimage/20200308115416/publish.zip -d publish/
11:54:27|INFO|【Server】unzip success: antdeploy/testimage/20200308115416/publish/
11:54:27|INFO|【Server】dockerFile not found in: [antdeploy/testimage/20200308115416/publish/Dockerfile],will create default Dockerfile!
11:54:27|INFO|【Server】create docker file: antdeploy/testimage/20200308115416/publish/Dockerfile
11:54:27|INFO|【Server】FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
11:54:27|INFO|【Server】COPY . /publish
11:54:27|INFO|【Server】WORKDIR /publish
11:54:27|INFO|【Server】ENV ASPNETCORE_URLS=http://*:5000
11:54:27|INFO|【Server】EXPOSE 5000
11:54:27|INFO|【Server】ENTRYPOINT ["dotnet", "testimage.dll"]
11:54:27|INFO|【Server】create docker file success: antdeploy/testimage/20200308115416/publish/Dockerfile
11:54:27|INFO|【Server】Start Copy Files From [antdeploy/testimage/20200308115416/publish/] To [antdeploy/testimage/deploy/]
11:54:27|INFO|【Server】Success Copy Files From [antdeploy/testimage/20200308115416/publish/] To [antdeploy/testimage/deploy/]
11:54:27|INFO|【Server】Changed directory to antdeploy/testimage/deploy/
11:54:27|INFO|【Server】docker build --no-cache --rm -t testimage:20200308115416 -f antdeploy/testimage/deploy/Dockerfile antdeploy/testimage/deploy/
11:54:27|INFO|【Server】Sending build context to Docker daemon 4.688MB
11:54:27|INFO|【Server】Step 1/6 : FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
11:54:27|INFO|【Server】 ---> e7e3b238011c
11:54:27|INFO|【Server】Step 2/6 : COPY . /publish
11:54:27|INFO|【Server】 ---> 77f1a71e747e
11:54:27|INFO|【Server】Step 3/6 : WORKDIR /publish
11:54:27|INFO|【Server】 ---> Running in 0488ac2f9d34
11:54:27|INFO|【Server】Removing intermediate container 0488ac2f9d34
11:54:27|INFO|【Server】 ---> 52cace207336
11:54:27|INFO|【Server】Step 4/6 : ENV ASPNETCORE_URLS=http://*:5000
11:54:27|INFO|【Server】 ---> Running in 6002963328d2
11:54:28|INFO|【Server】Removing intermediate container 6002963328d2
11:54:28|INFO|【Server】 ---> 30ef31b36b85
11:54:28|INFO|【Server】Step 5/6 : EXPOSE 5000
11:54:28|INFO|【Server】 ---> Running in 76a1ba895e97
11:54:28|INFO|【Server】Removing intermediate container 76a1ba895e97
11:54:28|INFO|【Server】 ---> a0be298ccf70
11:54:28|INFO|【Server】Step 6/6 : ENTRYPOINT ["dotnet", "testimage.dll"]
11:54:28|INFO|【Server】 ---> Running in c81d0ec0a693
11:54:28|INFO|【Server】Removing intermediate container c81d0ec0a693
11:54:28|INFO|【Server】 ---> 1c1fa6c51b6e
11:54:28|INFO|【Server】Successfully built 1c1fa6c51b6e
11:54:28|INFO|【Server】Successfully tagged testimage:20200308115416
11:54:28|WARN|【Server】ignore docker run
11:54:28|WARN|【Server】[upload image] - Login Succeeded
11:54:28|WARN|【Server】[upload image] - The push refers to repository [registry.cn-hangzhou.aliyuncs.com/lito/testimage]
11:54:28|WARN|【Server】[upload image] - a3dea8cda1bb: Preparing
11:54:28|WARN|【Server】[upload image] - 579a8f1d6a12: Preparing
11:54:28|WARN|【Server】[upload image] - 15e45d99c926: Preparing
11:54:28|WARN|【Server】[upload image] - 0cf75cb98eb2: Preparing
11:54:28|WARN|【Server】[upload image] - 814c70fdae62: Preparing
11:54:31|WARN|【Server】[upload image] - 0cf75cb98eb2: Mounted from lito/spa
11:54:31|WARN|【Server】[upload image] - 814c70fdae62: Mounted from lito/spa
11:54:31|WARN|【Server】[upload image] - 15e45d99c926: Mounted from lito/spa
11:54:31|WARN|【Server】[upload image] - 579a8f1d6a12: Mounted from lito/spa
11:54:32|WARN|【Server】[upload image] - a3dea8cda1bb: Pushed
11:54:34|WARN|【Server】[upload image] - 20200308115416: digest: sha256:892c1994a969fcc613d300590754bb8ddee0fb8f75e9614a097a7f482fa5d38e size: 1374
11:54:34|INFO|【Server】[upload image] - Success
11:54:34|INFO|publish Host: 192.168.159.135【centos】 End
11:54:34|INFO|Deploy Version:20200308115416
11:54:34|INFO|local publish folder ==> file://C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test#link79
11:54:34|INFO|-----------------Deploy End,[Total]:1,[Fail]:0-----------------
11:54:34|INFO|【Deploy log】 ==> file://C:\Users\Administrator\source\repos\testimage\testimage\bin\Release\deploy_docker\test_deploy_logs\20200308115416.log#link81
从日志里面可以看到,docker image被成功的上传了
在阿里云镜像仓库可以查到
原文:https://www.cnblogs.com/yudongdong/p/12441855.html