Deploy a PHP task template to SAE

Updated at:

You can use Apsara DevOps pipelines for continuous integration and deployment of your task templates. This topic describes how to use Apsara DevOps to deploy a PHP task template to SAE using an image.

Prerequisites

  • You have an Alibaba Cloud account.

  • Apsara DevOps is active.

  • Container Registry is active.

  • You have uploaded your application code, including its Dockerfile, to a code repository.

Background information

If this is your first time using Apsara DevOps, familiarize yourself with its deployment process and the deployment methods that SAE supports.

For more information, see Overview of deploying SAE applications and task templates by using Apsara DevOps 2020.

Step 1: Create a task template in SAE

If this is your first time hosting tasks on SAE, you must first create a corresponding task template in the SAE console. SAE supports code package deployment and image deployment. The task template's deployment method must match the pipeline configuration.

Step 2: Create an enterprise in Apsara DevOps

Create an enterprise when you use Apsara DevOps Flow for the first time. If you already have one, skip this step.

  1. Log on to Apsara DevOps Flow.

  2. Set the enterprise name, select the R&D organization size, and click Create Now.

Step 3: Create a pipeline in Apsara DevOps

  1. Log on to Apsara DevOps Flow.

  2. In the upper-right corner of the Flow page, click New Pipeline.

  3. In the Select a Template dialog box, select Empty Template · Empty Template and click Create.

  4. On the pipeline editing page, click Add Pipeline Source. In the Add Pipeline Source panel, select Code Source, configure its settings, and click Add.

    Parameter

    Description

    Select a code source

    The code source that contains your application code.

    Note

    The parameters to configure vary based on the code source. Configure the parameters as prompted on the page.

    code repository

    Select the code repository address.

    default branch

    Select the code branch.

Step 4: Deploy the task template to SAE

  1. In the Stage 1 area, click Empty Task. In the Edit panel, enter a custom Task Name, and configure build cluster, Specify Build Node, Build Environment, and Download pipeline source.

  2. Click Add Step, select Build > Build image and push to Alibaba Cloud Container Registry Personal Edition from the drop-down list, configure the image information, and then click Save Only.

    This topic uses a Personal Edition instance as an example. The following table describes the parameters.

    Parameter

    Description

    Select a service connection

    Select a service connection to allow Container Registry to store the image.

    Note

    If you have not created a connection, click Add service connection, complete the RAM authorization as prompted, and then configure the parameters.

    region

    Select the region of the task template that you created in Step 1.

    repository

    Select the repository where the image is pushed after the build is complete.

    tag

    A custom tag name.

    Dockerfile path

    The path where the Dockerfile is located.

    ContextPath

    The execution context path for the docker build command. Defaults to the Dockerfile path if left empty.

    Do not use cache

    Once selected, docker build will use the no-cache=true parameter to build the image.

    build argument

    When the component is run, a set of parameters are passed as --build-arg to the build command. You can configure these parameters based on your actual needs.

  3. In the New Stage area, click New Task and select Update Serverless (SAE) Task Template.

  4. In the Edit panel, configure the task settings and click Save and Run.

    Parameter

    Description

    Task name

    A custom task name. The name can be up to 20 characters long.

    build cluster

    You can select a different build cluster for the task.

    Download pipeline source

    If you enable this option, the source files from the pipeline source are downloaded to the corresponding working directory.

    Select a service connection

    Select a service connection to authorize Apsara DevOps to deploy the task template on SAE.

    If you have not created a connection, click Add service connection, complete the RAM authorization as prompted, and then configure the parameters.

    region

    Select the region where the task template created in Step 1: Create a task template in SAE is located.

    namespace

    Select the namespace where the task template created in Step 1: Create a task template in SAE is located.

    SAE task template

    Select the task template that you created in Step 1: Create a task template in SAE.

    build artifact

    Select the image tag that you specified in the image build task in Step 4.

    Use Alibaba Cloud ACR Enterprise Edition

    This topic uses a Personal Edition instance as an example, so no configuration is required.

    Task plug-in

    You can configure task plug-ins to send pipeline notifications as needed.

  5. In the Run Configurations dialog box, confirm the settings and click Run.

Verify the results

After the deployment starts, you are redirected to the Recent Runs tab to view the pipeline execution result. If the run fails, check the logs in the Apsara DevOps pipeline to troubleshoot the issue. After you fix the issue, run the pipeline again.

More information

After deploying the application to SAE, you can perform the following operations.

Actions

References

Manage the application lifecycle, such as updating, scaling, starting, stopping, and deleting the application.

Manage the application lifecycle

Improve application performance with auto scaling, CLB binding, and batch start and stop.

Track the application running status by managing logs, viewing monitoring data, checking application events, and reviewing change history.