Before using code packages to deploy applications, you need to create code packages align with SAE requirements.
Java
Creating JAR or WAR packages for SAE applications is the same as creating regular code packaging.
PHP
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.phpReplace the code files in
php/with yours.Modify the configuration files in
nginx/as needed.Configuration item
Default value
How to modify
Port
80
Modify the
default.conffile, addlisten <port>;(for example,listen 8080;) in the first line ofserver{ }.Program entry file name
index.php
If you modified the program entry file name, perform the following operations:
In
default.conf, changeindex index.php index.html index.htm;toindex <Program entry file name>;, and changefastcgi_index index.php;tofastcgi_index <program entry file name>;.Program directory name
php
If you modified the program directory name, perform the following operations:
In
root.dir, changeroot /home/admin/app/php;toroot /home/admin/app/<program directory name>;Package the contents of the current directory into a ZIP file. Note that
nginxandphpshould be located in the root path of the ZIP file.
Python
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.
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
.NET Core
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.shfile, place it in the root directory and package it together to allow SAE to automatically execute the startup script during deployment.
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.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.Write a startup script for the project (such as
start.sh) and add executable permissions to it usingchmod +x ./start.sh.View the current directory structure using the tree command.
. ├── appsettings.Development.json ├── appsettings.json ├── appsettings.Production.json ├── your-dotnet-project ... └── start.shPackage 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.