This topic describes how to deploy a Hacker News application to Function Compute. Function Compute provides a method different from traditional deployment methods. You can deploy a traditional Hacker News application to Function Compute and use the application for production without performing operations such as purchasing a server. The deployed Hacker News application can use the auto scaling, pay-as-you-go, and O&M-free features of Function Compute.
- Install Funcraft. For more information, see Install Funcraft.
- Configure Funcraft. For more information, see Configure Funcraft.
The content about how to use Funcraft to migrate an application from a traditional framework is no longer maintained. We recommend that you use Serverless Devs to migrate relevant frameworks to Function Compute.
For more information about how to migrate Function Compute-related resources from Funcraft to Serverless Devs, see Migrate resources from Funcraft to Serverless Devs.
For more information about how to use Serverless Devs to migrate an application from a web framework, see Use Serverless Devs to migrate web frameworks.
We apologize for any inconvenience caused.
- Run the following command to clone the Hacker News sample project to your on-premises
machine: If a Hacker News project already exists, skip this step.
git clone https://github.com/nuxt/hackernews.git
- Open the sample project or an existing project.
- Install dependencies.
- Run the on-premises project.
npm run dev
- Run the following command to compile the Hacker News project:
npm run build
- Run the
fun deploy -ycommand to deploy the application to Function Compute.
fun deploy -yThe following result is returned:
current folder is not a fun project. Generating /Users/XXX/Desktop/hackernews/bootstrap... Generating template.yml... Generate Fun project successfully! ========= Fun will use 'fun deploy' to deploy your application to Function Compute! ========= ... ... ... Fun detected that your function hackernews/hackernews sizes exceed 50M. It is recommended that using the nas service to manage your function dependencies. ? Do you want to let fun to help you automate the configuration? Yes ? We recommend using the 'NasConfig: Auto' configuration to manage your function dependencies. Yes ... ... ... starting upload /Users/XXX/Desktop/hackernews/node_modules to nas://hackernews/mnt/auto/node_modules/ start fun nas init... ... ... ... trigger httpTrigger deploy success function hackernews deploy success service hackernews deploy success Detect 'DomainName:Auto' of custom domain 'Domain' Request a new temporary domain ... The assigned temporary domain is 14942717-XXX.test.functioncompute.com, expired at 2020-04-02 13:51:57, limited by 1000 per day. Waiting for custom domain Domain to be deployed... custom domain Domain deploy success
The preceding deployment logs show that Funcraft detects that your function code package exceeds the maximum size of a code package that can be uploaded to Function Compute. Funcraft starts the large dependency wizard. In the wizard, enter Yes or Y. Then, Funcraft automatically uploads the third-party dependencies in your function to Apsara File Storage NAS. For more information about limits of Function Compute, see Limits on resource usage.
After the application is deployed, you can check logs to find the temporary domain name that is generated by Function Compute. You can use the temporary domain name to access the deployed application.Note The temporary domain name is used only for demonstration and development purposes. It is valid for a limited period of time. You must use a domain name that has obtained an Internet Content Provider (ICP) filing from Alibaba Cloud for production. For more information, see Configure a custom domain name.