Use this deployment type to publish an application when its source files are stored in Object Storage Service (OSS).
How it works
If you deploy to an application group that is an Auto Scaling (ESS) group, scaling activities are paused during the deployment. They automatically resume after the deployment finishes, whether it succeeds or fails.
The deployment process follows a stop-then-start principle. Each deployment first runs the stop script and then runs the start script.
Create and publish the deployment.
Configure the application source file, start script, and stop script for the deployment.
Create a release task, select a release mode, and publish the deployment to the target application group.
Automated deployment flow.
Retrieve deployment information, including OSS file details and the application's start and stop scripts.
Download file: The OSS file is automatically downloaded to the working directory.
Run stop script: Run the stop script to stop the old version of the application.
Run start script: Run the start script to start the new version of the application.
Scope
Deployments are supported only on Linux instances.
The start and stop scripts must be Shell scripts.
Procedure
Create an application and import Elastic Compute Service (ECS) instances.
If you do not have an ECS instance, create one that runs a Linux operating system from the ECS console - Custom Launch page.
We recommend using an ECS image of Alibaba Cloud Linux 3.2104 LTS 64-bit or Ubuntu 22.04 64-bit. The scripts in the following examples are based on these two images. If you use a different image, modify the scripts as needed.
Go to the ECS console - Application Management page, click Create from Existing Resources, create an application and an application group, and import the ECS instance into the application group.
Create an OSS deployment.
Download the official sample JAR package and upload it to OSS.
Go to the ECS console - Application Management page. On the My Applications tab, click the name of the target application.
On the application product page, select the Deployment tab, and then click Create Deployment.
On the Create Deployment page, set RevisionType to OSS File. Configure the parameters and click OK.
OSS file information: Specify the OSS Bucket and the path to the file.
If the ECS instance and the OSS Bucket are in the same region, you can select Internal Network Download to improve the download speed.
Working directory: The directory where the start and stop scripts run. The OSS file is automatically downloaded to this directory. Example:
/root/deploy.Alibaba Cloud Linux
function start_application() { set -e yum install -y maven-3.5.4 java -jar ./sample-spring-1.0-SNAPSHOT.jar & } start_applicationUbuntu
function start_application() { set -e apt update apt install -y maven java -jar ./sample-spring-1.0-SNAPSHOT.jar & } start_application### Stop the application (if any) function stop_application() { PID=$(ps -ef | grep "sample-spring-1.0-SNAPSHOT.jar" | grep -v "grep" | awk '{print $2}') if [ -n "$PID" ]; then kill -9 $PID fi } stop_application
Return to the deployment list. Find the deployment that you created and click Publish. Select the target group and click OK to start the deployment.
Verify the result.
Go to the details page of the target instance. Click Connect and select Workbench. Follow the prompts on the page to log on to the terminal.
Run the
curl http://localhost:8080/hellocommand. A return value ofAlibaba Spring Sample!indicates that the deployment was successful.
Important fields
Field | Description |
OSS Region | The region of the OSS Bucket that contains the source file. |
OSS Bucket | The OSS Bucket that contains the source file. |
OSS File | The source file object in the OSS Bucket. |
OSS File Version | The specific version ID of the file. This is required only if versioning is enabled for the Bucket. If versioning is not enabled, leave this field empty. |
Internal Network Download | Select this option when the ECS instance and the OSS Bucket are in the same region. |
Working directory | The download path for the application source file. This is also the execution directory for the start and stop scripts.
|
Application start script | The Shell script to start the application. |
Application stop script | The Shell script to stop the application. For example, the following script stops a container named |