Mdr{dani} Notes

Build a CI/CD workflow with Github Actions - Sesi 1

·

2 min read

Cover Image for Build a CI/CD workflow with Github Actions - Sesi 1

Prerequisite

  • Account Docker Hub

  • Account Github

  • Account AWS

  • Ansible

  • Terraform

  • Golang

  • Docker

  • VS Code

Arsitektur Diagram

Create Instance AWS EC2

Buat sebuah server di AWS EC2 bisa create langsung melalui console panel AWS atau menggunakan terraform. Untuk konfigurasi menggunakan terraform sudah diberikan pada artikel Ansible Practice - Session 1.

Install Docker on Instance AWS EC2

Instance AWS EC2 memakai ubuntu 22.04, lihat di dokumentasi install docker on ubuntu 22.04.

jika sudah menginstall Docker di Instance AWS EC2 lalu masukan user Ubuntu ke group docker.

$ sudo usermod -aG docker ubuntu

exit terlebih dahulu dari terminal dan remote kembali. check apakah docker sudah running di instance AWS EC2 nya.

$ docker ps
atau
$ docker container ls -a

Create App Golang

buat folder untuk aplikasi golang dan buka menggunakan VSCode

$ go mod init github.com/****/apiserver

buat file main.go

package main

import "fmt"

func main() {
    fmt.Println("Server running")
}

test apakah running

$ go run .
Server running

selanjutnya install Framework Golang yaitu Gin

$ go get github.com/gin-gonic/gin

edit file main.go

package main

import (
    "os"

    "github.com/gin-gonic/gin"
)

func main() {
    hostname, _ := os.Hostname()
    r := gin.Default()
    r.GET("/", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "code":    200,
            "message": "api server",
            "server":  hostname,
        })
    })
    r.Run("0.0.0.0:8144")
}

coba running

$ go run .

dan akses ke localhost:8144 menggunakan web browser atau bisa juga melalui Postman.

Create Repository Github

buat repository di github untuk mengupload Aplikasi Golang yang tadi sudah dibuat .

$ git add .
$ git commit -m "push app golang"
[master (root-commit) d207657] push app golang
 3 files changed, 129 insertions(+)
 ......
$ git branch -M main
$ git remote add origin https://github.com/mdrdani/container-app.git
$ git push -u origin main
Enumerating objects: 5, done.
......
Mdr{dani} Notes

A digital garden where I plant ideas, share thoughts on DevOps, cloud infrastructure, open-source, and my journey in tech. Keep exploring and happy automating!

Explore Topics

Web DevelopmentReactNext.jsGolangOpen SourceTutorials

Supported By

Codeathome
LampungDev

Made with© 2026 Muhamad Dani Ramanda

Powered by HashnodeHosted on Vercel