The AntDeploy tool releases the image to Tencent Cloud Docker private mirror warehouse with one click

Introduction to AntDeploy Tool Function

  • Support docker one-click deployment (support netcore)
  • Support iis one-click deployment (support netcore and framework)
  • Support one-click deployment of windows services (support netcore and framework)
  • Support one-click deployment of linux services (support netcore)
  • (Support incremental release) (support one-click rollback) (support ignition) (support select specific file release) (support view release records)
  • Support independent use from Visual Studio (cross-platform support windows system and mac system)
  • Support Agent batch update

Resource address:

Use AntDeploy to make an image and upload Tencent Cloud private image warehouse with one click

1. Demonstration environment description:

  • Operating system: Windows 10 Professional Workstation Edition x64, kernel version number 2004

  • Microsoft Visual Studio Enterprise 2019 版本 16.8.2

  • Install ubuntu-20.04 virtual machine on local Hyper-V (operate vm terminal vs code)

  •  AntDeploy offline version Version: 7.28

 Precautions:

  1. Ensure that the locally configured vm can access the external network and communicate with the host, check the network tools=》# sudo apt install net-tools
  2. Make sure vm install docker=》# sudo apt update & sudo apt install docker.io
  3. Make sure vm install unzip=》# sudo apt install unzip
  4. vs code install plug-in (optional configuration: Remote-WSL, Docker), connect to vm via ssh =》# ssh [email protected] prompt for the password

 vm install docker to configure domestic mirror source:

1. View the IP address of Ubuntu

ifconfig

2. After execution, the service function of this item may not be installed. Follow the prompts to execute and install network tools

sudo apt install net-tools

After installation, when trying to connect through the vs code/pwsh ssh remote tool, I found that the connection failed.

At this point, check the port of Ubuntu about 22, and execute the command as follows

netstat -ntlp|grep 22
    参数解释:
    -n  不以进程的服务名称,以端口号(port number)显示
	-t  列出tcp网络封包的信息
	-l  列出目前正在网络监听(listen)服务
	-p  列出该网络服务的进程

If you find that there is no process content on port 22 at this time, execute the following command

#安装openssh-server
sudo apt install openssh-server
#安装ufw防火墙
sudo apt install ufw
#启动ufw防火墙
sudo ufw enable
#ufw开发22端口
sudo ufw allow 22
  • After docker is installed in the vm, the non-root account is authorized to use it. The configuration steps are as follows:

1. Create a docker group

sudo groupadd docker

2. Add the current user to the docker group

sudo gpasswd -a ${USER} docker

3. Restart the docker service

sudo service docker restart或sudo systemctl restart docker

4. The current user logs out of the system and logs in again

# su root
# su chait 

5. Run the docker command to see if it can be used

docker ps 或 docker images

  

If it fails, you can restart the vm and test again.

Restart command: 

  1. reboot 
  2. shutdown -r now restart immediately
  3. shutdown -r 10 Automatic restart after 10 minutes
  4. shutdown -r 20:35 restart at 20:35

Shutdown command: 

  1. halt shuts down immediately (usually add -p to turn off the power)
  2. poweroff shuts down immediately 
  3. shutdown -h now shutdown immediately
  4. shutdown -h 10 Automatic shutdown after 10 minutes 

    If the shutdown is set by the shutdown command, you can use the shutdown -c command to cancel the shutdown.

2. AntDeploy image production:

2|1 Prepare .net5 related mirrors, downloading mirrors in China may fail due to network reasons:

Featured Repos

 Just pull the mirrors as needed, and only the following mirrors are needed for the demonstration here: .NET SDK & ASP.NET Core Runtime

#5.0 (Current)
#5.0 ASP.NET Core Runtime
docker pull mcr.microsoft.com/dotnet/aspnet:5.0
docker pull mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim

#5.0 .NET SDK
docker pull mcr.microsoft.com/dotnet/sdk:5.0-buster-slim

 Tencent Cloud Platform prepares a Docker private image warehouse to ensure that the vm and host can be logged in and accessed normally:

#登录腾讯云docker registry
sudo docker login --username=[user] ccr.ccs.tencentyun.com
#提示输入对应的密码即可

#从registry拉取镜像
sudo docker pull ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069:[tag]

#将镜像推送到registry
sudo docker login --username=[user] ccr.ccs.tencentyun.com
sudo docker tag [ImageId] ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069:[tag]
sudo docker push ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069:[tag]

 Tencent cloud platform Docker private mirror warehouse has prepared the following mirrors:

When pulling the mirror locally, you can configure the domestic mirror source:

Download the image from the local Windows PowerShell/PowerShell, now install a Docker for Windows client tool on the machine, and then configure the image source address:

