[JAVA] Deploy a Node.js application to an ECS instance using the Cloud Toolkit

This article will show you how to use the Cloud Toolkit to deploy a ** Node.js ** application on a ** Alibaba Cloud ECS instance **.

In the previous article, I explained how to deploy a local Java application directly to an instance of Alibaba Cloud Elastic Compute Service (ECS), and many readers read it. I received feedback. So, to answer your readers' questions, this article will also show you how to deploy a Node.js application on your Alibaba Cloud ECS instance.

image.png

Develop an application locally

In this article, I will explain how to deploy using a Node.js application that prints "Hello World" on a web page as an example.

const http = require('http');
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Alibaba Cloud Toolkit: Hello World');
});
server.listen(port, '0.0.0.0', () => {});

The code above is a standard Node.js project for displaying the string "Hello World" on a web page.

Plugin installation

Alibaba Cloud provides Eclipse-based plugins that allow developers to efficiently deploy applications written in their local IDE to ECS instances.

Plugin URL: https://www.aliyun.com/product/cloudtoolkit_en

The procedure for installing this Eclipse-based plug-in is similar to a typical plug-in, so we won't go into details here.

Plugin preferences

After installing the plugin, select it and configure the preferences.

Top Menu> Window> Preferences> Alibaba Cloud Toolkit> Account

When the following page is displayed, set the AK and SK of the Alibaba Cloud account, and the setting of the environment setting is completed (If you are using a RAM user account, enter the AK and SK of the RAM user ).

image.png

Deploy application

Right-click on the project name in Eclipse and select Alibaba Cloud> Deploy to ECS from the shortcut menu. The following deployment screen will be displayed.

image.png

In the Deployment Settings dialog box, set the deployment parameters and click Deploy to complete the initial deployment.

The /root/nodejs-demo/restart.sh file contains the following:

source ~/.bash_profile
killall node
nohup node /root/nodejs-demo/helloworld.js > nohup.log 2>&1 &

Description of placement parameters

--Deploy File: There are two options. The optional Upload File is used in your Node.js project. --Maven Build: If you are using Maven to build your current project, you can use Alibaba Cloud Toolkit to build and deploy your application directly. --File Upload: If you are not using Maven to build your current project, or if you already have a locally packaged deployment file, you can select your local deployment file and upload it directly. --Select ECS to deploy: Select a region from the drop-down list and select the ECS instance to deploy to that region. --Deployment location: Enter the deployment path on the ECS instance. --Command: Enter the application startup command. This parameter specifies the command to run after the deployment is complete. For Node.js programs, this is usually the startup command node XXX.js.

Recommended Posts

Deploy a Node.js application to an ECS instance using the Cloud Toolkit
Deploy a Java application developed locally with the Cloud Toolkit to an Alibaba Cloud ECS instance
Deploy your application to EDAS using the Cloud Toolkit Maven plugin
Guide: Deploy your application using the Alibaba Cloud Toolkit plugin
Deploy Java application developed in IntelliJ IDEA environment to Alibaba Cloud ECS instance
How to publish an application using AWS (3) EC2 instance environment construction
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]
I tried using the Migration Toolkit for Application Binaries
If you want to recreate the instance in cloud9
How to develop an app with Jersey Java RESTful API on Alibaba Cloud ECS instance
[Ruby] Does self refer to a class or an instance?
Add an icon to the header link using Rails fontawesome
How to create an application server on an EC2 instance on AWS
Deploy Spring Boot applications to Heroku without using the Heroku CLI
Launch an application on Code Engine using IBM Cloud Shell
[Java] Deploy the Spring Boot application to Azure App Service
Deploy the application created by Spring Boot to Heroku (public) ②
Procedure for publishing an application using AWS (4) Creating a database
Deploy the application created by Spring Boot to Heroku (public) ①
How to deploy Java application to Alibaba Cloud EDAS in Eclipse
How to deploy a Rails application on AWS (article summary)
How to build an environment with Docker, which is the minimum required to start a Rails application
After learning Progate, I tried to make an SNS application using Rails in the local environment
Deploy your application to WildFly
How to handle an instance
How to create a jar file or war file using the jar command
How to install and use Composer on an ECS instance on Ubuntu 16.04
[Java] Adding an element to the Collection causes a compile error
[Ruby] Relationship between parent class and child class. The relationship between a class and an instance.
I tried using the cache function of Application Container Cloud Service
Automatically deploy a Web application developed in Java using Jenkins [Preparation]
Easy way to create a mapping class when using the API
A memo that containerizes the simple chat application of Node.js + socket.io
Connect IoT devices to the cloud using gateway and subdevice scenarios
How to create a web server on an EC2 instance on AWS
Oracle Cloud [OCI]: Create a CentOS Stream instance using Compute's cloud-init
How to set an image in the drawable Left / Right of a button using an icon font (Iconics)