Updated on 2025-08-26 GMT+08:00

Deploying an Application on ECS

Adding a Target Host to the Project

Before deploying applications to ECSs, add target hosts as basic resources for the project.

  1. Go to the Phoenix Mall project, and choose Settings > General > Basic Resources.
  2. Click Create Host Cluster, configure the following information, and click Save.

    Table 1 Creating a host cluster

    Parameter

    Example

    Description

    Cluster Name

    phoenix-hostgroup

    The name of the host cluster to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.

    OS

    Linux

    The OS of the hosts to add to this cluster. Select Linux or Windows.

    Host Connection Mode

    Direct Connection

    The way your target hosts will connect to CodeArts Deploy. Select Direct Connection or Proxy.

    Execution Resource Pool

    Official

    A resource pool (or agent pool) is a collection of physical environments where software packages are deployed using commands.

    Choose the official agent pool or a self-hosted agent pool that contains your own servers.

  3. Click Add Host on the Target Hosts tab.
  4. Select Importing ECS, and click Import in the Operation column of the phoenix-ecs host.
  5. Configure the following information and click OK.

    Table 2 Adding a host

    Parameter

    Example

    Description

    Authorization

    Select Password.

    The authentication mode for connecting to the ECS. Select Password or Key.

    Username

    Enter root.

    The username for logging in to the ECS. By default, it is root for a Linux ECS.

    Password

    Enter the password set when buying the ECS.

    The password for logging in to the ECS.

    SSH Port

    Enter 22.

    The default port is 22. You can also use another one.

  6. Check the new record in the target host list. If the Verification Result column displays , the host is added successfully.

    If the host fails to be added, rectify the fault based on the failure details. For details, see Host Management FAQs.

Installing Dependency Tools on ECS

The sample program depends on Docker and Docker-Compose, which must be installed on the target ECS.

  1. Go to the Phoenix Mall project, and choose CICD > Deploy from the navigation pane.
  2. In the Operation column of the phoenix-sample-predeploy application, click and choose Edit.
  3. Click the Environment Management tab and configure the host environment.

    1. Click Create Environment, configure the following information, and click Save.
      Table 3 Creating an environment

      Parameter

      Example

      Description

      Environment

      phoenix-env

      The name of the environment to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.

      Resource Type

      Host

      The resource type in the environment. The default value is Host.

      OS

      Linux

      The OS of the hosts to add to this environment. Select Linux or Windows.

    2. Click Import Host on the Resources tab. In the displayed dialog box, select the configured host cluster and host and click Import.
    3. Check the new host in the resource list.

      Close the window. The new environment is displayed in the list.

  4. On the Deployment Actions tab page, edit the actions of the application.

    1. In action Install Docker, select phoenix-env from the Environment drop-down list. If a dialog box is displayed, asking you to confirm whether you want to change the environment to phoenix-env for the subsequent actions, click OK.
    2. Select Run Shell Commands, and add the following two command lines to the Shell Commands box:
      docker -v
      docker-compose -v

  5. Click Save & Deploy to start the deployment task.

    If a message is displayed indicating successful deployment, the task is successfully executed.

    If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.

  6. View the logs. If the log content is similar to the following figure, Docker and Docker-Compose are successfully installed.

    Figure 1 Viewing deployment logs

Configuring and Executing an Application

  1. Go to the Phoenix Mall project, and choose CICD > Deploy from the navigation pane.
  2. In the Operation column of the phoenix-sample-standalone application, click and choose Edit.
  3. Click the Environment Management tab and configure the host environment.

    1. Click Create Environment, configure the following information, and click Save.
      Table 4 Creating an environment

      Parameter

      Example

      Description

      Environment

      phoenix-env

      The name of the environment to create. Enter 3 to 128 characters. Only letters, digits, hyphens (-), underscores (_), and periods (.) are supported.

      Resource Type

      Host

      The resource type in the environment. The default value is Host.

      OS

      Linux

      The OS of the hosts to add to this environment. Select Linux or Windows.

    2. Click Import Host on the Resources tab. In the displayed dialog box, select the configured host cluster and host and click Import.
    3. Check the new host in the resource list.

      Close the window. The new environment is displayed in the list.

  4. On the Deployment Actions tab page, edit the actions of the application.

    1. Add the action Select a Deployment Source, and configure the following parameters.
      Table 5 Configuring the deployment source

      Parameter

      Example

      Description

      Source

      Build task

      The source of the software package to deploy. Select Artifact or Build task.

      Environment

      phoenix-env

      If a dialog box is displayed, asking you to confirm whether you want to change the environment to phoenix-env for the subsequent actions, click OK.

      The target deployment environment. Select the one added on the Environment Management tab.

      Build Task

      phoenix-sample-ci

      Available only when Source is set to Build task.

  5. Click the Parameters tab page and set parameters.

    Table 6 Parameters

    Name

    Default Value

    docker_server

    Enter the SWR server address obtained from the SWR login command.

    docker_username

    Enter the username obtained from the SWR login command.

    docker_username

    Enter the password obtained from the SWR login command.

    Obtain the SWR login command from the console. For details, see Obtaining a Long-Term Login or Image Push/Pull Command.

  6. Click Save & Deploy. In the displayed dialog box, click OK to start the deployment.

    If a success message shows up, the deployment is successful.

    If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.

  7. Verify the deployment result.

    1. Open a browser, enter http://IP:5000 in the address box, and press Enter. IP indicates the EIP of the ECS. The Phoenix Mall homepage is displayed.
      Figure 2 Phoenix Mall homepage
    2. Enter http://IP:5001 and press Enter. IP indicates the EIP of the ECS. The Phoenix Mall dashboard is displayed.
      Figure 3 Phoenix Mall dashboard