2|2To achieve the goal:

  • Use vs2019 to create the corresponding b/s application, here is [NetService-Jwt];
  • Use AntDeploy tool to make one-click image (application image based on .net5) and publish it to Tencent's docker private image warehouse;
  • Deployment preparation, Tencent Cloud TKE (based on k8s) platform pulls images from private image warehouses to implement resource deployment;

1. Configure AntDeploy.json, and get the following configuration information after the interface operation tool is configured;

{
  "Env": [
    {
      "Name": "docker-ubuntu-20.04",
      "ServerList": [],
      "LinuxServerList": [
        {
          "UserName": "chait",
          "Pwd": "35FE3BA71BD99AF92DB2A32F980ECDAE",
          "Host": "172.29.161.146",
          "NickName": "docker",
          "IIsFireUrl": null,
          "DockerFireUrl": "",
          "WindowsServiceFireUrl": null,
          "LinuxServiceFireUrl": null
        }
      ],
      "IgnoreList": [],
      "WindowsBackUpIgnoreList": []
    }
  ],
  "IIsConfig": {
    "SdkType": null,
    "WebSiteName": "",
    "LastEnvName": null,
    "EnvPairList": [
      {
        "EnvName": "docker-ubuntu-20.04",
        "ConfigName": "",
        "LinuxEnvParam": null,
        "DockerPort": null,
        "DockerEnvName": null,
        "DockerVolume": null,
        "DockerOther": null
      }
    ]
  },
  "WindowsServiveConfig": {
    "ServiceName": "",
    "SdkType": null,
    "LastEnvName": null,
    "EnvPairList": [
      {
        "EnvName": "docker-ubuntu-20.04",
        "ConfigName": "",
        "LinuxEnvParam": null,
        "DockerPort": null,
        "DockerEnvName": null,
        "DockerVolume": null,
        "DockerOther": null
      }
    ]
  },
  "LinuxServiveConfig": {
    "ServiceName": "",
    "EnvParam": "",
    "LastEnvName": null,
    "EnvPairList": [
      {
        "EnvName": "docker-ubuntu-20.04",
        "ConfigName": "",
        "LinuxEnvParam": null,
        "DockerPort": null,
        "DockerEnvName": null,
        "DockerVolume": null,
        "DockerOther": null
      }
    ]
  },
  "DockerConfig": {
    "Prot": "",
    "AspNetCoreEnv": "",
    "LastEnvName": "docker-ubuntu-20.04",
    "RemoveDaysFromPublished": "10",
    "Volume": "",
    "Other": "",
    "EnvPairList": [
      {
        "EnvName": "docker-ubuntu-20.04",
        "ConfigName": null,
        "LinuxEnvParam": null,
        "DockerPort": "",
        "DockerEnvName": "",
        "DockerVolume": "",
        "DockerOther": ""
      }
    ]
  }
}

2. Add the Dockerfile file to the project, right-click on vs2019 and select [Add] = "[Docker Support] to select the Linux platform

The local vm downloads the basic image related to .net5 in advance, and prepares the basic image information as follows:

Modify the Dockerfile file created by default, and set the file attribute in vs 2019 to [Always assign value]. If you do not write a Dockerfile file here, the tool will generate one by default;

At this point, the basic environment is ready, and then we use the offline version of the AntDeploy tool (V7.28) to select the corresponding project .csproj file, configure access to the vm communication test Ok, and then configure the Tencent Cloud Docker private mirror warehouse and click one-click release. finished.

 

 Pay attention to fill in the name of the private mirror warehouse here, here to spit out the basic information description of Tencent Cloud (the expression is misleading)

 

 

 Complete release log information: release the tool version AntDeploy-v7.29, the Dcokerfile file that builds the image is affected by comments, and needs to be optimized later;

