Last updated: 2021-08-26 15:26:32

    This document describes how to use an image to deploy a function in the console.

    Prerequisites

    SCF supports image repositories on TCR Personal Edition and Enterprise Edition. You can select an image repository as needed.

    • Purchase a TCR Enterprise Edition instance. For more information, please see Quick Start.
    • Use a TCR Personal Edition image repository. For more information, please see Getting Started.

    Creating Function in Console

    Pushing image

    Run the following code to push the built image to your image repository.

    # Switch to the file download directory
    cd /opt
    # Download the demo
    git clone https://github.com/awesome-scf/scf-custom-container-code-snippet.git
    # Log in to the image repository. Please replace `$YOUR_REGISTRY_URL` with the address of your image repository and replace `$USERNAME` and `$PASSWORD` with your login credentials respectively
    docker login $YOUR_REGISTRY_URL --username $USERNAME --password $PASSWORD
    # Build the image. Please replace `$YOUR_IMAGE_NAME` with the address of your image
    docker build -t $YOUR_IMAGE_NAME .
    # Push the image
    docker push  $YOUR_IMAGE_NAME
    

    Creating function

    1. Log in to the SCF console and click Function Service on the left sidebar.
    2. Select the region where to create a function at the top of the page and click Create to enter the function creation process.
    3. Select Custom Creation for Creation Method and enter the basic function information.
      Parameter Operation
      Function type Select event function or web function
      Function name Define the function name
      Region Select the function deployment region, which must be the same as that of the image repository
      Deployment mode Select image deployment
      Image Select the Personal Edition or Enterprise Edition image repository you created
      Image tag Select the image tag
      If this parameter is left empty, the latest version of the image will be used by default
      Command Enter the bootstrap command of the container
      Parameter input specification: we recommend you use "double quotation mark + comma" as the parameter separator, such as "nginx".
      This parameter is optional. If it is left empty, the Entrypoint / CMD in the image will be used by default
      Args Enter the bootstrap parameter of the container
      Parameter input specification: we recommend you use "double quotation mark + comma" as the parameter separator, such as "-args","value". This parameter is optional. If it is left empty, the CMD in the image will be used by default
    4. Click Complete.