Skip to content

SakuBoyz/BOIBOT

Repository files navigation

BOI BOT i[O - O]i

Line bot API implement by golang & gin framework

boibot

Implement stack

  • Logic coding line message (linebot) : Golang
  • API service Golang : Gin Framework
  • Store : database type relational microsoftSQL/SQL Server (mssql)
  • Container : Docker
  • Cloud server : AWS
  • Mapping service to https : ngrok

Team delivery task : WFH

  • manage task case : Trello
  • Version control coding : Gitlab (TODO goal to public repo)
  • video Screen&voice call meeting : Dicord

Credit Data source

How to install

git clone https://gitlab.com/CSBlockchainKmitl/boibot.git
git checkout dev
git pull origin dev

go mod init boibot
go mod vendor

How to run

go run go .

step by step for goal project

  1. เก็บ requirement
  • ที่มาความสำคัญที่เกิดเป็นโปรเจค boibot (ปัญหา)
  • วัตถุประสงค์
  • ประโยชน์
  • หาแหล่งอ้างอิงของข้อมูล ว่ามีความน่าเชื่อถือหรือมั้ย จะขอใช้ต้อมูลต้องทำยังไง
  1. ออกแบบการทำงานระบบ(การทำงานworkflow/api spec&ความสามารถfunc) ที่ตอบโจทย์ requirement

  2. ออกแบบฐานข้อมูล(ER&DB spec) ที่ตอบโจทย์ การทำงานระบบ

  3. เริ่ม implement ระบบตาม api spec ความสำคัญของงานอยู่ใต้การดูแลของ PM

    • line message api
    • update data api get covid19 state from root data source update to db
  4. build source code` to docker images

  5. push docker images to dockerhub

  6. create instance cloud

    • select shopping spec server
    • setting inbound/outbound Security Groups
  7. remote to instance ,pull docker images and run docker container

  8. **mapping public IP whit https by ngrok

  9. copy https://url to line bot webhook

  10. test enjoin with boibot in line app :)

** !! why use ngrok to mapping https

  • ngrok(have Free Trial)
  • line bot webhook : require HTTPS
  • เปิด https and setting domain ไม่ฟรี

1-4. Implement

5. Docker

5.1 Make Dockerfile

  • Make new file by cmd : touch Dockerfile
  • Copy to Dockerfile
#Copy to Dockerfile
FROM golang:latest
# Author
MAINTAINER dangminhtruong
# Create working folder
RUN mkdir /app
COPY . /app
WORKDIR /app

5.2 Docker build images

technology for building and container your applications with env

EX : docker build -t <dockerhub_id>/<projectname>:latest .

#Docker images
docker build -t jiraponjermkure/boibot:latest . 
docker images

see in terminal

REPOSITORY                   TAG                    IMAGE ID            CREATED              SIZE
boibot                       latest                 412b6c8394b1        About a minute ago   828MB

6. Docker push tp dockerHub

7. Create new EC2 instance in AWS

  1. Login AWS console
  2. Shopping server spec :
  • OS : ubuntu v18.09
  • CPU : 2 core
  • RAM : 2 GB
  1. download file.pem is key ssh remote to ec2
  2. remote ssh to ec2 by file.pem
  3. install environment

sudo apt install jq
  1. run docker container
  2. test HTTP request

8. Remote to instance&Docker run container

** after run cmd in terminal : it auto pull docker images from dockerHub(is public repo)

#Docker container
docker run --name boibot -p 1080:8080 -d jiraponjermkure/boibot:latest go run . 
 //My boibot start at 1443 port
docker ps -a

**!!Webhook Linebot : is require url HTTPS

9-10. Mapping Public IP for EC2 to HTTPS by ngrok

mapping <ip:port> to https://url random by ngrok(Free Trial)

#mapping & run ngrok background print log to file.log
ngrok http 172.31.44.106:1080 > ngrok.log &

Copy https://url by ngrok to line bot webhook

EX: https://cb8ee84d.ngrok.io

#get https://url random by ngrok
curl -s localhost:4040/api/tunnels | jq -r .tunnels[0].public_url

11.Enjoin with boibot in line app :)

ngrok (Free Tier)

For quick demos and other simple tunneling needs.
HTTP/TCP tunnels on random URLs/ports
1 online ngrok process
4 tunnels/ngrok process
40 connections / minute

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published