☁️Deploy Like a Pro: GoLang Deployment and Huawei CodeArts Integration, A Comprehensive Step by Step Guide

Tugay Talha İçen
Huawei Developers
Published in
7 min readJul 2, 2024
Golang with Huawei Codearts

Introduction

In today’s fast-paced tech landscape, efficiency and reliability in building and deploying applications are crucial. For Golang developers, finding a robust and streamlined solution to manage the entire lifecycle of a web application can be a game-changer. Enter Huawei CodeArts — a comprehensive platform designed to simplify the complexities of development, deployment, and release processes.

What is Huawei CodeArts? Huawei CodeArts is an integrated ready-to-use DevOps platform that provides a suite of tools and services to support the entire application lifecycle. It offers features such as code hosting, continuous integration and delivery (CI/CD), automated testing, and project management. By leveraging Huawei CodeArts, developers can significantly reduce the time and effort required to build, deploy, and manage applications, ensuring higher quality and faster time-to-market.

In this article, we’ll explore how to harness the power of Huawei CodeArts to build, and deploy a Golang web application. Whether you’re a seasoned developer looking for a more efficient workflow or a newcomer eager to learn the ropes, this guide will provide you with the tools and knowledge to elevate your Golang projects to the next level.

We’ll walk through the entire process step-by-step, highlighting the features and benefits of Huawei CodeArts that make it an ideal choice for Golang developers. From setting up your environment to deploying your app and managing releases, you’ll discover how this platform can enhance your development experience and accelerate your project timelines.

So, let’s dive in and unlock the full potential of Golang with Huawei CodeArts!

Demo

Step 1: Login to your Huawei Cloud account. If you don’t have any you can click here to learn how to create Huawei Cloud and take $100 dollar coupon.

Step 2: Navigate to the console and after you select desired location (services can change a bit from location to location). Click “Service List” from “Create Resources”.

Service List Choice

Step 3: Select CodeArts and buy a package if you don’t have any. In our case we can continue with free package.

Step 4: Click to access service and create a project with your desired type

Step 5: Create a repository from Code->Repo. If you don’t want to create repository here you can continue with existing ones from GitHub etc. in later steps. To create a repository we have three options:

Creating A Repository
Repository Creation Options

Step 5.A: You can crate a common(empty) repository to do whatever you want to do from scratch.

Step 5.B(Recommended for learning): We will create a template GoLang project to demonstrate steps. Select Go from programming languages and choose one of the GoLang projects with “Web Server“ tag and click next. For the following page enter the project name, and create the project by clicking Ok.

Create An Example GoLang Project

Step 5.C: You can import an existing repository from Git Url, SVN Url or GitHub by endpoint, or personal access token. Click to learn how to obtain personal access token for GitHub.

Step 6(Optional): You can create a pipeline so that you can repeat operations such as build and deploy later with a single click. We won’t do that in this article. Possible error: Code Check for GoLang is not supported in free package.

Step 7: After creating the repository(and adding the codes if you create an empty one) in order to create a build task click “Create Task” from CCID->Build

Create A Task

Step 8: Select your repository or connect another one from other version control systems, and click next.

Select Your Repository

Step 9: Select Go template and click OK.

Select Go Template

Step 10: If you want to customize the your build, and then then click the “Save and Run”.

Save and Run Your Build

Step 11: Create an Elastic Cloud Server(ECS) to deploy the application on it. You can click here to follow the guide. If you are using free package be careful to buy the ones that say “Free package” on the side.

Step 12: Click Create Application from CCID -> Deploy

Create An Application

Step 13: Select Deploy Go Application and click OK.

Select Deploy Go App

Step 14: In the page that comes click manage next to the Environment to create e new Environment with the ECS we created. Click Create Environment. Enter the Environment name and click save. Click the “Import Host” from Resources tap that came. Click go from this text: “If no host cluster is available, go to Basic Resources to create one. Go” . Name the Cluster, click save. Open the cluster back, click “Target Host” tab. Select if your ECS is there(it should seem if both CodeArts service and ECS in same region), if it is not there then click Adding IP and write your host IP (Console -> ECSs -> Click your ECS -> EIPs -> Expand the part -> copy the EIP), and name your host. Enter your username(root user recommended) and password for that user then write your SSH port(default “22”) and click OK. Go back to the Environment page, select the cluster and the host that we created(refresh if it doesn’t seem), Click import.

Step 14.5: Before you connect the ECS with Environment you should allow SSH port(22) from Security Group (Console -> ECS -> Network and Security -> Security Group) inbound rules. Also allow the port of your application(we will use 8080 in our example).

Step 15: Go back to the deploy settings page select the Environment that we created. You can deploy from Artifact by specifying artifact path(you can choose from 3 point after the build or you can find in Artifacts -> Release Repos -> path). We will continue with build task option. Select build task, and write Download path (I use “/usr/local”). Go to the Stop Go Service stage and Start Go Service stage in order and write Absolute Path (if you follow mine it is “/usr/local/${app_name}”). Click Save.

Deploy Settings

Step 16: Go to the parameters tab close the host_group and package_url options which we don’t need and write “demo” to app_name(if you want to change you should change from build task settings) and 8080 to the service port (you should change this on code for different ports). Click Save & Deploy.

Runtime Parameter Settings

Step 17: Congrats your web page is alive🥳!!! You can see it with writing your host’s “${EIP}:${Server_Port}” to the browser service port is 8080 in our case and you can find your host’s EIP with Console -> ECSs -> Click your ECS -> EIPs -> Expand the part -> copy the EIP. If your EIP is 123.345.6.7 and the service port is 8080 your address is “123.345.6.7:8080”

Page in Live

Conclusion

In conclusion, Huawei CodeArts offers a streamlined, efficient solution for building, deploying, and releasing Golang web applications. By integrating essential tools and automating workflows, it empowers developers to focus on creating high-quality code with less hassle.

We hope this guide has equipped you with the knowledge to leverage Huawei CodeArts effectively. Start using it today to enhance your Golang projects and accelerate your development process. Until the next article wish you fast debugged codings!!!!

Referances

--

--