L'outil AntDeploy publie l'image dans l'entrepôt de miroir privé Tencent Cloud Docker en un seul clic

Introduction à la fonction de l'outil AntDeploy

  • Prise en charge du déploiement en un clic de docker (prise en charge de netcore)
  • Prise en charge du déploiement en un clic iis (prise en charge de netcore et du framework)
  • Prise en charge du déploiement en un clic des services Windows (prise en charge de netcore et du framework)
  • Prise en charge du déploiement en un clic des services Linux (prise en charge de netcore)
  • (Prise en charge de la version incrémentielle) (prise en charge de la restauration en un clic) (prise en charge de l'allumage) (prise en charge de la version de fichier spécifique sélectionnée) (prise en charge des enregistrements de version de vue)
  • Prise en charge de l'utilisation indépendante de Visual Studio (prise en charge multiplateforme du système Windows et du système Mac)
  • Mise à jour par lots de l'agent de support

Adresse de la ressource:

Utilisez AntDeploy pour créer une image et télécharger l'entrepôt d'images privé Tencent Cloud en un seul clic

1. Description de l'environnement de démonstration:

  • Système d'exploitation: Windows 10 Professional Workstation Edition x64, numéro de version du noyau 2004

  • Microsoft Visual Studio Entreprise 2019 版本 16.8.2

  • Installez la machine virtuelle ubuntu-20.04 sur Hyper-V local (utilisez le terminal VM vs le code)

  •  AntDeploy version hors ligne Version: 7.28

 Précautions:

  1. Assurez-vous que la machine virtuelle configurée localement peut accéder au réseau externe et communiquer avec l'hôte, vérifiez les outils réseau =》 # sudo apt install net-tools
  2. Assurez-vous que vm install docker =》 # sudo apt update & sudo apt install docker.io
  3. Assurez-vous que vm install unzip =》 # sudo apt install unzip
  4. vs code install plug-in (configuration facultative: Remote-WSL, Docker), connectez-vous à vm via ssh =》 # ssh [email protected] invite pour le mot de passe

 vm install docker pour configurer la source du miroir domestique:

1. Affichez l'adresse IP d'Ubuntu

ifconfig

2. Après l'exécution, la fonction de service de cet élément peut ne pas être installée. Suivez les invites pour exécuter et installer les outils réseau.

sudo apt install net-tools

Après l'installation, en essayant de me connecter via l'outil distant vs code / pwsh ssh, j'ai constaté que la connexion avait échoué.

À ce stade, vérifiez le port d'Ubuntu sur 22 et exécutez la commande comme suit

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

Si vous constatez qu'il n'y a pas de contenu de processus sur le port 22 pour le moment, exécutez la commande suivante

#安装openssh-server
sudo apt install openssh-server
#安装ufw防火墙
sudo apt install ufw
#启动ufw防火墙
sudo ufw enable
#ufw开发22端口
sudo ufw allow 22
  • Une fois docker installé dans la machine virtuelle, le compte non root est autorisé à l'utiliser. Les étapes de configuration sont les suivantes:

1. Créez un groupe de menus fixes

sudo groupadd docker

2. Ajoutez l'utilisateur actuel au groupe Docker

sudo gpasswd -a ${USER} docker

3. Redémarrez le service Docker

sudo service docker restart或sudo systemctl restart docker

4. L'utilisateur actuel se déconnecte du système et se reconnecte

# su root
# su chait 

5. Exécutez la commande docker pour voir si elle peut être utilisée

docker ps 或 docker images

  

En cas d'échec, vous pouvez redémarrer la machine virtuelle et tester à nouveau.

Commande de redémarrage: 

  1. redémarrer 
  2. shutdown -r redémarre maintenant immédiatement
  3. shutdown -r 10 Redémarrage automatique après 10 minutes
  4. shutdown -r 20:35 redémarrage à 20:35

Commande d'arrêt: 

  1. halt s'arrête immédiatement (ajoutez généralement -p pour éteindre l'alimentation)
  2. la mise hors tension s'arrête immédiatement 
  3. shutdown -h maintenant arrêter immédiatement
  4. shutdown -h 10 Arrêt automatique après 10 minutes 

    Si l'arrêt est défini par la commande shutdown, vous pouvez utiliser la commande shutdown -c pour annuler l'arrêt.

2. Production d'images AntDeploy:

2 | 1 Préparez les miroirs liés à .net5, le téléchargement des miroirs en Chine peut échouer pour des raisons de réseau:

Repos en vedette

 Tirez simplement les miroirs selon vos besoins, et seuls les miroirs suivants sont nécessaires pour la démonstration ici: .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 prépare un entrepôt d'images privées Docker pour garantir que la machine virtuelle et l'hôte peuvent être connectés et accédés normalement:

#登录腾讯云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]

 L'entrepôt de miroirs privés Docker de la plateforme cloud Tencent a préparé les miroirs suivants:

Lorsque vous tirez le miroir localement, vous pouvez configurer la source du miroir domestique:

Téléchargez l'image à partir de Windows PowerShell / PowerShell local, installez maintenant un outil client Docker pour Windows sur l'ordinateur, puis configurez l'adresse source de l'image:

2 | 2 Pour atteindre l'objectif:

  • Utilisez vs2019 pour créer l'application b / s correspondante, voici [NetService-Jwt];
  • Utilisez l'outil AntDeploy pour créer une image en un clic (image d'application basée sur .net5) et la publier dans l'entrepôt d'images privées docker de Tencent;
  • Préparation du déploiement, la plate-forme Tencent Cloud TKE (basée sur k8s) extrait les images des entrepôts d'images privés pour mettre en œuvre le déploiement des ressources;

1. Configurez AntDeploy.json et obtenez les informations de configuration suivantes une fois l'outil d'opération d'interface configuré;

{
  "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. Ajoutez le fichier Dockerfile au projet, faites un clic droit sur vs2019 et sélectionnez [Add] = "[Docker Support] pour sélectionner la plate-forme Linux

La machine virtuelle locale télécharge à l'avance l'image de base liée à .net5 et prépare les informations d'image de base comme suit:

Modifiez le fichier Dockerfile créé par défaut et définissez l'attribut de fichier dans vs 2019 sur [Toujours attribuer une valeur]. Si vous n'écrivez pas de fichier Dockerfile ici, l'outil en générera un par défaut;

À ce stade, l'environnement de base est prêt, puis nous utilisons la version hors ligne de l'outil AntDeploy (V7.28) pour sélectionner le fichier .csproj du projet correspondant, configurer l'accès au test de communication vm Ok, puis configurer le cloud Tencent Entrepôt de miroir privé Docker et cliquez sur la version en un clic. Terminé.

 

 Faites attention à remplir le nom de l'entrepôt de miroirs privés ici, ici pour cracher la description des informations de base de Tencent Cloud (l'expression est trompeuse)

 

 

 Informations complètes du journal de publication: publiez la version de l'outil AntDeploy-v7.29, le fichier Dcokerfile qui construit l'image est affecté par les commentaires et doit être optimisé ultérieurement;

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-----------------  

Enfin, vérifiez l'entrepôt de miroirs privés de Tencent Cloud Platform, les informations d'affichage sont les suivantes:

Ce qui précède est la version complète et la construction du processus de mise en miroir. Toute personne utile est la bienvenue pour aimer et partager. Ici, je remercie aussi sincèrement les créateurs des outils pour leurs suggestions et échanges!

Je suppose que tu aimes

Origine blog.csdn.net/ChaITSimpleLove/article/details/110647146
conseillé
Classement