All Products
Search
Document Center

Serverless App Engine:Creating code packages align with SAE requirements

Last Updated:Jun 20, 2025

Before using code packages to deploy applications, you need to create code packages align with SAE requirements.

Java

  1. Creating JAR or WAR packages for SAE applications is the same as creating regular code packaging.

  2. Deploy Java applications using WAR or JAR packages.

PHP

  1. Download the sample code package hello-sae-php.zip and extract it. The directory structure is as follows:

    .
    ├── nginx
    │   ├── default.conf
    │   ├── fastcgi_params
    │   └── root.dir
    ├── php # Program directory
    │   ├── index.php # Program entry file
    │   └── phpinfo.php
  2. Replace the code files in php/ with yours.

  3. Modify the configuration files in nginx/ as needed.

    Configuration item

    Default value

    How to modify

    Port

    80

    Modify the default.conf file, add listen <port>; (for example, listen 8080;) in the first line of server{ }.

    Program entry file name

    index.php

    If you modified the program entry file name, perform the following operations:

    In default.conf, change index index.php index.html index.htm; to index <Program entry file name>;, and change fastcgi_index index.php; to fastcgi_index <program entry file name>;.

    Program directory name

    php

    If you modified the program directory name, perform the following operations:

    In root.dir, change root /home/admin/app/php; to root /home/admin/app/<program directory name>;

  4. Package the contents of the current directory into a ZIP file. Note that nginx and php should be located in the root path of the ZIP file.

  5. Deploy PHP applications using ZIP packages.

Python

  1. Learn about the ZIP packaging specifications.

    • Package the code root directory files or folders. Do not package the outer directory.

    • If the application has a requirements.txt, place it in the root directory and package it together to allow SAE to automatically install software dependencies during deployment.

  2. Based on the example hello-sae-python.zip, package your Python application as a ZIP file. The directory structure of the example is as follows (the sample code depends on Flask, Gunicorn, and other packages. For details, see requirements.txt):

    .
    ├── app
    │   └── hello.py
    └── requirements.txt (optional, should be in the root directory)

    Execute the following commands:

    # Get the example
    wget https://sae-demo-cn-shenzhen.oss-cn-shenzhen.aliyuncs.com/demo/1.0/hello-sae-python.zip
    # Extract the example
    unzip hello-sae-python.zip -d hello-sae-python && rm -rf hello-sae-python.zip && cd hello-sae-python
    # Replace the sample code with your Python program (replace /path/to/your-python-project/ with your project path)
    rm -rf app/* requirements.txt
    cp -r /path/to/your-python-project/. app/
    cp -r /path/to/your-python-project/requirements.txt ./
    # Package into a ZIP file
    zip -r my-python-app.zip app requirements.txt
  3. Deploy Python applications using ZIP packages.

.NET Core

  1. Understand the ZIP packaging specifications.

    ZIP directory

    Corresponding SAE instance runtime directory

    Description

    ./start.sh

    /home/admin/start.sh

    Stores the application startup script.

    ./your-dotnet-project

    /home/admin/app/nginx/*.conf

    Stores the .NET program.

    • Package the code root directory files or folders. Do not package the outer directory.

    • If the application has a startup script, such as the start.sh file, place it in the root directory and package it together to allow SAE to automatically execute the startup script during deployment.

  2. Download and install .NET SDK. Select a .NET Core version supported by SAE and verify the installation by executing dotnet --version. If an error occurs, install the corresponding dependency packages prompted by the error message.

  3. Compile and build the project by executing the following commands:

    # Navigate to the project path (replace /path/to/your-dotnet-project/ with your project path)
    cd /path/to/your-dotnet-project/
    # Restore project dependencies
    dotnet restore
    # Compile the source code
    dotnet build -c Release -o demo
    # -c Release: Optimizes code to improve runtime performance and removes debugging information, suitable for production deployment.
    # -o demo: Specifies the build output directory as demo.
  4. Write a startup script for the project (such as start.sh) and add executable permissions to it using chmod +x ./start.sh.

  5. View the current directory structure using the tree command.

    .
    ├── appsettings.Development.json
    ├── appsettings.json
    ├── appsettings.Production.json
    ├── your-dotnet-project
    ...
    └── start.sh
  6. Package into a ZIP file.

    zip -r demo.zip *
    # demo.zip: The name of the ZIP file to be created.
    # *: Packages all files and folders in the current directory.
  7. Deploy .NET Core applications using ZIP packages.