Deploy a static website

Updated at:
Copy as MD

SAE provides an Nginx environment. To deploy a static website, package your static resources, such as HTML, CSS, and JavaScript files, and upload the package to SAE.

Getting Started

Step 1: Create a code package

  1. Adjust the directory structure: Ensure that your static resources follow the directory structure below.

    .
    └── app
        └── index.html
        └── Other static resource files/folders
  2. Package the project: In the directory that contains the app folder, run the following command to package all static resources into a ZIP file.

    zip -r demo.zip app
    Important

    To ensure that the code package can run on SAE, follow these rules:

    • The directory that contains the static resource files must be named app. If the directory is named dist, rename it to app.

    • Package the app folder directly. Do not package the parent directory.

Step 2: Create an application

  1. On the SAE application list page, select a destination region and namespace from the top of the page, and then click Create Application.

  2. Select an application edition: For more information about the differences between editions, see Application editions.

    Note

    The Lightweight Edition and Professional Edition are available by invitation only. If you are not in the beta program, your application is created as the Standard Edition and you do not need to select an edition.

  3. Basic Information Settings:

    • Application Name: Enter a custom name for the application.

    • Namespace Type: A namespace is equivalent to a Kubernetes (K8s) namespace and is used to isolate resources for different environments. You cannot change the namespace of an application after it is created, so plan your configuration accordingly.

      • System Created: Use the default namespace, vSwitch, and security group that are created by the system in the current region.

      • Existing Namespace: Select the namespace, vSwitch, and security group that you previously created.

    • Application Deployment Method: Select Code Package-based Deployment, and click Configure Code Package-based Deployment.

      • Technology Stack Programming Language: Select HTML.

      • Code Package Type: Select ZIP Package Deployment.

      • NGINX environment: Select an environment that is compatible with your code. For more information, see HTML - Nginx environment introduction.

      • Upload Method: You can upload a local code package or provide the URL of the code package.

      • Version: Enter a version number for the application or select Use Timestamp as Version Number.

      • Time Zone Settings: Select a time zone for the application.

  4. Capacity Settings:

    • Resource Type: Select Default.

      Note

      Resource Type can be set to Default or Hygon. The Hygon resource type is available by invitation only. If you are not in the beta program, Resource Type is automatically set to Default, and you do not need to select it.

    • Single Instance Type: Select the CPU and memory specifications for each instance.

    • Instances: Set the initial number of instances.

  5. Click Create Application with One Click and wait for the application to be created.

Step 3: Access the application

You can expose your application to the internet by attaching an NLB, attaching a CLB, or configuring gateway Ingress. The following steps use attaching an NLB as an example.

  1. In the SAE application list, select the destination region and namespace at the top of the page. Then, click the Application ID of an application to open its details page.

  2. In the Application Access Settings area, select the NLB-based access tab, and click Add NLB Access.

    • Instance Source: Select Create an instance.

    • Network Type: Select Public Network.

    • vSwitch: Specify the zone and virtual switch for the NLB instance.

      Note
      • For high availability, select at least two zones and their corresponding virtual switches.

      • If no virtual switch is available, click Create to create one. After the virtual switch is created, click the refresh icon and select the new virtual switch.

    • Protocol Type: Select TCP.

    • Listener Port: The port that accepts and forwards requests to backend servers. This port is customizable. In this example, enter 80.

    • Container Port: The listening port for the container process, which is defined in the application. For an Nginx environment in SAE, the default port is 80.

  3. Click Confirm and wait for the instance to be created.

  4. Verify the result:

    1. Click the ID of the NLB instance to go to its details page. In the Zone section, copy an EIP of the NLB instance.

    2. Access the application from a browser. The URL format is http://<EIP>:<Listener Port>.

Advanced Settings

When you create and deploy an application, you can configure the following advanced features as needed.

Runtime environment and lifecycle management

Application access and traffic management

Data persistence

Store your application data in NAS, OSS, or a database to prevent data loss when an application is changed or terminated.

Logging and monitoring

  • After you deploy an application, you can immediately view real-time logs and view resource usage and payload without any additional configuration. You can also export logs to SLS or Kafka for centralized management and analysis.

  • Application Real-Time Monitoring Service (ARMS) provides a comprehensive view of your application's status. It helps you quickly detect faulty and slow API operations, identify performance bottlenecks, and reproduce call parameters. This greatly improves the efficiency of diagnosing online issues.

    • For Std Edition applications, you can view ARMS Basic Edition monitoring data immediately after deployment without any additional configuration. You can also subscribe to ARMS Premium Edition monitoring.

    • For Pro Edition applications, after you enable Application Monitoring in the Advanced Settings and deploy the application, you can view ARMS Premium Edition monitoring data at no additional cost.

Microservice governance

Microservices Governance enables lossless deployment and undeployment, traffic protection, end-to-end canary releases, and prioritized routing within the same availability zone for Java applications.

  • For Std Edition applications, after you deploy the application, you must go to the application details page to purchase the MSE microservice governance feature.

  • For Pro Edition applications, after you enable Microservices Governance in the Advanced Settings, you can configure graceful deployment and undeployment. After the application is deployed, you can configure more features on the application details page at no additional cost.

Other features