This topic describes how to use the command-line interface (CLI) to create and deploy an application based on a deployment package. The Java sample program provided by Web App Service (Web+) is used as an example.
Prerequisites
Step 1: Download and install the command-line tool
In Linux or macOS, run the following command to download and install the CLI:
eval "$(curl -s -L https://webplus-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/cli/install.sh)"
Step 2: Configure the command-line tool
Run the following command to use the AccessKey ID and AccessKey secret of your account to register and configure the CLI, select the region where the environment resides, and then create a folder, for example, named demo:
wpctl configure --access-key-id "$ALICLOUD_ACCESS_KEY" --access-key-secret "$ALICLOUD_SECRET_KEY" --region "$ALICLOUD_REGION" --profile demo
Step 3: Clone the Java sample program
Run the following command to clone the sample program provided by Web+ to the root directory of your project.
If you want to use your own Java program, replace the URL of the sample program in the following command with that of your sample program.
git clone https://github.com/aliyun/alibabacloud-webplus-demo-java.git && cd alibabacloud-webplus-demo-java
Step 4: Compile a package and create an application
- After cloning the sample program, run the following command to package the sample
program:
mvn package
- Run the following command to upload the sample program and create an application and
a deployment environment:
wpctl env:apply --package target/webplus-demo-java*.jar --label webplusVersion0.1 --category Java --env webplusEnvDemo --app webplusAppDemo --create-on-absent
Note In this step, the application name and deployment environment name are specified. The --create-on-absent flag specifies that Web+ creates an application or deployment environment if the specified application or deployment environment does not exist.
Step 5: Access the application
After the application and deployment environment are created, Web+ purchases the configuration resources in the template for you. It takes about 2 minutes to purchase the resources. Then, you can follow these steps to access the application:
- Run the following command to switch to the created application and deployment environment:
wpctl env:use webplusEnvDemo --app webplusAppDemo
- Run the following command to view the event list and verify that the switchover is
completed:
wpctl env:events
- Run the following command to view the environment information and obtain the application
URL:
wpctl env:info
- Open the application URL and visit the homepage of the application.
Step 6: Release the deployment environment
Run the following command to release the deployment environment.
By default, when the deployment environment is released, the Elastic Compute Service (ECS) instances purchased by Web+ for you are also released and no longer billed. In addition, the purchased Server Load Balancer (SLB) instance is released and no longer billed when no traffic or back-end servers need to be monitored.
wpctl env:terminate --app webplusAppDemo --env webplusEnvDemo
References
- For more information about CLI-related commands, see Use CLI commands.
- For more information about how to quickly deploy an application in the Web+ console, see Deploy applications in the Web+ console.