In the previous article, we have discussed how to deploy a local Java application directly to an Alibaba Cloud ECS instance. In this article, we will introduce how to deploy a Go application to an Alibaba Cloud Elastic Compute Service (ECS) instance.
The coding method is similar no matter whether you compile Go applications that run on the cloud or locally. Therefore, this article takes a Go application for printing "Hello World" on a Web page as an example to explain the deployment method.
//Alibaba Cloud Toolkit. http://www.aliyun.com/product/cloudtoolkit
func setupRouter() *gin.Engine {
// Disable Console Color
// gin.DisableConsoleColor()
r := gin.Default()
// Ping test
r.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "Alibaba Cloud Toolkit: Hello World.")
})
return r
}
func main() {
r := setupRouter()
// Listen and Server in 0.0.0.0:8080
r.Run(":80")
}
You can download the source code through this link.
The preceding code is a standard Go project used to print the string "Hello World" on a Web page.
Alibaba Cloud provides an Eclipse-based plug-in to help developers efficiently deploy applications written in the local IDE to ECS instances.
URL of the plug-in: https://www.aliyun.com/product/cloudtoolkit_en
The installation process of this Eclipse-based plug-in is similar to that of a common plug-in, and therefore will not be detailed here.
After installing the plug-in, configure the preferences by choosing:
Top menu > Window > Preferences > Alibaba Cloud Toolkit > Accounts.
When the following page is displayed, configure the AK and SK of your Alibaba Cloud account to complete the configuration of preferences.( If you are using a RAM user account, enter the AK and SK of the RAM user.)
In Eclipse, right-click the project name and choose Alibaba Cloud > Deploy to ECS from the shortcut menu. The following deployment window is displayed:
In the Deployment Configurations dialog box, set the deployment parameters, and click Deploy to complete the initial deployment.
source ~/.bash_profile
pkill -f 'go-demo'
mv /tmp/go-demo /root/go-demo
chmod 755 /root/go-demo
sh -c /root/go-demo
Deploying a Java Application to an ECS Instance in IntelliJ IDEA
Deploying an Application to Container Service for Kubernetes
liptanbiswas - July 15, 2018
Alibaba Clouder - February 13, 2019
Alibaba Clouder - May 6, 2019
Alibaba Clouder - November 29, 2017
Marketplace - February 21, 2019
Alibaba Clouder - February 14, 2020
Robotic Process Automation (RPA) allows you to automate repetitive tasks and integrate business rules and decisions into processes.
Learn MoreA PaaS platform for a variety of application deployment options and microservices solutions to help you monitor, diagnose, operate and maintain your applications
Learn MoreGain an industrial edge with Alibaba Cloud best practices
Learn MoreAlibaba Cloud (in partnership with Whale Cloud) helps telcos build an all-in-one telecommunication and digital lifestyle platform based on DingTalk.
Learn MoreMore Posts by Nick(倪超)