16:24:39|INFO|The Porject ENTRYPOINT name:NetServices.Jwt.dll,DotNetSDK.Version:5.0  
16:24:39|INFO|-----------------Start publish[Ver:7.29]-----------------  
16:24:39|INFO|CurrentProjectFolder:  file://G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt#link3
16:24:39|INFO|current project Path:G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\NetServices.Jwt.csproj  
16:24:39|INFO|dotnet publish "G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\NetServices.Jwt.csproj" -c Release -o "G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\deploy_docker\docker-ubuntu-20.04\"  
16:24:39|INFO|Copyright (C) Microsoft Corporation. All rights reserved.  
16:24:40|INFO|  Determining projects to restore...  
16:24:40|INFO|  Determining projects to restore...  
16:24:42|INFO|  All projects are up-to-date for restore.  
16:24:42|INFO|  All projects are up-to-date for restore.  
16:24:43|INFO|  NetServices.Helper.Cache -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Cache\bin\Release\net5.0\NetServices.Helper.Cache.dll  
16:24:43|INFO|  NetServices.Helper.RabbitMQ -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.RabbitMQ\bin\Release\net5.0\NetServices.Helper.RabbitMQ.dll  
16:24:43|INFO|  NetServices.Helper.RabbitMQ -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.RabbitMQ\bin\Release\net5.0\NetServices.Helper.RabbitMQ.dll  
16:24:43|INFO|  NetServices.Helper.Base -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Base\bin\Release\net5.0\NetServices.Helper.Base.dll  
16:24:43|INFO|  NetServices.Helper.Base -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Base\bin\Release\net5.0\NetServices.Helper.Base.dll  
16:24:43|INFO|  NetServices.Helper.RestTemplate -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.RestTemplate\bin\Release\net5.0\NetServices.Helper.RestTemplate.dll  
16:24:43|INFO|  NetServices.Helper.RestTemplate -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.RestTemplate\bin\Release\net5.0\NetServices.Helper.RestTemplate.dll  
16:24:44|INFO|  NetServices.Helper.Database -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Database\bin\Release\net5.0\NetServices.Helper.Database.dll  
16:24:44|INFO|  NetServices.Helper.Database -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Database\bin\Release\net5.0\NetServices.Helper.Database.dll  
16:24:44|INFO|  NetServices.Helper.Log -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Log\bin\Release\net5.0\NetServices.Helper.Log.dll  
16:24:44|INFO|  NetServices.Helper.Log -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Helper.Log\bin\Release\net5.0\NetServices.Helper.Log.dll  
16:24:45|INFO|  NetServices.Jwt -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\net5.0\NetServices.Jwt.dll  
16:24:45|INFO|  NetServices.Jwt -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\net5.0\NetServices.Jwt.dll  
16:24:46|INFO|  NetServices.Jwt -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\deploy_docker\docker-ubuntu-20.04\  
16:24:46|INFO|  NetServices.Jwt -> G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\deploy_docker\docker-ubuntu-20.04\  
16:24:46|INFO|publish success  ==>   file://G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\deploy_docker\docker-ubuntu-20.04#link26
16:24:46|INFO|-----------------Start package-----------------  
16:24:46|INFO|package ignoreList Count:0  
16:24:46|INFO|Find Dockerfile In Package: Dockerfile  
16:24:49|INFO|package success,package size:14M  
16:24:49|INFO|-----------------Deploy Start-----------------  
16:24:49|INFO|【Server】ssh connecting 172.27.94.126...   
16:24:50|INFO|【Server】Connected to [email protected]:22 via SSH  
16:24:50|INFO|【Server】Changed directory to antdeploy/netservicesjwt/20201214162449/  
16:24:50|INFO|【Server】uploaded 9 %  
16:24:50|INFO|【Server】uploaded 21 %  
16:24:50|INFO|【Server】uploaded 32 %  
16:24:51|INFO|【Server】uploaded 44 %  
16:24:51|INFO|【Server】uploaded 59 %  
16:24:51|INFO|【Server】uploaded 71 %  
16:24:51|INFO|【Server】uploaded 83 %  
16:24:51|INFO|【Server】uploaded 94 %  
16:24:51|INFO|【Server】uploaded 100 %  
16:24:52|INFO|【Server】unzip -o -q antdeploy/netservicesjwt/20201214162449/publish.zip -d publish/  
16:24:52|INFO|【Server】unzip success: antdeploy/netservicesjwt/20201214162449/publish/  
16:24:52|INFO|【Server】Start Copy Files From [antdeploy/netservicesjwt/20201214162449/publish/] To [antdeploy/netservicesjwt/deploy/]  
16:24:52|INFO|【Server】Success Copy Files From [antdeploy/netservicesjwt/20201214162449/publish/] To [antdeploy/netservicesjwt/deploy/]  
16:24:52|INFO|【Server】Changed directory to antdeploy/netservicesjwt/deploy/  
16:24:52|WARN|【Server】Volume in dockerFile is not defined  
16:24:52|WARN|【Server】Docker Run Other Args in dockerFile is not defined  
16:24:52|INFO|【Server】Add EXPOSE 5000 to dockerFile  : 【antdeploy/netservicesjwt/deploy/Dockerfile】  
16:24:52|INFO|【Server】Update DockerFile 【 \cp -rf antdeploy/netservicesjwt/deploy/Dockerfile antdeploy/netservicesjwt/20201214162449/publish/】  
16:24:52|WARN|【Server】--name in Other Args is not defined  
16:24:52|INFO|【Server】 docker build --no-cache --rm -t netservicesjwt:20201214162449 -f antdeploy/netservicesjwt/deploy/Dockerfile antdeploy/netservicesjwt/deploy/   
16:24:53|INFO|【Server】Sending build context to Docker daemon  43.74MB  
16:24:53|INFO|【Server】Step 1/6 : FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim  
16:24:53|INFO|【Server】 ---> 1ad38cdee8b3  
16:24:53|INFO|【Server】Step 2/6 : COPY . /publish  
16:24:57|INFO|【Server】 ---> 89c1e9311f25  
16:24:57|INFO|【Server】Step 3/6 : WORKDIR /publish  
16:24:58|INFO|【Server】 ---> Running in ce10c33d6846  
16:25:00|INFO|【Server】Removing intermediate container ce10c33d6846  
16:25:00|INFO|【Server】 ---> ab9847d605e3  
16:25:00|INFO|【Server】Step 4/6 : EXPOSE 8002  
16:25:02|INFO|【Server】 ---> Running in e8411eb8a13e  
16:25:03|INFO|【Server】Removing intermediate container e8411eb8a13e  
16:25:03|INFO|【Server】 ---> c2e707157198  
16:25:03|INFO|【Server】Step 5/6 : EXPOSE 5000  
16:25:05|INFO|【Server】 ---> Running in 38a502ae6f0b  
16:25:07|INFO|【Server】Removing intermediate container 38a502ae6f0b  
16:25:07|INFO|【Server】 ---> ae6797201035  
16:25:07|INFO|【Server】Step 6/6 : ENTRYPOINT ["dotnet", "NetServices.Jwt.dll"]  
16:25:08|INFO|【Server】 ---> Running in b10cbf0cad95  
16:25:10|INFO|【Server】Removing intermediate container b10cbf0cad95  
16:25:10|INFO|【Server】 ---> 8eb53a301a0f  
16:25:10|INFO|【Server】Successfully built 8eb53a301a0f  
16:25:11|INFO|【Server】Successfully tagged netservicesjwt:20201214162449  
16:25:11|WARN|【Server】ignore docker run  
16:25:11|WARN|【Server】[upload image] - set -e; docker login -u [user] -p [pwd] ccr.ccs.tencentyun.com;  docker tag 8eb53a301a0f ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069:jwt-v1.0.0; docker push ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069:jwt-v1.0.0  
16:25:11|WARN|【Server】[upload image] - Login Succeeded  
16:25:12|WARN|【Server】[upload image] - The push refers to repository [ccr.ccs.tencentyun.com/sws-center-ol-service-dev/rg-sws-center-ol-dev-2069]  
16:25:12|WARN|【Server】[upload image] - 04b1dc15379b: Preparing  
16:25:12|WARN|【Server】[upload image] - 064d1568f66a: Preparing  
16:25:12|WARN|【Server】[upload image] - 8c8ce230525b: Preparing  
16:25:12|WARN|【Server】[upload image] - ac1439b965df: Preparing  
16:25:12|WARN|【Server】[upload image] - b22af9287e60: Preparing  
16:25:12|WARN|【Server】[upload image] - f5600c6330da: Preparing  
16:25:12|WARN|【Server】[upload image] - f5600c6330da: Waiting  
16:25:12|WARN|【Server】[upload image] - 8c8ce230525b:   
16:25:12|WARN|【Server】[upload image] - Layer already exists  
16:25:12|WARN|【Server】[upload image] - 064d1568f66a:   
16:25:12|WARN|【Server】[upload image] - Layer already exists  
16:25:12|WARN|【Server】[upload image] - b22af9287e60:   
16:25:12|WARN|【Server】[upload image] - Layer already exists  
16:25:13|WARN|【Server】[upload image] - ac1439b965df:   
16:25:13|WARN|【Server】[upload image] - Layer already exists  
16:25:13|WARN|【Server】[upload image] - f5600c6330da:   
16:25:13|WARN|【Server】[upload image] - Layer already exists  
16:25:18|WARN|【Server】[upload image] - 04b1dc15379b:   
16:25:18|WARN|【Server】[upload image] - Pushed  
16:25:21|WARN|【Server】[upload image] - jwt-v1.0.0: digest: sha256:1c165fdc9dbd311692000812771e39c97397dee747001887b032ad127abe05c5 size: 1583  
16:25:21|INFO|【Server】[upload image] - Success  
16:25:21|INFO|publish Host: 172.27.94.126【docker】 End  
16:25:21|INFO|Deploy Version:20201214162449  
16:25:21|INFO|local publish folder  ==>   file://G:\SvnProject\HCIMS_V3.1_Online\Project\Services\SwsXytxMsServices\branches\v1.0\NetServices.Jwt\bin\Release\deploy_docker\docker-ubuntu-20.04#link105
16:25:21|INFO|-----------------Deploy End,[Total]:1,[Fail]:0-----------------  

Finally, check the private mirror warehouse of Tencent Cloud Platform, the display information is as follows:

These are the complete release build mirroring process, there is little help to welcome partners like to share, here Thank you very much original creator tool wing pointing to communicate!

Guess you like

Origin blog.csdn.net/ChaITSimpleLove/article/details/110647146
Recommended