Use this deployment type to publish an application when no source files are required and the entire deployment is handled by scripts.
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 of the publishing task.
Retrieves the deployment information, including the application's start and stop scripts.
Runs the stop script to stop the old version of the application.
Runs 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
Prepare the application, group, and ECS instances.
Before you deploy, create an application and a group in ECS Application Management. Then, add your ECS instances to the group.
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.
Install Docker on the ECS instances in the group. On the O&M tab of the application group, select ACS-ECS-BulkyConfigureOOSPackageWithTemporaryURL to install Docker in a batch.
If your ECS instance was created from a custom image, you cannot install extensions this way. You must remotely connect to the instance and manually install Docker.
Create the deployment.
Pull the sample image to your local machine. Then, push the image to your personal edition ACR repository.
docker pull aliyun-computenest-opensource-registry.cn-hangzhou.cr.aliyuncs.com/default/aliyun-code-deploy:latestGo to the ECS console - Application Management page. On the My Applications tab, click the name of the target application.
On the application details page, select the Parameters tab and click Create Parameter. Create
usernameandpasswordparameters to store your ACR Personal Edition credentials. For security, create thepasswordparameter as an encrypted parameter.On the application product page, select the Deployment tab, and then click Create Deployment.
On the Create Deployment page, set RevisionType to Command-only. Then, set the parameters and click OK.
Working Directory: The directory in which the start and stop scripts are executed. For example,
/root/deploy.Application Start Script: Replace the
<repo>and<image>values with the information for your Personal Edition ACR instance.In the figure below, the first field is
repoand the second field isimage. Use these values for the corresponding parameters in the application start script.
### Start the current version of the application start_application() { repo="<repo>" image="<image>" container_name="my-container" docker login --username=${username} --password=${password} $repo docker pull $image docker run -d -p 8080:8080 --name $container_name $image } start_application### Stop the container (if any) stop_application() { # Query for the container by name. If it exists, delete it. container_name="my-container" container_id=$(docker ps -aq -f name=${container_name}) if [ -n "$container_id" ]; then docker rm -f $container_id 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 |
Working directory | The working directory for the application's start and stop scripts.
|
Application start script | The Shell script used to start the application. |
Application stop script | The Shell script to stop the application. For example, the following script stops a container named |