Deploy a Parse Server application on Elastic Container Instance

更新时间:
复制 MD 格式

You can use the Alibaba Cloud command-line interface (CLI) to create an Elastic Container Instance (ECI) container group, deploy a Parse Server application to the container group, and enable public network access.

Tutorial overview

The steps and examples in this tutorial are integrated into Alibaba Cloud Shell. You can open the tutorial in Cloud Shell to quickly deploy a Parse Server application using the Alibaba Cloud CLI.

In this tutorial, you will complete the following operations:
  1. Configure the network
  2. Deploy the application
  3. Destroy the application
After you complete this tutorial, the following resources are created:
  • ECI container group
    • Number of containers: 3
    • Container specifications: 1 vCPU, 1 GB memory
  • Elastic IP Address
    • Number of instances: 1
    • Billing method: pay-by-traffic
For more information about billing, see ECI billing overview and Pay-as-you-go for Elastic IP Address.

Prerequisites

Before you begin, make sure that you meet the following requirements:

Network configuration

Before you deploy the Parse Server application, configure the network environment.
  1. Run the following command to navigate to the directory that contains the Terraform template for network configuration.
    cd ~/tutorial-eci-parse-server/network
  2. Run the init command to load Alibaba Cloud Providers.
    terraform init
  3. Run the following command to deploy the network environment.
    terraform apply
    After the deployment is successful, the following output is displayed in the console:
    ...
    Outputs:
    eip_ip = 106.14.2.**
    eip_id = eip-uf6n81mgxtwl******
    region_id = cn-hangzhou
    securitygroup_id = sg-uf631pc9pwu******
    vpc_id = vpc-uf6rrgi1zrug3znr*****
    vswitch_id = vsw-uf6jxv84mbf427h*****
    zone_id = cn-hangzhou-b
    You can specify the following parameters to customize your network configuration:
    • region

      • The region. The default value is cn-hangzhou.
    • availability_zone

      • The zone. The default value is cn-hangzhou-b.
    • vpc_cidr

      • The VPC CIDR block. The default value is 172.16.0.0/12.
    • vswitch_cidr

      • The vSwitch CIDR block. The default value is 172.16.0.0/21.
  4. Run the following command to save the network parameters to a temporary file. These parameters are used in subsequent steps.
    terraform output > net_conf

Deploy the Parse Server application

This tutorial provides the eci-create.sh script. The script reads the network configuration file that you generated and creates an ECI container group to deploy the Parse Server application. For more information about ECI operations in the CLI, see Manage Elastic Container Instance (ECI) using the Alibaba Cloud CLI.

Run the following commands to navigate to the tutorial-eci-parse-server directory and deploy the Parse Server application.
cd ~/tutorial-eci-parse-server
bash eci-create.sh network/net_conf
Command description:
  • network/net_conf is the configuration file that stores the network parameters generated in the previous step.
  • The container group contains three containers. One container runs MongoDB, another runs Parse Server, and the third runs Parse Dashboard.
After the deployment is successful, the following output is displayed in the console:
{
    "ContainerGroupId":"eci-uf6fonnghi50val****",
    "RequestId":"3061989B-C3D2-41BD-B30F-*****"
}
You can now log on to the ECI console to view the container group that you created.
Note After the container group is created, you can access Parse Dashboard at http://${EIP_IP_address}:4040.

Destroy the application

You can destroy the application by deleting the container group and the network configuration.
  1. Run the following command to delete the container group.
    aliyun eci DeleteContainerGroup \
      --RegionId cn-hangzhou  \
      --ContainerGroupId eci-uf6fonnghi50val****
    In the command, ContainerGroupId is the ID of the container group that you created in the previous step.
  2. Run the following command to navigate to the directory that contains the Terraform template for network configuration.
    cd ~/tutorial-eci-parse-server/network
  3. Run the following command to destroy the network resources.
    terraform destroy