当前位置:网站首页>Produced by Ali! Graphical ant script - idea plug-in cloudtoolkit

Produced by Ali! Graphical ant script - idea plug-in cloudtoolkit

2022-06-21 23:15:00 InfoQ

CloudToolkit brief introduction

CloudToolkit It is a product of Ali IDEA plug-in unit , It makes it easier to automate deployment , Its built-in terminal tools and file upload function , It is very convenient even to manage the server ! This kind of IDEA Plug ins are not only powerful , And it's completely free !

install

CloudToolkit The installation of is very simple , Directly in IDEA Search in the plug-in market Cloud Toolkit Then install it .
null

Use

Next, let's experience CloudToolkit Automated deployment of , With SpringBoot The application is packaged and deployed to Docker Environment, for example , See if it works well enough .

Automated Deployment

  • When the plug-in is installed , Open the left panel , Right click Host Icon, we can add the connection information of the server , Before implementing automatic deployment, you need to configure the connection information ;
null
  • In general, if we want to deploy locally SpringBoot Applied to the Docker The environment needs to go through the following steps , Use CloudToolkit We just need to configure the process , These operations will be automatically completed for us ;
null
  • First, get ready to package the application image Dockerfile file ;
#  This image needs a dependent base image
FROM java:8
#  Set the jar Package is copied to the docker Container of / Under the table of contents
ADD mall-tiny-deploy-1.0-SNAPSHOT.jar /mall-tiny-deploy-1.0-SNAPSHOT.jar
#  Declare that the service is running at 8088 port
EXPOSE 8088
#  Appoint docker Run when container starts jar package
ENTRYPOINT ["java", "-jar","/mall-tiny-deploy-1.0-SNAPSHOT.jar"]
#  Specify the name of the maintainer
MAINTAINER macrozheng
  • When you are ready, you can automatically package the application image 、 Create and run a script for the container run.sh, For the specific use of these two scripts, please refer to use Jenkins Tips for automated deployment  ;
#!/usr/bin/env bash
#  Define the application group name
group_name='mall-tiny'
#  Define application name
app_name='mall-tiny-deploy'
#  Define the application version
app_version='1.0-SNAPSHOT'
#  Define the application environment
profile_active='prod'
echo '----copy jar----'
docker stop ${app_name}
echo '----stop container----'
docker rm ${app_name}
echo '----rm container----'
docker rmi ${group_name}/${app_name}:${app_version}
echo '----rm image----'
#  Package compilation docker Mirror image
docker build -t ${group_name}/${app_name}:${app_version} .
echo '----build image----'
docker run -p 8088:8088 --name ${app_name} \
--link mysql:db \
-e 'spring.profiles.active'=${profile_active} \
-e TZ="Asia/Shanghai" \
-v /etc/localtime:/etc/localtime \
-v /mydata/app/${app_name}/logs:/var/logs \
-d ${group_name}/${app_name}:${app_version}
echo '----start container----'
  • Upload these two files to Linux Server , to run.sh Add executable rights ;
null
  • Right click the project to be deployed , Click on Deploy to Host;
null
  • Then choose Maven packaged Jar Upload the package to the specified directory , Execute after uploading run.sh Script ;
null
  • Next edit Maven The goal of construction , Pack only mall-tiny-deploy The module can ;
null
  • Then modify the advanced settings , Configure the command to view the container log ;
null
  • Finally, run the configuration , After running, you can directly view the application running log ;
null
  • Open the app's Swagger Page view , It's found that it can be accessed normally , Access address :http://192.168.3.105:8088/swagger-ui/
null

Common functions

  • Of course CloudToolkit It's more than that , It has built-in terminal tools , stay IDEA In the management Linux The server , Just use it , Directly through the bottom panel , Click the terminal button to open ;
null
  • Experienced this terminal tool , The tips are quite comprehensive , What else do you want Xshell?
null
  • You can upload files through the upload function ,WinSCP There's no need to !
null

summary

Experienced a handful of products from Alibaba CloudToolkit, After configuration , It can basically realize one click deployment of applications to remote servers , Say it is IDEA Version of Jenkins Too much ! Its built-in terminal tools are also very easy to use , It is highly recommended that you try a wave !

Project source address

https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-deploy
source :https://mp.weixin.qq.com/s/-VVakojVBoYxorccSTaCSQ
原网站

版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212052459008.html