Ali produced — SpringBoot application automation deployment artifact, IDEA version of Jenkins

Friends, Xiaoyeqiu recently discovered an [IDEA plug-]CloudToolkit in produced by Ali , which not only supports direct packaging and deployment of applications to remote servers, but also can be used as a terminal tool. I tried this plugin, it’s very good, I recommend it to everyone! With this plug-in installed, IDEA one-stop development is one step closer!

Introduction to CloudToolkit

CloudToolkitIt is an IDEA plug-in produced by Ali. Through it, we can realize automatic deployment more conveniently. Its built-in terminal tool and file upload function are very convenient even for server management! Not only is this IDEA plugin powerful, it’s completely free!

Install

The installation of CloudToolkit is very simple, just search Cloud Toolkitand install it in IDEA’s plug-in market.

use

Next, let’s experience the automatic deployment function of CloudToolkit, take SpringBoot application package and deploy to [Docker] environment as an example, to see if it is good enough.

Automated deployment

  • First, prepare the Dockerfile file required to package the application image; 

# The image needs to depend on the base image 
FROM  java:8 
# Copy the jar package in the current directory to the / directory of the docker container 
ADD  mall-tiny-deploy-1.0-SNAPSHOT.jar /mall-tiny-deploy-1.0-SNAPSHOT .jar 
# Declare the service to run on port 8088 
EXPOSE  8088 
# Specify the jar package to run when the docker container starts 
ENTRYPOINT  ["java", "-jar","/mall-tiny-deploy-1.0-SNAPSHOT.jar"] 
# Specify the maintainer Name 
MAINTAINER  YEQIU

Then prepare the scripts that can automatically package the application image, create and run the container. run.shFor the specific use of these two scripts, please refer to the skills of using Jenkins for automated deployment  ;

#!/usr/bin/env bash 
# Define the application group name 
group_name= 'mall-tiny' 
# Define the 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 and compile the docker 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 the Linux server and run.shadd executable permissions;

Right-click the project to be deployed and click Deploy to Host;

Then choose to upload the Jar package packaged by Maven to the specified directory, and execute the run.shscript after the upload is complete;

Next, edit the goal of the Maven build, just package the mall-tiny-deploymodule;

Then modify the advanced settings and configure the command to view the container log;

Finally, run the configuration, and you can directly view the application operation log after the operation is completed;

Open the Swagger page of the application and see that it can be accessed normally. The access address is: http://192.168.3.105:8088/swagger-ui/

Common Functions

Summarize
---------

I have experienced a CloudToolkit produced by Alibaba. After the configuration is done, it is basically possible to deploy applications to remote servers with one click. It is not an exaggeration to say that it is the IDEA version of [Jenkins] ! Its built-in terminal tool is also very easy to use, and it is strongly recommended that you try it out!

> Project source code address
> ---------------------------
> 
> https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-deploy

Code text is not easy, just click to follow and one-click three collections, and those who don’t understand can scan the code to get learning materials~~

Leave a Comment

Your email address will not be published. Required fields are marked *