<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Acceth on Medium]]></title>
        <description><![CDATA[Stories by Acceth on Medium]]></description>
        <link>https://medium.com/@acceth?source=rss-bac9ea266915------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0Cgx2e-riDDg8cZ5GiO5dQ@2x.jpeg</url>
            <title>Stories by Acceth on Medium</title>
            <link>https://medium.com/@acceth?source=rss-bac9ea266915------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 23:39:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@acceth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kubernetes (K8S) SaaS on DigitalOcean]]></title>
            <link>https://medium.com/@acceth/kubernetes-k8s-saas-on-digitalocean-f9ac41903a21?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9ac41903a21</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[k8s]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Sun, 18 Aug 2019 19:44:49 GMT</pubDate>
            <atom:updated>2019-08-18T19:44:49.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Easy Kubernetes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*T2qWz6AUlaIUcgoYRpkdWQ.png" /></figure><p>ปกติจะใช้ AWS EC2 ในการลง K8S เองเพื่อทำ Private K8S ซึ่งข้อดีคือ เราจัดการเองได้ทั้งหมด ซึ่งถ้าทำงานจริงก็ควรจะเป็นแบบนั้น แต่ก็จะเสียเวลาและยุ่งยากพอควรและ Cost ค่อนข้างเยอะ ต้องทำหลายอย่าง จึงเหมาะแก่งาน Enterprise Grade</p><p>วันนี้พอดีมีมีงานส่วนตัวที่ทำอยู่ และอยากจะเทส Digitalocean Kubernetes ก่อนหน้านี้ได้ ลองเล่น AWS EKS ที่เป็น K8S แบบ SaaS ก็ง่ายมากพอสมควร</p><p>แต่ช้าก่อน พอมาลองของ DO รุ้สึกว่าง่ายกว่า EKS ไป อี๊กกกกกกกก</p><p>เลยทำให้จำเป็นต้องเปลี่ยนจาก การใช้ Circle CI ในการ Deploy ให้ docker compose จัดการ มาเป็น การลองใช้ DigitalOcean Kubernetes โดยใช้ แค่ Node เดียวในการทำ</p><ul><li>ใน blog นี้จะเป็นการจำลองการทำ K8S บน DO แบบไวๆให้ดู โดยการใช้แค่ Node เดียว</li></ul><p><strong>Prerequisite</strong></p><ul><li>DigitalOcean Account</li><li>AWS Route53</li><li>Project Build From Golang with Dockerfile</li><li>Dockerfile Build Jenkins Image</li><li>Kubernetes CLI</li></ul><h3><strong>Let Started!</strong></h3><ul><li>เปิด Digitalocean Kubernetes 1 Node</li><li>หลังจากนั้น ดาวโหลด k8s context (kube config)</li><li>ทดลอง เรียกใช้ command kubectl</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLkPDH0iRbt8A0HDTd13hA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q4MyAVIiVcUD5IqinCMQ5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3FwmNyJHZ-lE4ARwhTATaQ.png" /></figure><p>จะเห็นว่า เรียก API K8S ได้แล้ว</p><p><strong>สร้าง helm rbac หรือ helm service account role base access control เพื่อ เรียกใช้ k8s package manager อย่าง helm</strong></p><ul><li>ตัวอย่าง file k8s ของ example นี้ จะมี</li><li>jenkins</li><li>docker-registry</li><li>pg-admin</li><li>postgres database</li><li>letenctrypt issuer</li><li>ingress</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bL9_HnJzv88aOYb1wYPpRw.png" /></figure><p><strong>สร้าง SA หรือ K8S Service Account</strong></p><p><strong>สร้าง Docker Registry ไว้ใช้เป็น Private Docker Image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*Agp9ycwMPgY2IDkNDvAt0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*o9JxJ9VX8RlOlbG16uqhSw.png" /></figure><p><strong>เช็คว่า service helm tiller account ขึ้นมาหรือยัง</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*JKu04AFE9pP2Vg3A_QsZNg.png" /></figure><p><strong>ต่อมา สั่งให้ helm สร้าง loadbalancer และ โหลด helm package nginx ingress เพื่อไว้ในการ control nginx ingress กับ loadbalancer</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lPbD9pixgRTRjwr7GImCA.png" /></figure><p><strong>เช็ค service หน่อยว่ารันครบหรือยัง</strong></p><p><strong>สิ่งที่ได้เพิ่มมาคือ loadbalancer กับ nginx ingress default backend controller</strong></p><p>รอ IP Solve ของ Loadbalancer นานนิดนึงประมาณ 1 นาที</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OS86DDwXziWfO1ewlcuJ9A.png" /></figure><p><strong>พอได้ IP Loadbalancer เราก็นำมา เพิ่มใน AWS Route53 ที่เรามี Domain อยู่ ตั้งชื่อ Subdomain ว่า docker-registry</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*dFn9jrVxQIIEeYHSez7YDA.png" /></figure><p><strong>Check Response ผ่าน Console AWS</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P091usv0pdMDPI0bXIpJKQ.png" /></figure><p><strong>helm list เช็คว่า มี helm package ที่เราลงไปไหม</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*Rbm2bam9amVmeb01KvuKVw.png" /></figure><p><strong>หลังจากนั้น ลง package ไว้ทำ cert manager</strong></p><p><strong><em># Add the Jetstack Helm repository</em></strong></p><p>helm repo add jetstack <a href="https://charts.jetstack.io/">https://charts.jetstack.io</a></p><p><strong><em># Update your local Helm chart repository cache</em></strong></p><p>helm repo update</p><p><strong># Install cert manager</strong></p><p>kubectl apply -f <a href="https://raw.githubusercontent.com/jetstack/cert-manager/release-0.9/deploy/manifests/00-crds.yaml">https://raw.githubusercontent.com/jetstack/cert-manager/release-0.9/deploy/manifests/00-crds.yaml</a></p><p>kubectl create namespace cert-manager</p><p>kubectl label namespace cert-manager <a href="http://certmanager.k8s.io/disable-validation=true">certmanager.k8s.io/disable-validation=true</a></p><p>แล้วก็ รอ การสร้าง container ของ cert-manager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjgwnFGveCooVsbJCSnoKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*Qx0xLCwL1e01DGDF8zNNSQ.png" /></figure><p><strong>เมื่อ cert manager พร้อม nginx ingress loadbalancer พร้อม ทีนี้เราก็พร้อมจะ deploy docker registry service ละ</strong></p><p>สร้าง file deployment.yaml ของ docker-registry ขึ้นมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*kABW7GJ_ApZwn55SEF4QYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*94LUs_6V6Wq5ino5wFT8dw.png" /></figure><p><strong>แล้วไปเพิ่ม config ที่ไฟส์ ingress.yaml และ apply ไฟส์ deployment ของ docker-registry ของเรา</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*Q5W0-yh0ynb2oVGoC-ejaA.png" /></figure><p><strong>หลังจาก apply docker-registry deployment เราก็สั่ง run ingress ที่เรา set domain docker-registry ไว้</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*JmQb9nEmaO141lcv47zc4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*CzmeckdhQMJ-zrdf-L11ow.png" /></figure><p><strong>ลองเช็ค ว่า pod ขึ้นมาหรือยัง ของ docker-registry จะเห็นว่า pod ของ docker-registry ขึ้นมาเรียบร้อย</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*XLj56_QvR2T795MLRuMKsQ.png" /></figure><p><strong>ลอง เช็คว่า nginx ingress และ cert manager เราทำงานไหม ด้วยคำสั่ง</strong></p><p>curl -v ตามด้วยชื่อ domain</p><p>จะเห็นว่า สิ่งที่สั่ง <strong>deploy</strong> ไปใน K8S ได้ทั้งการสร้าง <strong>pod,</strong> <strong>service</strong> และทำการ <strong>map nginx ingress</strong> ออก <strong>lenencrypt cert</strong> และทำเป็น <strong>http/2 protocol</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*h1QfHkrUR8qgHtEE5a5tmQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3sqZeEI0FgmxHyaz3OIlw.png" /></figure><p><strong>ต่อมาเราจะมา deploy postgres database กัน เขียน deployment.yaml เหมือนเดิม พร้อมทั้งตั้ง USER , PASSWORD ด้วย และชี้ mount path ของ DB</strong></p><p>จริงๆ ถ้าเป็น Production ควรจะต้องชี้ไปที่ <strong>Persistant Volume Claim (PVC) </strong>ของเรา ปกติทำใน <strong>AWS EC2</strong> ที่ลง K8S เองเราจะชี้ไปที่ <strong>EBS (Elastic Block Storage)</strong> แต่ในนี้เราทำ Example เฉยๆ ประหยัดเงินไม่ตำเป็นต้องต่อ <strong>NFS Storage</strong> ไปข้างนอก ให้เปรืองเงินก็ใช้ Storage ใน Node นี้นี่แหละ :D</p><p><strong>REF : </strong><a href="https://kubernetes.io/docs/concepts/storage/storage-classes/"><strong>https://kubernetes.io/docs/concepts/storage/storage-classes/</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*p-9Ea6k3n2Gx_nlPZUazfg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*2n_fHfEUGHfsqynKpGcnCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*5DEi77_ZaJhCIve7CHwU0g.png" /></figure><p><strong>สั่งเกตเห็นว่ารอบนี้ เราจะไม่เอา postgres db เข้า ingress ใน loadbalancer เราทำเป็น NodePort เพื่อต้องการ จะทำ external IP Port ของ Containerในการ คุยกัน แบบไม่ต้องผ่าน Public IP</strong></p><p>และสั่งรัน kubectl apply -f deployment.yaml</p><p>ทั้ง pg-admin และ postgres-db</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*44ViNr9U1_lX-MCcsjJiAw.png" /></figure><p><strong>เมื่อเรามี postgres db , pg-admin ทีนี้เราจะมา สร้าง pod กับ service ของ jenkins เพื่อเตรียม ระบบ CI/CD ให้พร้อม กับการ Deploy APP ของเรา</strong></p><p>Login Private Docker Registry ของเรา ที่เรา Deploy ไว้ก่อนหน้านี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*OBRldJHNzBhJLVgqnJfXRQ.png" /></figure><p><strong>Build Custom Jenkins Image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5qyzklxZRa7iHDPOX73Dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*343VeiGSGl19tDTYJxibNg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*790H9w4ML83eqVp7Y4JbuQ.png" /></figure><p>curl ไปเช็คที่ private docker registry ของเรา จะเห็นว่ามี image ที่เรา build และ push ขึ้นไปไว้แล้ว</p><p><strong>ทีนี้เราก็มาสร้าง file k8s deployment เหมือนเดิม แต่คราวนี้เป็น jenkins service</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*J1krj2MFp89h7liBfkaPxw.png" /></figure><p><strong>สั่ง kube สร้าง secret ของ docker registry ของเรา</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KUeg4jR0lHqJtCfocaU-Fw.png" /></figure><p><strong>หลังจากนั้นเราก็สั่งรัน kubectl apply -f deployment.yaml ของ file deployment jenkins-service ที่เราทำไว้</strong></p><p>จากนั้นก็รอ K8S สร้าง pod และ service jenkins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*ne0mokGi3xa0fWKNALNQ-w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FOQKrnYc6ki9oCLhCaOCjA.png" /></figure><p><strong>เมื่อ deploy jenkins service แล้วเราก็มาเพิ่ม ingress sub domain ของ jenkins ของเรา และสั่ง run</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*xaRWlSblKLUfB3spYkDZVw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*aNzxVlxNCAQ0RkavxhFt1g.png" /></figure><p><strong>เราจะได้ jenkins ขึ้นมาแล้วก็นำ secret ของ jenkins มาลงครั้ง jenkins จะถามหา first login secret เพื่อทำการสร้าง admin account ต่อไป login ก็จะไม่ต้องใช้ secret นี้อีก</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rhmCQ84DVEQm83tMrzNs_w.png" /></figure><p><strong>เลือก package ที่จะลง</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dBFEAMskpwJ4UK9-v0sYUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NCH68fRwJmojtmZ1cjH1Uw.png" /></figure><p><strong>จิ๊บกาแฟ รอมันลง :D</strong></p><p><strong>เข้ามา ที่ Dashboard Jenkins</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZqzMswbMDF4c1-LVvSuGGA.png" /></figure><p><strong>สิ่งที่ขาดไม่ได้สำหรับ jenkins คือ package เสริม blue ocean</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Lk-IR72PzKbzXDnhWXoUg.png" /></figure><p><strong>เมื่อลง jenkin แล้วเรามาสร้าง domain ของ service ที่เราจะให้ jenkins deploy ให้ผ่านทาง AWS Route53 เช่นเดิม</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axHIn_T8NzP98IKiGt6q3g.png" /></figure><p><strong>ลอง Logout และ Login jenkins ใหม่ ไม่ต้องใช้ secret และแต่ใช้ user pass ที่เราสร้างไว้ เป็น admin</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*djmv8yUUnCaznRGCjbntow.png" /></figure><p><strong>ทีนี้เรากลับมาที่ jenkins เพื่อ config ให้ jenkin ต่อกับ private docker registry ของเรา</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9A9fb1Ecb02_KMbAQeBtJA.png" /></figure><p><strong>หลังจากนั้นเราก็ทำการสร้าง jenkins pipeline</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2IhcH9OcDNxzQqhrGj0mBA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKuRgtaLTFZFBOKu06gZ1A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5zEUW7vBJgS4JdXJFltqQ.png" /></figure><p><strong>เราจะได้ pipeline ที่เราสร้าง และ คือ ยกตัวอย่างเช่น email-service-dev</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEm6tS9U7lMKpRJ_ymVByQ.png" /></figure><p><strong>ลองเข้าไปที่ blue ocean</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*In_uzybrdBLGaW1S1ZvKYQ.png" /></figure><p><strong>ทีนี้ให้เรากลับไปที่ Project App ของเราเพื่อเพิ่ม ไฟส์ Jenkinsfile ไปในนั้นเพื่อ เขียน jenkins pipeline step</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*u6T17rEd96wyxliC2TS-eg.png" /></figure><p><strong>หลังจากนั้นก็ push commit ใน git branch ที่เราเพิ่มไฟส์ Jenkinsfile ไป</strong></p><p><strong>พร้อมทั้ง สั่ง Build Project App ของเรา แล้ว Push ไปที่ Private Docker Registry ของเรา</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nJ3pUkeqCjRYAj_LMBvcw.png" /></figure><p><strong>เข้ามาเพิ่ม ingress subdomain ของ service ที่เราจะทำการ deploy ใน pipeline ที่เราสร้างไว้ ให้ loadbalancer map sub domain ลงไป</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*2ZpgIz_HHkH_nJjQcJZaUw.png" /></figure><p><strong>เช็ค สถานะของ pod ต่างๆ</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*OPDfq8i-tdry_DxCPu2iFA.png" /></figure><p><strong>หลังจากนั้นก็สั่ง Deploy Ingress ที่พึ่งทำการ config เพิ่ม service ใหม่ข้าไป รอ</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*8C6ILt8w8UXwFzWtK0BScQ.png" /></figure><p><strong>ที่นี้เราลืมไปอย่างจะให้ merge branch เข้า develop แล้วทำการ trigger jenkins ให้ทำ pipeline CI/CD เราก็ต้อง config github ที่เราใช้ webhook ก่อน</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cLYTUp8gEQVtToaDYbA4pw.png" /></figure><p><strong>หลังจากนั้นเราก็ทำการ สร้าง file K8S deployment ของ service ทีเราทำ pipeline ไว้ และสั่ง รัน apply deployment นี้</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*xbGWMUxxayzIM3eoh3dqTg.png" /></figure><p><strong>จากนั้นเมื่อเราเตรียมทุกอย่างพร้อมแล้ว เราจะลองทำการ merge request git branch develop ของเรา เพื่อเช็คว่า jenkin ได้รับ webhook trigger ให้รัน pipeline auto ไหม</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ActVvnM5c95xKyuIMcX2Kg.png" /></figure><p><strong>หลังจาก merge เข้า branch develop github จะ trigger jenkins ของเรา และทำตาม Jenkinsfile step ที่เราเขียนไว้ใน repo ก่อนหน้านี้c]h;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q3LLeQ8Dj246G2gQEPVZgw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DnB9kJw5ZUDbNaCOcjqhWA.png" /></figure><p><strong>แล้วเมือรันจนเสร็จแล้วไม่มี Error จาก Unit Test หรือ Build Image หรือ Deploy ก็จะเป็น สถานะ สีเขียว</strong></p><p>แต่ถ้ามมี error ใน pipeline จะเป็นสีแดง และหยุดการทำงาน</p><p>สามารถ กด เช็ค error ที่ console ของแต่ละ step ได้เลย แล้วจะทำการสั่ง run manual re deploy ก็ได้ แต่ก็พังอยู่ดีถ้า พังที่ code ที่ merge มา จึงต้องแก้ ก่อน แล้ว merge ขึ้นมาใหม่</p><p><strong>*** Blue Ocean ตอนจังหวะ Run Pipeline เราไม่ต้อง Refresh เลย step จะไหล Auto ให้เราเห็นเลยเป็นแบบ Realtime ***</strong></p><p><strong>มาเช็ค Email DB สิ หลังจากเรา Deploy App ขึ้นไป มีการสั่ง Run Migration Script หรือไม่ ประกฏว่า มีการสั่งสร้าง Migration DB ตามที่เราเขียนไว้ ใน Project เรียบร้อย</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehHhD__JWQbNqkguFJkHzg.png" /></figure><p><strong>มาเช็ค kube ของเรากันบ้างว่ามี service อะไรรันอยู่ ตอนนี้บ้าง</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bm7YzqyGfGd9t94B_LvRkA.png" /></figure><p><strong>ทีนี้เนื่องจาก code route health ของเราที่เขียนไว้เขียนให้เรียกไปที่ health-test-jenkins จึงทำให้ /health นั่น เป็นหน้า 404 Not Found</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngxqZHQ4lWye33K2iXGzPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ffedVJAuRfAs9hk4WekEOQ.png" /></figure><p><strong>ทีนี้เราจะลองมาแก้ code ให้ /health นั่น work แล้ว merge กลับเข้าไปเพื่อทดสอบระบบ CI/CD</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*6cF6_3u4_HkJmlPDXqyiRA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lOt5TdcDogVurI0QFtPiYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nelEbBK1jMgBWKn6kMqXpw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noS_id59_9nBvmrwyYW1jw.png" /></figure><p><strong>จะเห็นว่าหลังจาก merge jenkin จะได้รับ trigger จาก git แล้วมารัน pipeline แบบ automate CI/CD</strong></p><p><strong>ทีนี้เราจะมาเช็คกันว่า /health work หรือยัง</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ukD-85YKgrsYOhGpiQKytA.png" /></figure><p><strong>จะเห็นได้ว่าหลัง merge /health-test-jenkins ทีเคย เปิดได้ จะเป็น 404 แทนแล้วและ /health นั่น work แทน ลืม Capture ภาพ ดัน ปิด Service ไปหมดแล้วหลังจากทำเสร็จ lol</strong></p><p>ทีนี้เราะมาลองยิง API ผ่าน Swagger ใน App ที่เรา Deploy ไป</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aUIerqBLacbDcAJoxM-VfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*22Uc9pOU-pTSREkUJpV6wg.png" /></figure><p>หากจะเพิ่ม Service อื่นในการทำ pipeline เราก็แค่ create pipeline map git repo ให้ถูก</p><p>สร้างไฟส์ K8S Deployment ให้ App นั้น แล้วใส่ Subdomain ใน Ingress ก็จะเพิ่ม Service ได้</p><p>หรือถ้าอยากทำ ให้มัน Auto Scale ก็ใส่ คำสั่ง</p><p>kind ประเภท<strong>HorizontalPodAutoscaler</strong></p><p><a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/"><strong>Reference Link</strong></a><strong> :</strong></p><ul><li><a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#how-does-the-horizontal-pod-autoscaler-work">Horizontal Pod Autoscaler</a></li><li><a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/">HorizontalPodAutoscaler Walkthrough</a></li></ul><p><strong>ปล. Kubernetes</strong> แบบนี้ ก็พอทำได้ใน ขั้น Develop แต่หากเป็นขั้น Enterprise Grade แล้วควรจะ ลงเอง บน AWS ด้วยอย่างน้อง 3 Node</p><p><strong>1 Master</strong> ในการ <strong>Control Worker Node</strong> ที่มีการลง <strong>Dashboard Kubernetes</strong> ไว้</p><p><strong>2 Worker Node</strong> ที่เป็น เครื่อง ใหญ่ หน่อยเช่น 64 CPU RAM 512GB เพื่อรองรับการ Auto Scale แบบ แนวนอน หรือที่เค้าเรียกกันว่า <strong>Horizontal Pod Autoscaler หากมี Load เข้ามาเยอะแต่อยากประหยัด ถ้า เป็น AWS เค้าจะ เอา Cloud Front มาขั้นก่อน Loadbalancer แต่ถ้าอยากจะใช้ ข้างนอกก็แนะนำ Cloud Flare มากันก่อนเข้า VPC Gateway ของ AWS ที่ใส่ Policy ไว้แบบจัดเต็ม จะช่วยเรื่อง Security และการ DDOS Attack และควรจะทำ VPN ในการ เข้า K8S Controller</strong></p><p><strong>จบ……….</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9ac41903a21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playground Stellar Blockchain with Open API]]></title>
            <link>https://medium.com/@acceth/playground-stellar-blockchain-with-open-api-a5572f9289d9?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5572f9289d9</guid>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Wed, 31 Jul 2019 14:22:08 GMT</pubDate>
            <atom:updated>2019-07-31T14:22:08.650Z</atom:updated>
            <content:encoded><![CDATA[<p>POC using stellar blockchain for move assets usecase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*kOdvgR99DX4l1BUp-8RYsg.png" /></figure><p>TechStack</p><ul><li>Golang 1.12</li><li>Line Messaging API</li><li>Docker</li><li>K8S</li><li>Backend URL Service Swagger : <a href="https://stellar-playground.athiwat.me/swagger/index.html"><strong>https://stellar-playground.athiwat.me/swagger/index.html</strong></a></li><li>Example Use Case Client Use This API Line Official Account : <a href="http://nav.cx/3dWFilD"><strong>http://nav.cx/3dWFilD</strong></a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*F6GKzvIUdq0rnLZMmQpuxA.png" /></figure><p>เริ่มกันเลย …</p><p>api backend จำลองไว้ ให้เทสยิง มีทั้งหมด 4 endpoint ได้แก่</p><ol><li>สร้างกระเป๋า wallet : <strong>POST</strong> <strong>/v1/stellar-accounts</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vd_uaH75TmZLIFwaaKq3oQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VnFju5bSjrAonmhKCY06DA.png" /></figure><p>หลังจาก สั่งสร้างประเป๋า Stellar Account Wallet แล้ว เราก็จะได้ Stellar Address และ Private Key รวมทั้ง โชว์จำนวน เหรียญ THB ที่เราทำการ สร้างและ mint เหรียญนี้ให้ทันที จำนวน 1000</p><p>2. เรียกดู assets ที่มีทั้งหมดของ wallet account <strong>GET /v1/stellar-accounts/{stellarAddress}/assets</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ZpgF4lV88kEVMnrjFHNLg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnPhyBc0qk5YSGXSwBs64w.png" /></figure><p>จะเห็นได้ว่า Wallet นี้ถืออยู่ทั้งหมด 3 เหรียญ โดยที่มีเหรียญที่เรา mint มาคือ THB จำนวน 1000</p><p>3. เติมเงินเข้าประเป๋า <strong>POST /v1/stellar-accounts/{stellarAddress}/assets.topUp</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFh7173XqZzGKtes1p15yA.png" /></figure><p>ในที่นี้เราจะลองเติมเหรียญ THB เข้า Wallet ที่เราทำการสร้างมาเมื่อกี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IlH8jFZ8dng9aw-HYazcDQ.png" /></figure><p>หลังจาก เติมเหรียญแล้ว เราลองมาเช็คดูว่า เหรียญ THB ของเรา Wallet นี้ เพิ่มขึ้นหรือไม่ จาก 1000 เป็น 1099 แล้วหลังจากเราเติมเข้าไป 99.000000</p><p>4. ใช้ในการส่งเหรียญให้ Wallet Account อื่น <strong>POST /v1/stellar-accounts/{stellarAddress}/assets.sent</strong></p><p>ทีนี้เราจะลองโอนเงิน จาก Wallet Account เมื่อสักครู่ที่เรามี 1099 THB โดยจำลองให้ Wallet Account อื่นโอนเข้ามาให้ อีก 1 THB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fyYRS0-ZYOMu76TFgnKSA.png" /></figure><p>ที่นี้ก็ลองมาดูผลว่า Wallet Account ที่เคยมี 1099 นั้น เปลี่ยนมาเป็น 1100 หรือยัง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_3IurdiVEEz4VgjkVQ2bpA.png" /></figure><p>ที่นี้เราอาจจะอยากดู Wallet Account ของเราซิว่าเป็น Dapp (Decentralize Application) หรือไม่ ผมจะลองเอา Wallet Account นี้ไปดู ว่าเกิดอะไรขึ้นบ้างบน Platform อื่นๆ ใน network stellar blockchain ดู</p><ol><li><a href="https://testnet.steexp.com/">https://testnet.steexp.com/</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wv7JesWzaYJuSSnBBIgogw.png" /></figure><p>ที่นี้เราลองเอา Wallet Account ที่เรามี 1100 THB มาเช็คหน่อยสิเคยทำไรมาบ้าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5rxFLAVmRKPOQH-sh0AVCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1UFsh-MCX31hG_vM_Byu6w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpG2Z5HyeNuiDFCFmoE6YQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzxdxH-KdNafkGqVZ5u-mQ.png" /></figure><p>จะเห็นการเปลี่ยนแปลง บน blockchain ทั้งหมดของ Wallet Account นี้</p><p>2. <a href="http://testnet.stellarchain.io/">http://testnet.stellarchain.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhH_xKVH0jPMmpc_h8IjhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xzpuQQztY7NoAZhoqaLGuw.png" /></figure><p>ลองมาดูอีก Platform ก็มีค่าการเปลี่ยยนแปลง state ทั้งหมดของ Wallet Account นี้เช่นกัลลลลลล</p><p>3. <a href="https://stellar.expert/explorer/testnet/">https://stellar.expert/explorer/testnet/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKqZtk-ZSrTSG1crY-hsjg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4shMDeT5ziorgyahfsU7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qFXAm77tKegzRCNsOuoQgw.png" /></figure><p>มาถึง Platform นี้เป็น Platform ที่ชอบที่สุด จะเห็นการเปลี่ยนแปลงแต่ละ State ของ Wallet Account นี้เช่นกัน</p><p>จบแล้วสำหรับการ ใช้ API ที่เราสร้างขึ้นมาทดสอบ กับ Stellar Blockchain</p><p><strong>ทีนี้เราจองลองเอา API นี้ไปทำการต่อกับ อีก Platform สิ เพื่อทำ Use Case เล็กๆ สักอัน POC ในการใช้ API</strong></p><p>ด้วย Platform Line Official Account โดยการใช้ <a href="https://developers.line.biz/en/docs/messaging-api/overview/"><strong>Messaging API</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*HWq0kP4A1rDDgtIVl1lohg.jpeg" /></figure><p>หลังจาก Scan QR Line Official Account Channel เข้ามา กด Menu A แล้วรอการสร้าง Wallet Account จะมีข้อความส่ง มาบอกหลังสร้างเสร็จ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*UuXlpHiDryDCvL_Xi24Szw.jpeg" /></figure><p>จะเห็นข้อมุลที่เราทำการ เรียก API Create Wallet Account</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*_lsga5kallc3glK2jm22pQ.jpeg" /></figure><p>ลองกด เมนู Balance ดู จะเห็นว่าเรามี เหรียญ THB 1000</p><p><strong>ทีนี้เราจะมาลองโอนเหรียญให้ Wallet Account แรกที่เรามี 1100 ก่อนหน้านี้ที่เราทำการสาธิตใน Swagger UI</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*Tbc2OczSxVGLuUYT53cEXw.jpeg" /></figure><p>หลังจากนั้น กด Menu Send Money จะเข้ามาหน้านี้เราก็ กรอก จำนวนเหรียญ address ปรายทาง และ private key ที่ใช้ในการ sign โอน เหรียญของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*60iDulX5XeueA05e5JxdVQ.jpeg" /></figure><p>โอ้วเหรียญของเราหายไป 50 THB ละ ทีนี้เราจะลองมาดู ว่า Wallet Account ก่อนหน้านี้มี เหรียญนี้เพิ่มไหม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZ5atFdL7WoxOqx398rsFQ.png" /></figure><p>จะเห็นได้ว่า มีคนโอนมาให้ 50 THB เพิ่มเป็น 1150 THB จาก ก่อนหน้านี้ 1000 THB</p><p>จบ….</p><p><strong>ปล. นี่เป็นแค่ POC แค่ไม่กี่ Operation จริงๆ มีอีกหลาย Operation เช่น Multi Signature เป็นต้น และอีกมากกมายไว้ทำ Part 2</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5572f9289d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Elastic Transcoder with API]]></title>
            <link>https://medium.com/@acceth/aws-elastic-transcoder-with-api-e29ca8050e7?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/e29ca8050e7</guid>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Sun, 28 Jul 2019 21:30:45 GMT</pubDate>
            <atom:updated>2019-07-29T05:28:03.622Z</atom:updated>
            <content:encoded><![CDATA[<p>POC using transcoder media from AWS Elastic Transcoder with Golang SDK</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*wUwnaQQ3kZ_0njj-B2vNaw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*AEKozVAP5jCHZBeTrQJ0_Q.png" /></figure><p>Demo นี้เราจะมาทำการใช้ AWS Golang SDK ทำ API บ้าง จากก่อนหน้านี้เคยทำผ่าน <strong>AWS Console</strong> ให้ดูแล้ว <a href="https://medium.com/@acceth/%E0%B8%97%E0%B8%B3%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-aws-elastic-transcoder-682903d7fe26"><strong>LINK</strong></a>ในการ Convert Media ให้เป็น <strong>Adaptive Bitrate Streaming HLS</strong> ให้ภาพนั้นบรรยาย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QxebY6BDwOGZayrsFzt6Vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*I_DLBNTzKiIbGv_QwdeGhg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*sGJ1oU2aYx8C9BSjFnxQ6w.png" /></figure><p><strong>TechStack</strong></p><ul><li>Golang</li><li>AWS SDK</li><li>Docker</li><li>K8S</li></ul><p><strong>Prerequisite</strong></p><ul><li>AWS Account</li><li>AWS IAM</li><li>AWS S3 Bucket</li><li>AWS Elastic Transcoder</li><li>File MP4</li></ul><p>มาเริ่มกันเลย…</p><ol><li>Step แรก ต้องสร้าง Pipeline ใน AWS Elastic Transcoder ก่อน</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Km9qlzhbZ9iHe0qBtdhIWA.png" /></figure><p>อื้อหือไม่ได้เข้านาน หมวดนี้ มี Service ใหม่ชื่อว่า Media Convert ทำหน้าที่คร้ายๆๆกัน แต่ราคาถูกกว่านิดหน่อยไหนเข้าไปดูหน่อย ดู จากรูปแล้วทำคร้ายๆ กัน ไว้มาลองทำ API เล่น Part หน้า</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G2VQXUBgR7ZaEQ6WufCFuw.png" /></figure><p>ที่แน่ๆ ราคาถูกกว่า ไม่รวม ค่า Bandwidth CloudFront นะการทำ Cache Media ส่วนค่า S3 มันถูกมากๆๆอยู่ละ (ถ้าไม่ทำพวก Rotate Folder Archive Folder ก็อวกอยู่) เท่าที่ลองกดเข้าไปเล่นดู มันทำมาเพื่อคนต้องการ Convert Media แบบเร็วๆ อารมมี BackOffice ให้ใช้อ่ะ ขาดแค่ Media กับคำสั่งว่าจะให้ทำอะไรบ้าง</p><p><strong>วิธีการคิดเงินก็ประมาณนี้ Media Convert ถูกกว่าเยอะพอควรแต่ถ้าจะเชื่อมต่อ API หรือ ทำ อะไร Advanced ก็ต้อง Transcoder ละ พวก AES256, Pay Per View, Custom Preset, WaterMark, Auto Caption, ส่วนใหญ่บริการพวกนี้ขึ้นอยู่กับความยาว Media</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_XsDlhDnpVFw7YjC1F1p2A.png" /></figure><p>มาต่อ หลังจากสรา้ง Pipeline แล้วหน้าตาเป็นแบบนี้ ก่อนหน้านี้ผมเล่น Convert มาแล้วเลยมี Fail บ้างจากการ เขียนโค๊ดผิด :D</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFQnJIty1XyY145F412vrw.png" /></figure><p>หลังจากนั้นมาเลือก Preset ในการ สั่งให้ Elastic Transcoder Convert ตาม Preset ที่เราต้องการ</p><p>*** แต่หากอยากได้ Custom Preset ต้องสร้างก่อน เพื่อจะนำ PresetID ใน Elastic Transcoder ไปใช้ใน Code ของเราเพื่อใช้ใน API ***</p><p><strong>จากรูปด้านล่างมีทั้งให้เลือก ที่เป็น พื้นฐาน Preset หรือจะ Custom เองก็ สร้าง Preset เอาได้</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63lv2EdxOXQm356xE8rg4Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U-5DA869hJsV7EuHAIXETg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dbH-0TUTvYJignDYbjEFpw.png" /></figure><p>ขั้นตอนตระเตรียม PresetID, PipelineID เรียบร้อยแล้ว ลองมายิง API ที่ทำขึ้นมาหน่อย ใน API นี้</p><ul><li><strong>เลือกสั่งให้ 1 Media Upload Convert ออกมา 2 Preset ในครั้งเดียว คือ Preset HLS 600K และ HLS 2M ด้วยการนำ PresetID ด้านล่าง ไปใช้ใน Code API Convert</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K1jQ00jIpSlM-3J0dzeyQg.png" /></figure><p>มาลองใช้ API ที่ทำขึ้นมาด้วยการต่อ AWS SDK กันเลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmrVRS4VkGig8XRHG4vI8g.png" /></figure><p>Bucket โล่งๆ ที่เราเตรียมไว้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_FChIQAz-E8sEnCRV6ZwA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTAF5CGqKaEZjsGmcNPETQ.png" /></figure><p>กด Browse Clip</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LfQkyrHFgwmQRjfAqX8K_Q.png" /></figure><p>เรียบร้อยยิง API สั่ง Upload และ สั่งให้ Elastic Transcoder ทำงาน ตาม PipeLineID ที่เราสั่งไว้ใน Code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8exbyzJnSzPcLIrb81WaKw.png" /></figure><p>URL Media ที่ Return ออกมาไหนลองเอามาเล่นใน Player HLS หน่อยสิ <a href="https://videojs.github.io/videojs-contrib-hls/">PlayerTest</a></p><p>แต่ก่อนเอาไปเล่นลองเช็ค Status ในระบบ Convert หน่อยว่าเป็นไงบ้างน้าา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZbVMC8PR81g3JXaf2POJVQ.png" /></figure><ul><li>1. Search Jobs เพื่อหา Job ของ Pipeline นี้ว่าที่เรายิง API ไปนั่น Fail หรือ Complete</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8t-70CxBJpHn2n5wXUGHbQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYuS0VjGwe7GppoAwxsDHA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ozO0k3Q09WfJ9KzU6q8KDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dn6Sp-wt7t1tz_a3F-t-5g.png" /></figure><p>2. ระบบ Elastic Transcoder จะบอกรายละเอียดที่ Convert มา แม่กระทั่งว่าอยู่ใน Queue กี่วิ ใช้ เวลา Transcode กี่วิ จะเห็นไว้ว่าไวมาก ตั้งแต่ Submit นี่คือ การ Convert 2 Preset ด้วยนะ สบายใจหายห่วง แต่ก็ต้องคำนวน คอสดีๆ ว่าคุ้มกว่าลงทุนเองไหมแต่ ระบบ เสถียร และ ยืดหยุ่นมาก เหมาะแก่ต้องการทำ Business แนวนี้แบบ ไวๆ ก็สามารถใช้ได้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UdYafWb1iz9RC59uFwm6NA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fuwH-NHpUJTWemIwr2fDWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kwu_RTLnzf4hOva-UlT44A.png" /></figure><p>โอ้ว ระบบ Elastic Transcoder ได้ทำการ Convert Media 2 Preset และ อัพโหลดมาที่ S3 แล้ว แต่ผมไม่ได้ต่อ CloudFront ไว้นะ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2U0dUvm4ZhGdLXx0lqFgA.png" /></figure><p>จาก Folder จะมี Folder Specific ที่ผมตั้งชื่อไว้ในการ สั่งให้ PipeLine Convert แล้ว แยก HLS 600K กับ HLS 2M ไว้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RSswilr0Cwdr5wcEIO7Djg.png" /></figure><p>ภายใน Folder HLS 2M</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d91qWgFmm08WSTDp7hbc6A.png" /></figure><p>ภายใน Folder HLS ธรรมดา 600K</p><ul><li>** ไหนลองเอา ลิ้ง จาก API ไป เล่นดูหน่อยสิ ***</li></ul><p><a href="https://videojs.github.io/videojs-contrib-hls/">Player Test</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T2ZasTVEsSMIJcRiEYxjVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MT8_HoRQj40V1-ndrYULNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gb6qDPyfha3maD5Z3-o13Q.png" /></figure><p><strong>เรียบร้อย ทั้ง 2 Preset เล่นแบบ M3U8 HLS</strong></p><p>จบแล้ว โปรเจ็ค ทำเล่นๆ ยามว่าง</p><p>URL API : <a href="https://transcoder-service.athiwat.me/swagger/index.html">https://transcoder-service.athiwat.me/swagger/index.html</a></p><p><strong>ปล. service นี้อาจจะเปิดให้เล่น ไม่นาน เพราะ เปลือง และลดเหลือแค่ Convert 1 Preset อัพโหลดได้แค่ Media ขนาดไม่เกิน 3MB</strong></p><p><strong>:)</strong></p><p><strong>References</strong></p><p><a href="http://www.jwplayer.com/blog/an-overview-of-audio-and-video-transcoding/?source=post_page---------------------------">http://www.jwplayer.com/blog/an-overview-of-audio-and-video-transcoding/</a></p><p><a href="http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/introduction.html?source=post_page---------------------------">http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/introduction.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e29ca8050e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Open API for Libra Blockchain POC]]></title>
            <link>https://medium.com/@acceth/open-api-for-libra-blockchain-poc-266a21f9ead2?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/266a21f9ead2</guid>
            <category><![CDATA[libras]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[stellar]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Wed, 17 Jul 2019 18:28:13 GMT</pubDate>
            <atom:updated>2019-07-17T18:30:18.470Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fq2PdgQrX0OoIFtOsQvoLg.jpeg" /></figure><p>TechStack</p><ul><li>Golang with Clean <a href="https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html">Architecture</a></li><li>NuxtJS</li></ul><p>Backend URL Service Swagger : <a href="https://api-libra.athiwat.me/swagger/index.html"><strong>https://api-libra.athiwat.me/swagger/index.html</strong></a></p><p>api backend จำลองไว้ ให้เทสยิง ไป libra api testnet มีทั้งหมด 5 endpoint</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3ZgbltiEiDQH2CKUSHD9Q.png" /></figure><ol><li>/v1/wallets -&gt; ใช้สร้าง libra account</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eb5wDbQUyQ3IOrFsJTHyIg.png" /></figure><p>2. /v1/wallets/account.state -&gt; ใช้สำหรับ เรียกดูค่าของ account นั้นๆ ว่ามีการทำ state อะไรไปเท่าไหร่ มีทั้งจำนวน balance ที่เหลือเป็น microlibra ตอนนี้ถ้า create account เราจะทำการ mint libra coin จำนวน 1000 micro libra หรือ เป็นจำนวน 0.001000 * แต่ในระบบ ไม่ได้ทำการ แปลงค่าให้เห็นเป็น microlibra ให้ดู</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gt3GOtscqLlfr-8YjUI-Ag.png" /></figure><p>3. /v1/wallets/account.transfer -&gt; ใช้สำหรับ โอนย้าย เหรียญ libra coin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MVbYB9jp8fsJT7R0BRhG-g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JfaFGZwo2kEWWcUAb3UjzA.png" /></figure><p>4. /v1/wallets/mnemonic -&gt; เนื่องจาก api endpoint เส้นแรกเราทำการ generate mnemonic phrase auto ทำให้เกิด usecase ที่อยากให้ user สร้าง account ด้วย mnemonic phrase ตัวเองเพื่อง่ายแก่การจำในการ login เข้าระบบ frontend ที่ทำ POC โดย user สามารถ สร้าง libra account ด้วยการใส่ mnemonic phrase ของตัวเองได้ตามใจชอบ (ในตัวอย่างผมอยากมี mnemonic phrase เป็น helloworld1234)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8GRRnf5g7t94Ixsbxih7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYKxZKpeKRdufRKBNeWjUw.png" /></figure><p>5. /v1/wallets/mnemonic.auth -&gt; เส้นนี้เราทำการ POC account ที่ถูกสร้างจาก mnemonic phrase เอง เพื่อนำมา login เข้า ระบบ POC frontend</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*td2FH3j1gH-OFTgC1_8nvw.png" /></figure><p>*** libra account นั้น สามารถ transfer เหรียญ libra ให้ตัวเองได้ในตอนนี้ balance จะเท่าเดิมแต่ state จะมีการเปลี่ยนแปลง คือ received sent sequence จะเพิ่มอย่าละ 1 ***</p><p><a href="https://developers.libra.org/docs/life-of-a-transaction">Life of a Transaction · Libra</a></p><p>มาถึง Frontend บ้าง</p><ol><li>ลองทำการสร้าง libra account ด้วย mnemonic : helloworld</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fvV1Pk85MGWTzEGw8xug8A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rJvZB1smxy-eDsMY5g2Pzg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MiAk80QiHvawhsOadNs7BQ.png" /></figure><p>2. เราจะลองทำการ โอน libra coin เพื่อทดสอบกัน ด้วยการ โอน 1 microlibra ไปให้ account helloworld2 ที่ได้ทำการสร้างไว้ก่อนหน้านี้แล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y61z63KVuzXaTQTrL_zAiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wP0FN81j8YLpf_NUGlKULQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Azp9TsQhV9l7GJSVn8tDcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Z7NQF-j0_cOLrJYK91tRA.png" /></figure><ul><li>วิธี sign การ โอน asset แบบนี้ ไม่ถูกซะเท่าไหร่ แต่เนื่องจากแค่ทำ POC เฉยๆ ไม่จำเป็นต้อง implement multisig หรือ sign transaction แบบ stellar</li><li><strong>** ทีนี้ถ้าเราอยากจะรู้ว่ามัน account นี้ มีอะไรเกิดขึ้นบ้าง จาก web อื่นก็สามารถทำได้ อีกอย่าง api ของ libra น่าจะยังไม่เสร็จ สมบูรณ์ ทั้งหมด น่าจะมีอะไรให้เล่นอีกเยอะ ***</strong></li></ul><p>ลองเข้ามาที่ web : <a href="http://libra-explorer.net/account/1ef6efbb0a6743f621170706ac1ea4852fc41aa1629f88d6154ef7bb526406eb">http://libra-explorer.net</a></p><p>และทำการ นำ source address ของ helloworld มาแปะเทสดู ผลที่ได้คือ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BPdFeJZOuzXrIet-YE-x7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WMIt4S8llAfoye45N7grdQ.png" /></figure><p>จะเห็นว่าเหลือ 0.000999 จาก ตอนที่เรา create wallet account ที่ระบบเราได้ mint เหรียญ 1000 libra เท่ากับ 0.001000 แต่ระบบบเราไม่ได้ทำ การแปลงเป็น microlibra ให้ เลยทำให้เห็นเป็น 1000 แต่เว็บนี้ทำการแปลงให้เรียบร้อย</p><p>— — จบแว้ว งานเขียนยามว่าง — —</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=266a21f9ead2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build VueJS แล้วมาทำ CI/CD ด้วย Circle CI, AWS S3, AWS Route53, AWS CloudFront กัน]]></title>
            <link>https://medium.com/@acceth/build-vuejs-%E0%B9%81%E0%B8%A5%E0%B9%89%E0%B8%A7%E0%B8%A1%E0%B8%B2%E0%B8%97%E0%B8%B3-ci-cd-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-circle-ci-aws-s3-aws-route53-aws-cloudfront-%E0%B8%81%E0%B8%B1%E0%B8%99-686eefcb5fb0?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/686eefcb5fb0</guid>
            <category><![CDATA[cloudfront]]></category>
            <category><![CDATA[route-53]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Wed, 18 Apr 2018 11:35:04 GMT</pubDate>
            <atom:updated>2018-04-18T11:59:41.502Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*N2AwLfjuufUOt-hsqzFnfA.png" /></figure><p><strong>สิ่งที่ต้องมี</strong></p><h4>Prerequisites</h4><ul><li><a href="https://github.com/">Github Account</a></li><li><a href="https://circleci.com/">CircleCI Account</a></li><li><a href="https://aws.amazon.com/">AWS Account</a></li><li><a href="http://docs.aws.amazon.com/cli/latest/userguide/installing.html">AWS CLI</a></li><li><a href="https://github.com/vuejs/vue-cli">VueJs CLI</a></li><li><a href="https://nodejs.org/en/">NodeJs</a></li></ul><p>เริ่มกันเลย….</p><ol><li>สร้าง Github Repository</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79GbdHSGzHEQoW-J99ajoQ.png" /></figure><p>2. ลง VueJs CLI และ AWS CLI</p><pre>$ <strong>npm install -g @vue/cli</strong><br>$ <strong>brew install awscli</strong></pre><p>3. Build VueJs webpack ด้วย Vue CLI</p><pre>$ <strong>vue init webpack vuejs-ci-cd-aws</strong></pre><pre>$ <strong>vuejs-ci-cd-aws</strong><br>$ <strong>git add .</strong><br>$ <strong>git commit -m &#39;ini project demo vuejs-ci-cd-aws with s3&#39;</strong><br>$ <strong>git remote add origin https://github.com/&lt;user&gt;/&lt;repository-name&gt;.git</strong><br>$ <strong>git push -u origin master</strong></pre><p>4. Setup S3 เพื่อสร้าง Bucket ในการเก็บ File เว็บของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r15Gsaif8n_rJUilCfQfZQ.png" /></figure><p>5. หลังจากนั้นให้เข้าไป Set การเรียก File Host นั่นก็คือ index.html ไว้ก่อนและ Set ให้เป็น Public</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kp3DYu0Iocfra8lRjX7dmA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wh8DCq0f-dxf_SqdMXokxw.png" /></figure><p>6. หลังจากนั้นให้กดเข้าไปที่ Menu Permission เพื่อ Set Policy จริงๆ แล้ว AWS มีเว็บไซต์ generate policy ด้วยนะจะบอกให้ <a href="https://awspolicygen.s3.amazonaws.com/policygen.html">https://awspolicygen.s3.amazonaws.com/policygen.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GMXZ4_tqrrJWLYtew7pS6w.png" /></figure><p>7. สิ่งที่ขาดไม่ได้คือ AWS IAM เพราะเราต้องไป generate access key และ secret key เพื่อ เปิดให้ AWS CLI นั้นเรียกใช้งานได้จาก Terminal Console ของเรา ไม่ว่าจะเป็น MacOSX Window หรือ Ubuntu</p><p>โดยเข้าไปที่ Service IAM ของ AWS หลังจากนั้นไปที่ Users แล้วกด Add เพื่อเพิ่ม User เข้าไป แล้วทำ การ Create Group Policy เพื่อ Add Permission ในการ Control AWS S3 ในนี้ผม Add Permission เป็น Full Access แต่จริงๆๆแล้วสามารถแยกได้ เป็น Role เป็น User แต่ละ User ว่าจะเข้าได้ถึงระดับไหน Readonly หรือ Full Access หรือเข้าถึงระดับไหนมีระเอียดยิบ</p><p>พอ สร้าง User และ Add Permission เสร็จแล้ว ให้กดไปที่ Menu Security credentials เพื่อ รับ Access Key และ Secret Key รวมถึง ดาวโหลดส์ credential.json มาเก็บไว้ที่เครื่องเผื่อลืมในกรณีที่ gen แล้วลืม gen ใหม่ได้ แต่…ช้าก่อน Service ที่ถูกผูกไว้กับ Access key และ Secret key เดิมจะใช้ไม่ได้นะ เพราะมันคือการ Revoke Permission นั่นเอง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TL9NEBCtnV7AV0mty5CX8w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v_Kf4Jdk_zJgOE5TLSsLYA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ouje4L2BfmRVs7Dl8VlYw.png" /></figure><p>8. ต่อมาทำการ Setup Config AWS CLI ใน คอมของเราก่อน ที่ได้มาจากการ สร้าง User ใน AWS IAM เพื่อที่เราจะได้เรียกใช้คำสั่ง SDK ต่างๆ Command Line ต่างๆ ของ AWS ได้ในคอมเรา</p><pre>$ <strong>aws</strong> <strong>configure</strong><br>AWS Access Key ID [None]: xxxxxxxxxxx<br>AWS Secret Access Key [None]: xxxxxxxxxxxxx<br>Default region name [None]: <strong><em>your-region</em></strong><br>Default output format [None]: <strong><em>json</em></strong></pre><p>9. ทีนี้ เราก็มี Vue CLI AWS CLI สร้าง Project Vue Webpack เรียบร้อย Up ขึ้น Git เรียบร้อย มาถึงการ Set Circle CI ละ ผมเลือก Login ด้วย Github เพราะต้องการเชื่อมต่อ กับ Git Repository ของในนั้นอยู่แล้วเพื่อนทำการ Trigger และ Build and Deploy Website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWqyM4Sm9H2GFzgRT0hpdw.png" /></figure><p>9. มาถึงหน้า เลือก Repository ที่เราจะทำการ Trigger CI/CDในการ Build Test Deploy เลือก Setup Project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Smsj4hNaCC_yAz0DB_nstg.png" /></figure><p>10. มาที่หน้า Setup Build เลือก Linux -&gt; Node แล้วเลื่อนลงไป Setup File yml ด้วยการ Copy คำสั่งไปวางใน Folder .circleci ใน Repository ของเรา</p><pre>$ mkdir .circleci &amp;&amp; touch ./circleci/config.yml</pre><p>จากนั้น กด Start Build</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fCRmxHcw2BzuYe9Sz2AWTA.png" /></figure><p>รอ Circle CI Build</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvZKdXEWg3ZpDZnhZCht9g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ls-GU0WNOAMaYj3ajxw6ow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WfheRvzO6Tfda_MW96SDUQ.png" /></figure><p>11. หลังจากนั้นมา Set และลอง แก้ไข Website ของเราดุหน่อยสิจะ Build Test Deploy ใหม่ไหมน้า…….</p><p>หลังจากแก้ไขแล้วก็ Commit แล้ว Push ขึ้น Git ดู Github ที่เรา Invoke Circle CI ไว้จะทำการ Trigger ไปที่ Circle CI ด้วยตาม File Config Yml ของเรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkNP9aIUK_uu5wyhBWsMWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*43pISDJNfPaFO3WlPYHGZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*96z63CdYdbTlWgbLIO08-Q.png" /></figure><p>ภาพตอนกำลัง Build Test Deploy จะมี Status บอกแบบ Realtimeและแจ้ง Error ระดับนึง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TT7MzyeeLKGN9wAVeJcsgw.png" /></figure><p>หลัง Run Build Test Deploy ผ่านแล้ว จะเปลี่ยน Status</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBYCvoz2mAp_UPBLHH1kIg.png" /></figure><p>ไหนลองเปิดดูสิ หน้า เปลี่ยน ไปหรือยัง น้า CI/CD เสร็จ เอ้….. หน้าคุ้นๆ แถมมี กะหรี่ ลีนุ๊ก เอ้ย กาลี ลีนุ๊ก เอ้ย ถุกแว้วววว Tool Hack ยอดนิยมที่ใช้ในการทำ Owasp Penetration Test</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKS1WNZ2Lb-3HbRRyO93XQ.png" /></figure><p>ก่อนหน้านี้เป็น Basic ของ VueJs CLI ที่ Build ขึ้นมา ไหนๆ ก็ไหน อะลองแก้แล้ว Commit ขึ้น Git ใหม่ดูสิ ระหว่างรอ Circle CI Build เราสามารถเข้าไปดู ลำดับขั้น ของการทำงาน Build ด้วยการกดที่ ปุ่ม Running จะมี รายละเอียดของการ Build บอกว่ากำลังทำอะไรอยู่ ขั้นตอนไหนแล้ว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-rD7vxK2XBgIQoqg4U78Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XqnEnKaH3sgNDdWMyG-txg.png" /></figure><p>12. จากนั้นให้ไปที่ CloudFront เพื่อสร้าง Cache Domain ก่อน เลือก Web เข้าไปก็เลือก Setting domain ที่เรามีใน Route53 ว่าจะใช้ Subdomain ใด เพื่อ ลิ้งกับ Domain Cache ใน CloudFront ของเรา</p><p>ปล. ความน่าเบื่อของ CloudFront ขึ้นอัพทีรอนาน โคตร 10 นาทีขึ้น เพราะมัน Deploy ไปหลายที่ ต่อให้ ลดมามากสุดก็ยัง บังคับ Deploy 3 ที่ คือ</p><p><strong>Use Only US, Canada and Europe</strong></p><p><strong>Use Only US, Canada, Europe and Asia</strong></p><p><strong>Use All Edge Locations (Best Performance)</strong></p><ul><li><strong>Origin Domain Name : S3 Endpoint URL</strong></li><li><strong>Origin ID: </strong>S3-xxxxxxx</li><li><strong>Viewer Protocol Policy: </strong>Redirect HTTP to HTTPS</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxpTWQ5XLncnL4gRc2t5PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkUxVTRQm5qeL1BwgulAqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ucwfxBxIQDPWCDkWuGnkCA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2w_zuriJBkaiaLDhqKgRA.png" /></figure><p>13. หลังจากนั้นให้ไปที่ Service Route53 เพื่อ Add Subdomain ที่เราทำการลิ้งไว้กับ Domain CloudFront (ระหว่างรอ CloudFront Deploy จะนานหน่อยนะ)</p><p>ด้วยการนำ Domain ของ CloudFront มาใส่ใน Alias ของ Route53 Subdomain หรือ Domain ที่เราต้องการลิ้งกับ CloudFront</p><p><strong>*** ที่สำคัญ จะต้องไปสมัคร ใช้ Certificate SSL TLS Free ของ AWS ได้ที่ ACM AWS Certificate Manager ก่อนนะจ๊ะ ด้วย Certificate Free นั้น สามารถใช้ได้สองวิธีคือ ผ่าน CloudFront และ AWS Loadbalancer ***</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZOIO06uszaMgoyv-1i2Mw.png" /></figure><p>ถ้ามีแล้วก็ใส่ไปที่ Config ตอน สร้าง CloudFront ที่ใช้ File Server ผ่าน Endpoint ของ S3 ได้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*opHJQt2x1hvrPNmdkxaj9w.png" /></figure><p>แทนแท่นแท้นนนนนนน เราก็ได้ Domain SSL HTTPS ของเราแล้ววว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WTW9r_Tkio0fzj38OY2Ykw.png" /></figure><p>จบปิ้งกิงก่องแก้ว ข้อมูล ใน S3 ผมนั้น เปิด Public นะ ไม่ถือว่าคนเข้ามาดู นั้น Hack อิอิ ต้องตามกระแสหน่อย 555+</p><p><strong>Inspiration</strong></p><p><a href="https://rossta.net/blog/deploying-vue-to-amazon-s3-with-circleci.html">https://rossta.net/blog/deploying-vue-to-amazon-s3-with-circleci.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=686eefcb5fb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Laravel + Docker = Laradock]]></title>
            <link>https://medium.com/@acceth/laravel-docker-laradock-753382ee2292?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/753382ee2292</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[laradock]]></category>
            <category><![CDATA[docker-compose]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 02:44:46 GMT</pubDate>
            <atom:updated>2018-04-17T02:44:46.864Z</atom:updated>
            <content:encoded><![CDATA[<p>ลองเล่น Laravel กับ Docker ด้วย Laradock บน On Click App ของ Digital Ocean</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ksZylm_23jMmbiYYZBNZzw.png" /></figure><p>เริ่มด้วยการ เปิดหน้า Dashboard Digitalocean ไปที่ หน้า Create Droplets</p><p>เลือก One Click Apps</p><p>เลือก Docker CE</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4OsaQCBX5-jqIORHkX4hug.png" /></figure><p>หลังจากนั้น ssh เข้า server</p><pre><strong>$ </strong>ssh root@xxx.xxx.xxx.xxx</pre><p>เมื่ออยู่ใน Server</p><pre><strong>$</strong><em>apt-get install git<br></em><strong>$</strong><em>git clone https://github.com/laravel/laravel</em><br><strong>$</strong><em>cd laravel</em><br><strong>$</strong>git submodule add https://github.com/Laradock/laradock.git<br><strong>$</strong>cd laradock<br><strong>$</strong>chmod +x /usr/local/bin/docker-compose</pre><p>ทำไล่ไปทีละขั้น</p><pre><strong>$</strong><em>cp env-example .env<br></em><strong><em>$</em></strong><em>docker-compose up -d nginx mysql workspace</em></pre><p>แล้วก็รอ มันลง Image และ Container Start</p><p>พอลงเสร็จแล้วท่านจะได้รูปนี้…..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yepy15ca41-voKXO3dqTDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkPoRaEYdTOr9crvDmeBKw.png" /></figure><p>หลังจากลง Environment เรียบร้อยมี nginx mysql ทีนี้มาถึงการลง Laravel</p><pre>$docker-compose exec workspace bash</pre><p>แถ่นแทนแท้นนนนนนน แล้วเราก็ วาปเข้ามาใน workspace ของ laravel แล้ว ภายใน laradock</p><p>*** จริงๆมันไม่ต้องใช้ wortkspace ของ laradock ก็ได้ถ้าเราอยากย้าย laravel path ออกมาข้างนอกให้แก้ config file .env</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f-H7YslF02qkLNC3YGd-aA.png" /></figure><pre><strong>$</strong><em>composer install</em> <br><strong>$</strong><em>cp .env.example .env</em> <br><strong>$</strong><em>php artisan key:generate<br></em><strong>$</strong><em>exit</em> <br><strong>$</strong><em>cd ..</em> <br><strong>$</strong><em>sudo chmod -R 777 storage bootstrap/cache</em></pre><p>Composer Install ตาม step ลงมาเรื่อยๆ จนเสร็จ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mq3CcGcQMatk4hb59T0tAg.png" /></figure><p>เย้เสร็จแล้ววววววว ไหนลองรันดูหน่อยสิ</p><p>สวัสดี Laravel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKllqPson8dHf9iXyWmvQw.png" /></figure><p>เสร็จแล้วทีนี้ก็ เขียนโค็ดต่อแล้ว up ขึ้น git แล้ว ต่อยอดไปทำ CI อีกที</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=753382ee2292" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker Stack แบบง่ายๆ ไวๆ ด้วย Docker Compose]]></title>
            <link>https://medium.com/@acceth/docker-stack-%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86-%E0%B9%84%E0%B8%A7%E0%B9%86-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-docker-compose-a1a94a42b2e5?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1a94a42b2e5</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[dockerfiles]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Tue, 20 Feb 2018 08:13:27 GMT</pubDate>
            <atom:updated>2018-02-20T08:33:13.281Z</atom:updated>
            <content:encoded><![CDATA[<p>ชวนทำ Development Mode แบบง่ายๆ บน Local Machine ด้วย Docker Compose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D4rgnq-hsIkLEzDHhlsL2A.png" /></figure><p>วันนี้มาลุยการทำ local development ด้วย docker compose ในการทำ wordpress</p><ol><li>ก่อนอื่นต้องลง Docker CE ก่อน Docker Community Edition <a href="https://www.docker.com/community-edition">https://www.docker.com/community-edition</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*2pr-YC_VilSY5KlOiRDDrw.png" /></figure><ul><li>Start Docker CE จะมี Icon ขึ้นด้านบน macOS HighSierra</li></ul><p><strong>2</strong>. หลังจากนั้นสร้าง File <strong>docker-compose.yml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*juDUBtlgcdARrlPp6UGnAQ.png" /></figure><ul><li>ใน ไฟส์ นี้ก็จะเป็น ไฟส์ที่ Control การสร้าง Images Mapping Image Valume Set Environment ต่าง ในนี้ประกอบไปด้วยการเรียกใช้ Images <strong>nginx , php 7.1, redis, mariadb 10.1, elasticsearch, kibana</strong></li><li>เพื่อนำมา Build Image ในเครื่องวของเรา แล้วจัดการ Up เป็น Container ภายในเครื่องของเรา</li></ul><p><strong>3</strong>. ต่อมาสร้าง Folder Config และในนั้นสร้าง Folder nginx เพื่อทำการ Set File vhost.conf ขึ้นมา ทำการ Set แบบ Default แต่เพื่อ fastcgi cache fix นิดหน่อย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*SkWCrKmyj5McmB6b7oULDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8rlytdiMwiKVRTOaG5gMPg.png" /></figure><p>4. จากนั้นมา สร้าง Folder php-fpm เพื่อ Set Config php-fpm เพิ่มอีกนิดหน่อย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eNqtJxElIXayaDVl89RQKg.png" /></figure><p>ส่วนอีก File php.ini ก็นำมา config เพิ่มด้วยเพื่อ ในการ Build Image จะได้ Map file ไปใช้ใน Image ของ Container เลย</p><p>5. ต่อมาให้สร้าง Folder www เพื่อ เก็บ folder หรือ ไฟส์ ทั้งหมด ที่เราจะ Map กับ Port 80 ในการรัน Container เรียกใช้ nginx php ในนี้ผมเก็บ Folder <strong>wordpress</strong></p><p>*** อย่าลืม cp wp-config-sample.php wp-config.php เพื่อ Set config ของ <strong>wordpress</strong> ด้วยนะจะ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*CIyH5II2P4G_NoBNZpspBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c2gfV0tJcSyKA_Gcvcsdcg.png" /></figure><p>6. ทีนี้เรามาเริ่มการ Run Docker Compose ได้แว้ววววว</p><p>เช็ค Image และ Container หน่อยสิ มีอะไรอยู่ไหม น้าาาาา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yjn9TqVVlP2_oQvyAY_R4A.png" /></figure><p>โล่งงงงงงงเชียวววววววว</p><ul><li>อ่าวงั้นลุยเลยยยย Run Build Image ก่อนเลยงั้น</li></ul><p>$ docker-compose build</p><p>…… รอมัน Pull และ Build Image ตาม File Docker ใน Folder php-fpm และ Docker Compose ที่เรา Set <strong>Environment Image Volumes Links Ports</strong></p><p>นานหน่อยนะ ประมาณ 1 นาที</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1OX1qFtAUwxyrE4TatAgzg.png" /></figure><ul><li>เช็คหลังจาก Build Images หน่อยสิ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j2PTPwKpUyYPA_8iSx6eAg.png" /></figure><p>7. มา Run เพื่อสร้าง Container ต่อเลย</p><p>$ docker-compose up -d</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkCJqkJpwoMII58ofYPrVw.png" /></figure><ul><li>เช็คหน่อยสิ Container ขึ้นหรือยัง</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4k8n85FqEty09b23jKmAxw.png" /></figure><p>8. Container ขึ้นแล้ว มาเทสกัลลลล</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7N8Gt8hJWzYo6p2arW_c2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cn78HSsO4tHJoesTnUVvMA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QG2sfqpXuGCPnwBGH3Muw.png" /></figure><p>มาแล้ววว Wordpress ทีนี้มาดู Redis Elasticsearch Kibana PhpMyadmin หน่อยสิ</p><ul><li>phpMyadmin</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RhrWFcYSwB73L5OqV_BIfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMcTXwO981uszwdioA8UNg.png" /></figure><ul><li>Elasticsearch</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iad7Vb-u0jfgkDNcXzcpZA.png" /></figure><ul><li>Kibana</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMoML_kozo_u9SmXqgLDVg.png" /></figure><ul><li>Redis ผมใช้ โปแกรแกรม <strong>Keylord </strong>ในการเทส</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4h7H73a9QiZtGa_5kL7uUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mujBZyFRkkW7PQwuwd4nJQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVUVVkb2Ce1vEeLfvkyWVw.png" /></figure><p>จบอย่างสวยงามตามท้องเรื่อง <strong>nginx php phpmyadmin mariadb elasticsearch kibana redis</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SitzuCVPSYpUCmmKYzRbDg.png" /></figure><p>ลองไปเล่นกันดูครับเข้าใจ Docker แบบง่าย แบบเบสิค แล้วค่อยไปต่อยอด <strong>Container Service Management พวก Kubernetes AWS ECS Docker Swarm MESOS Rancher Netflix-Eureka</strong></p><p><strong>Repo → </strong><a href="https://github.com/athiwatp/POC-docker-wordpress-es-pma-redis"><strong>https://github.com/athiwatp/POC-docker-wordpress-es-pma-redis</strong></a></p><p>Clone มาเทสกันได้ อันนี้ ไม่ได้ Private Project อิอิ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1a94a42b2e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ลองรวบรวมสิ่งที่เราทำ My Developer 2018]]></title>
            <link>https://medium.com/@acceth/%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B8%A3%E0%B8%A7%E0%B8%9A%E0%B8%A3%E0%B8%A7%E0%B8%A1%E0%B8%AA%E0%B8%B4%E0%B9%88%E0%B8%87%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B9%80%E0%B8%A3%E0%B8%B2%E0%B8%97%E0%B8%B3-my-developer-2018-536c537a4cc5?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/536c537a4cc5</guid>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[developer]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Wed, 24 Jan 2018 09:10:05 GMT</pubDate>
            <atom:updated>2018-01-24T09:10:05.945Z</atom:updated>
            <content:encoded><![CDATA[<p>บทความนี้ไม่มีไรแค่อยากทำเก็บไว้ดูของตัวเอง อิอิ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JSC9t2-VIr3f-4Y-zmezkg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LiJK4gE_PmIQJEPmpqM_aQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2zGbGUephLq2GXcwcZXdbA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDwclPqo8fq7i71InG50WA.png" /></figure><p>ชีวิตของการเป็น Developer ตัวน้อยๆ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=536c537a4cc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ต่อยอดจาก BlockChain ด้วยการทำ Wallet]]></title>
            <link>https://medium.com/@acceth/%E0%B8%95%E0%B9%88%E0%B8%AD%E0%B8%A2%E0%B8%AD%E0%B8%94%E0%B8%88%E0%B8%B2%E0%B8%81-blockchain-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-wallet-7c3b27949c9c?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c3b27949c9c</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Tue, 16 Jan 2018 11:06:29 GMT</pubDate>
            <atom:updated>2018-01-16T11:06:29.268Z</atom:updated>
            <content:encoded><![CDATA[<p>รอบนี้มาทำ BlockChain Wallet Concept 101 กัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*OkVPEcRUaC3yqygSg-1nKA.jpeg" /></figure><p>ความเดิมตอนที่แล้ว <a href="https://medium.com/@acceth/%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-crypto-js-%E0%B8%97%E0%B8%B3-blockchain-101-ae9905ac3091">https://medium.com/@acceth/%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-crypto-js-%E0%B8%97%E0%B8%B3-blockchain-101-ae9905ac3091</a></p><ul><li>รอบนี้มาทำโค๊ดให้เป็น แบบทันสมัยหน่อย NodeJs แบบ ใช้ TypeScript เพื่อทำการแยก Function ของการทำ BlockChain Wallet Concept</li></ul><p>เริ่มได้…</p><p><strong>1.ไฟส์แรก คือ main.ts</strong></p><p>ใน main.ts นี้จะเป็นการ Setup การทำงานของ Node Server เพื่อทำ Route การทำงานต่างๆ ของระบบ รวมทั้งการใช้งาน ของ Route Wallet และ Transaction รวมทั้งการทำงานแบบ peer 2 peer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYT5c4UnM7iKffGjK8-6Qg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oM8e3eOYtpsOCugpBzEqYQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZpvtW1SG6ei2uPKqVrhmBg.png" /></figure><p><strong>2 . ไฟส์ blockchain.ts</strong></p><p>ในไฟส์ blockchain.ts นี้เหมือนเดิมพระเอกคือ Crypto-Js เพียงแต่รอบนี้เราเปลี่ยนการเขียนจาก NodeJs ธรรมาดามาเขียนแบบ <strong>TypeScript</strong> รอบนี้เรา Gen Block และ Fixed ค่าของกระเป๋าตัง Wallet ให้ <strong>100 บาท </strong>สำหรับคนที่ <strong>Initial Block</strong> เข้ามาในครั้งแรก แต่มีการเพิ่ม Function การทำงาน การ <strong>Validate Chain , Match Block Content, Check Valid Hash และ Function GetAccountBalance</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7uw32H_oAolveVW2GzaysQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mKH1rfWOuDgnGLORjS1fQg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gh8EfHF3_gdWsl_g8vCzoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOLcYEBUtyfq8NKi6ExdSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LI3l__f9Qm59dryWa41THg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ap-n-jrmphpLBIWRYdrFTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GY4hmwu0JoJX6CfO8krM7w.png" /></figure><p><strong>3. ไฟส์ wallet.ts</strong></p><p>ไฟส์นี้สำคัญมากกับลุกค้า ในกรณีไปทำจริง เพราะเวลาเรา Initial BlockChain แล้วระบบจะสร้าง file<strong> private_key</strong> มาเก็บ <strong>hash key</strong> เพื่อ <strong>Map BlockChain Hash Block</strong> เข้ากับ <strong>private_key</strong> ที่เรา Gen ให้ลุกค้าคนนั้นๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*u2DJ-bI1dzaJVpW8MzjYog.png" /></figure><p>มาดู Function ใน ไฟส์ wallet.ts กันต่อ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFy_2xlbDLY4ZFvWXNejsQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FMpwyEX3HBdeazXkWjMrzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vaHJ5hiQTFetfmt-pMDlaA.png" /></figure><p><strong>4. มาถึงขั้นตอนการรัน เทสละ สำหรับ BlockChain Wallet Concept 101</strong></p><pre>$ npm i<br>$ npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hHVgmJEff7VIzF9qEti2vw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SuCP0Kb1rSIm85RJ2pLCmQ.png" /></figure><p><strong>5. ทีนี้มาใช้คำสั่ง โชว์ Block ของเราหน่อยสิ</strong></p><p>เงินในกระเป๋ามาแว้ว… 100 บาท</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jieBFm6Z_-g1JgHdw5VFEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2-WShIc8-bBF_gzmKpO6rQ.png" /></figure><p>6. ไหนมาลองยิง API เช็ค Balance Account หน่อยสิ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YTjqAZUpLotVe2a_NDzPzA.png" /></figure><p>7. ทีนี้มาลองเติมเงินเข้า Wallet หน่อนสิ สัก 50 บาท ไปที่ <strong>Hash Block</strong> ของเรา</p><pre>$ curl -X POST http://localhost:3001/mineBlock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*977oTsFr9aT2yXGT4AOrrg.png" /></figure><p>กลับมาเช็ค Account Balance อีกทีดูสิเงินเข้าไหม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TT_s6OOSC4_bWHmeDp2X7Q.png" /></figure><p>โอเครเงินเข้า กระเป๋าตังละ ฮิฮิ</p><p><strong>8. คราวนี้กลับมาเช็ค BlockChain Block Content ของเราสิว่ามี Transaction อะไรเข้ามาบ้างก่อนหน้านี้</strong></p><pre>$ <strong>curl</strong> <a href="http://localhost:3001/blocks">http://localhost:3001/blocks</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M-RT7iDbVHeCNQCoW9AjnQ.png" /></figure><p>รองเอามาถอดให้สวยๆ ผ่าน json online สิเพื่อดู <strong>Transaction</strong> ใน <strong>BlockChain</strong> ของ <strong>Hash Key</strong> เรา ว่ามีอะไรบ้าง</p><p><strong>Transaction </strong>ที่เราทำล่าสุด <strong>Index</strong> <strong>ที่ 3 เติมเงินไป 50 บาท</strong> ให้กับ <strong>Address Key Hash</strong> ของเรา แล้วมี <strong>Previous Hash</strong> บอกก่อนหน้าด้วยว่าคือ <strong>Block</strong> ไหน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2ZTFzVll69s_OHBZixqYQ.png" /></figure><p>9. ทีนี้ ยิง API อย่างเดียวไม่พอละ ขี้เกียจนั่ง <strong>Run CURL</strong> ละทำ <strong>Front End VueJs</strong> ขึ้นมาเทส หน้าตาของกระเป๋า ง้าวๆ ของเราก็เป็นดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AEtfUVJQ6XLZrG7OWqbgA.png" /></figure><p>ไหนลองกดเติมเงินเพิ่มอีกทีสิ 50 บาท</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XBI5bwYxPA7BZ0wQfUTUw.png" /></figure><p><strong>10. ทีนี้พอกดเติมเงินผ่าน Front End VueJs แล้วมาเทสแบบ API ว่า BlockChain ของเรา Chain ไปถึง Hash ไหนแล้ว</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s2PPGT-2tRAMYcXiKWFFZg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1haOj1d-R4997qfK61lvw.png" /></figure><p><strong>โอ้วกดเพิ่มเงินไป 3 รอบรอบละ 50 บาท Hash ก็จะเพิ่มมา 3 Hash เช่นกัน</strong></p><p><strong>*** จบละ BlockChain Wallet Concept ***</strong></p><p><strong>Part ต่อไปว่าจะทำ Security ย้ายไป GraphQL ต่อการตัดเงินผ่าน Omise เพื่อเติมเงิน (ไว้ว่างก่อนน่ะ!!!)</strong></p><p>ย้อนดู BlockChain NodeJs Concept 101 ได้ที่นี่</p><p><a href="https://medium.com/@acceth/%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-crypto-js-%E0%B8%97%E0%B8%B3-blockchain-101-ae9905ac3091">https://medium.com/@acceth/%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-crypto-js-%E0%B8%97%E0%B8%B3-blockchain-101-ae9905ac3091</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c3b27949c9c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ทดลองเล่น Crypto-Js ทำ BlockChain 101]]></title>
            <link>https://medium.com/@acceth/%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%A5%E0%B9%88%E0%B8%99-crypto-js-%E0%B8%97%E0%B8%B3-blockchain-101-ae9905ac3091?source=rss-bac9ea266915------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae9905ac3091</guid>
            <category><![CDATA[blockchain-technology]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[crptocurrency]]></category>
            <dc:creator><![CDATA[Acceth]]></dc:creator>
            <pubDate>Tue, 16 Jan 2018 09:23:07 GMT</pubDate>
            <atom:updated>2018-01-16T11:07:27.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*tfkTlYAKi4PQgUPkftVeFw.jpeg" /></figure><p>วันนี้พามาลองทำ Blockchain เบื้องต้น ในการเข้ารหัส แต่ละ Block ด้วย Crypto-Js</p><h3>BlockChain คือ ?</h3><p><a href="https://en.wikipedia.org/wiki/Blockchain_(database)">From Wikipedia</a> : เทคโนโลยี แบบนึงที่ใช้ในการเก็บข้อมูลใน เงินดิจิทัล แทบทุกชนิด โดยข้อมลจะเรียงต่อกันเป็น Block โดยแต่ละ Block จะอ้างอิงถึงกัน ทำให้ไม่สามารถย้อนกลับไปแก้ไข Block ก่อนๆ ได้</p><p><strong>มาทดลองทำ BlockChain 101</strong></p><ul><li>มาดู Structure กับ Main Component Concept</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eiq6D0UaP2AkI2h4Ndtl2w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*YOBG6tYIM1PHsBpV0Jqdag.png" /></figure><ol><li><strong>Setup Package</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JHMuQOvwE3tHxegOct9cSQ.png" /></figure><p><strong>2. สร้าง File Dockerfile</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KWK2fK1iwqleTxXWXarpfQ.png" /></figure><p>3. สร้าง file docker-compose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LXthvIW9nlmw-QC-1Wk0Uw.png" /></figure><p><strong>4. จากนั้นกลับมาที่ หน้าจอ Terminal รัน install node package และรัน Docker</strong></p><pre>$ npm i<br>$ docker-compose up</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kfKBQLHo_beXdPR5vcB2Vg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtSg086QEIiPP8KSfnIhcQ.png" /></figure><p><strong>5. มารองรันเทส HTTP API กันหน่อยสิ</strong></p><pre>$ curl <a href="http://localhost:3001/blocks">http://localhost:3001/blocks</a></pre><p>initial hash เรียบร้อย สำหรับ blockchain เรา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRVc5lNNwCuhDdRYwbvOdg.png" /></figure><p><strong>6. ทีนี้รองมาเพิ่ม block กันบ้าง</strong></p><pre>$ <strong>curl</strong> -H &quot;Content-type:application/json&quot; --data &#39;{&quot;data&quot; : &quot;เพิ่ม ข้อมูลไปใน  block&quot;}&#39; http://localhost:3001/mineBlock</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fT2NykvNqhqaCqX185n5NQ.png" /></figure><p><strong>7 .จากการเพิ่มข้อมูลลงไปใน BlockChain ทำให้ index ของ Chain เพิ่มแต่จะมี Previous hash ไล่มาเป็น Chain เรื่อย บ่งบอกถึงความเชื่อมโยง</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFrIsSwGTHXFNF9Xwzj7uQ.png" /></figure><ul><li><strong>** จบ BlockChain ด้วย Crypto-Js เบื้องต้น ละ Part หน้ามาเทสการใช้ BlockChain นี้ทำ Wallet กัน ***</strong></li></ul><p>ดู Concept หน้า BlockChain Wallet Concept ได้ที่นี่</p><p><a href="https://medium.com/@acceth/%E0%B8%95%E0%B9%88%E0%B8%AD%E0%B8%A2%E0%B8%AD%E0%B8%94%E0%B8%88%E0%B8%B2%E0%B8%81-blockchain-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-wallet-7c3b27949c9c">https://medium.com/@acceth/%E0%B8%95%E0%B9%88%E0%B8%AD%E0%B8%A2%E0%B8%AD%E0%B8%94%E0%B8%88%E0%B8%B2%E0%B8%81-blockchain-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%97%E0%B8%B3-wallet-7c3b27949c9c</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae9905ac3091" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>