<?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 Kyaw Myint Thein on Medium]]></title>
        <description><![CDATA[Stories by Kyaw Myint Thein on Medium]]></description>
        <link>https://medium.com/@kyawmyintthein?source=rss-6bf51df026d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vwNVnTjxJAI8wvMfHkbdhQ@2x.jpeg</url>
            <title>Stories by Kyaw Myint Thein on Medium</title>
            <link>https://medium.com/@kyawmyintthein?source=rss-6bf51df026d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 01:29:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kyawmyintthein/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[This article is for those, like me, who don’t have a chance to learn computer science]]></title>
            <link>https://medium.com/@kyawmyintthein/this-article-is-for-those-like-me-who-dont-have-a-chance-to-learn-computer-science-3816cdf3725f?source=rss-6bf51df026d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3816cdf3725f</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[book-review]]></category>
            <dc:creator><![CDATA[Kyaw Myint Thein]]></dc:creator>
            <pubDate>Sun, 03 Dec 2023 11:33:54 GMT</pubDate>
            <atom:updated>2023-12-03T11:45:55.962Z</atom:updated>
            <content:encoded><![CDATA[<p>I struggled at the start of my career although I have a lot of passion for programming. I learned new programming languages, frameworks, and tools since I had a lot of energy and time to do so. That wasn’t helping at all. I was rejected by many companies, and couldn’t find a good job. Technologies constantly evolving. Everyone talking about which language, or framework is better and faster. I tried to learn whatever new came up. I realized something was wrong with what I was doing, and I foresaw the failure of my career.</p><p>I decided to study computer science without going back to university. There might be a question about how I knew I needed to learn computer science. (Luckily, I got a chance to work with a person who was doing a Ph.D. in computer science — I don’t want to mention a specific topic). That was the time I realized my failures were rooted in a lack of knowledge in computer science.</p><p>You might argue that we really need to know computer science to become a developer. I would say “It’s great to know for the long run”. This article is more focused on how I learned it. I wouldn’t say I know everything now, but I’d like to share my journey.</p><p>First, I started digging for information about where and how to learn computer science. Then, I bought a bunch of expensive books from Amazon. Before I recommend anything, I’d like to say the most important thing to learn is “English.” Most of the valuable books and articles are written in English.</p><p>Let’s start with my recommendation; I’d like to recommend a book called “<a href="https://www.amazon.com.au/Computer-Systems-Programmers-Randal-Bryant/dp/013409266X">Computer Systems: A Programmer’s Perspective</a>,” which is pretty expensive. I recommend buying it if you can. If not, I found the video on YouTube (<a href="https://www.youtube.com/watch?v=4CpHpFu_KYM&amp;list=PLyboo2CCDSWnhzzzzDQ3OBPrRiIjl-aIE&amp;ab_channel=%E5%BE%90%E6%B1%9F">Link here</a>). You also find a PDF version online. You can learn from there. It’s not as complete as the book, but better than nothing. From my experience, when I started reading that book, I needed to go back and read the other two books to get the full context. (In my opinion, it’s not necessary to understand 100% of these two books). I also prefer to read about the Linux operating system. (I don’t have resources to recommend).</p><ol><li>The C Programming Language — <a href="https://www.amazon.com.au/Programming-Language-Brian-W-Kernighan/dp/0131103628/ref=sr_1_5?crid=1X979OE4B7W9S&amp;keywords=c+programming&amp;qid=1701598160&amp;sprefix=C+progrm%2Caps%2C490&amp;sr=8-5">Amazon Link</a></li><li>The Art of Assembly Language, 2nd Edition — <a href="https://www.amazon.com.au/Art-Assembly-Language-2nd/dp/1593272073/ref=sr_1_28?crid=3UQZOU2CJIFYU&amp;keywords=assembly+language+for+x86+processors&amp;qid=1701598240&amp;sprefix=assembly+lan%2Caps%2C334&amp;sr=8-28">Amazon Link</a></li></ol><p>There are a few other books I’ve read. But, the aforementioned books are good enough to start. Another aspect of interview questions, especially for Software Engineers, is Data structure and algorithms. I’d like to recommend this Udemy course — <a href="https://www.udemy.com/course/datastructurescncpp/">Link here</a>. I recommend practicing with your preferred programming language while studying it. It’s hard to write during a coding interview without practicing. I’d also like to recommend a book called “Introduction to Algorithms” — <a href="https://www.amazon.com.au/Introduction-Algorithms-fourth-Thomas-Cormen/dp/026204630X/ref=sr_1_3?keywords=Introduction+to+Algorithms&amp;qid=1701601510&amp;s=books&amp;sr=1-3">Amazon link</a>. Since it’s expensive, I think the Udemy course is good enough to understand basic data structures and algorithms to start practicing the coding questions from LeetCode and HackerRank. Learning about computer systems will give you a better understanding of data structures and algorithms. Additionally, data structures and algorithms are applied in computer science theories.</p><p>Lastly, I’d like to make some recommendations for those interested in backend engineering and distributed systems.</p><ol><li>Designing Data-Intensive Applications: Big Ideas Behind Reliable, Scalable, and Maintainable Systems — <a href="https://www.amazon.com.au/Designing-Data-Intensive-Applications-Reliable-Maintainable/dp/1449373321/ref=sr_1_13?keywords=distributed+system&amp;qid=1701599406&amp;sr=8-13">Amazon Link</a></li></ol><p>I’ve also found a few free YouTube channels for distributed systems. (The order is random)</p><ol><li><a href="https://www.youtube.com/watch?v=rZPRjLMWOao&amp;list=PLNPUF5QyWU8PydLG2cIJrCvnn5I_exhYx&amp;ab_channel=LindseyKuper">https://www.youtube.com/watch?v=rZPRjLMWOao&amp;list=PLNPUF5QyWU8PydLG2cIJrCvnn5I_exhYx&amp;ab_channel=LindseyKuper</a></li><li><a href="https://www.youtube.com/watch?v=7VbL89mKK3M&amp;list=PLOE1GTZ5ouRPbpTnrZ3Wqjamfwn_Q5Y9A&amp;ab_channel=DistributedSystemsCourse">https://www.youtube.com/watch?v=7VbL89mKK3M&amp;list=PLOE1GTZ5ouRPbpTnrZ3Wqjamfwn_Q5Y9A&amp;ab_channel=DistributedSystemsCourse</a></li><li><a href="https://www.youtube.com/playlist?list=PLrw6a1wE39_tb2fErI4-WkMbsvGQk9_UB">https://www.youtube.com/playlist?list=PLrw6a1wE39_tb2fErI4-WkMbsvGQk9_UB</a></li></ol><p>There are a few other books I’ve been reading for distributed systems. I won’t add them here since I haven’t finished them yet. This section might be helpful for system design interviews, but there are many other topics to learn for system design interviews. I hope this should be good enough for starting a journey.</p><p>I believe all the resources I mentioned above will enable you to learn a lot more about other things such as compilers, automatic memory management (garbage collector), concurrency, etc. These are fundamental to modern technologies and programming languages.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3816cdf3725f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails style fixtures go testing with Gorm (ORM)]]></title>
            <link>https://medium.com/@kyawmyintthein/rails-style-fixtures-go-testing-with-gorm-orm-784bd0b9b7a4?source=rss-6bf51df026d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/784bd0b9b7a4</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kyaw Myint Thein]]></dc:creator>
            <pubDate>Fri, 29 Jul 2016 06:35:10 GMT</pubDate>
            <atom:updated>2016-07-29T06:35:10.130Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction</h4><p>In this article, I want to introduce the Ruby on rails style fixture library <a href="https://github.com/kyawmyintthein/gofixtures">gofixtures</a> for Golang testing and how to use with Gorm ORM. The ideal of gofixtures is setup demo data for testing.</p><blockquote><a href="https://github.com/kyawmyintthein/gofixtures">https://github.com/kyawmyintthein/gofixtures</a></blockquote><p>There is no dependencies for database driver and ORM. gofixtures load yaml format file and parse that file to specific <strong>Golang’s Struct</strong>.</p><h4>Usage</h4><p>Before we start using gofixtures, we need to setup fixture folder path. Then, you need to load the specific yaml format fixture file. One file can have multiple objects. for example:</p><p>main.go</p><pre>package tests<br>import(<br>    &quot;testings&quot;<br>    &quot;<a href="https://github.com/kyawmyintthein/gofixtures">github.com/kyawmyintthein/gofixtures</a>&quot;<br>)</pre><pre>func init(){<br>   gofixtures.SetupConfig(&quot;data&quot;)<br>}</pre><pre>func TestLoadFixtureFile(t *testing.T){     <br>    fixture, err := gofixtures.LoadFixture(&quot;example&quot;)   <br>    if err != nil{              <br>         t.Errorf(&quot;failed to load fixture: %v&quot;, err)    <br>    }   <br>}</pre><pre>func TestAddUser(t *testing.T){     <br>    fixture, err := gofixtures.LoadFixture(&quot;example&quot;)   <br>    if err != nil{              <br>         t.Errorf(&quot;failed to load fixture: %v&quot;, err)    <br>    } <br>    user := models.User{}    <br>    err = fixture.Load(&quot;one&quot;,&amp;user)    <br>    if err != nil{        <br>         t.Errorf(&quot;failed to load fixture model: %v&quot;, err)    <br>    }     </pre><pre>     v, err := models.AddUser(user)  <br>     if err != nil{        <br>         t.Errorf(&quot;failed to load fixture model: %v&quot;, err)    <br>     } <br>     if v.Name == &quot;&quot;{         <br>        t.Errorf(&quot;failed to load fixture model&quot;)   <br>     }  <br>}</pre><p>user.go</p><pre>package models<br>import(<br>    <br>)</pre><pre>type User struct{    <br>      Name string  `json:&quot;name&quot;`    <br>      Age  int64  `json:&quot;age&quot;`<br>}</pre><pre>func AddUser(m User) (User, error) {<br>    var (<br>      err error<br>    )</pre><pre>    if !db.Gorm().NewRecord(m) {<br>        return m, errors.New(&quot;Primary key should empty.&quot;)<br>    }   </pre><pre>    tx := db.Gorm().Begin()<br>    if err = tx.Create(&amp;m).Error; err != nil {<br>      tx.Rollback()<br>      return m, err<br>    }<br>    tx.Commit()<br>    return m, err<br>}</pre><p>First of all, gofixtures load the example.yaml as []byte array in fixture object. Currently, gofixtures support to parse single struct object from fixture content([]byte). You can load one object by using name of object. In yaml, you need to have specific format as follow:</p><p>data/example.yaml</p><pre>one:  <br>   name: John  <br>   age: 21<br>two:  <br>   name: Kyaw  <br>   age: 23</pre><p>In above yaml file, you can load with “one” or “two” as object name. Parse yaml to struct object is the responsibilities of gofixtures.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=784bd0b9b7a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adding namespace feature to Golang -httprouter]]></title>
            <link>https://medium.com/@kyawmyintthein/adding-namespace-feature-to-golang-httprouter-8119b7213a6e?source=rss-6bf51df026d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8119b7213a6e</guid>
            <category><![CDATA[httprouter]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Kyaw Myint Thein]]></dc:creator>
            <pubDate>Fri, 06 May 2016 14:35:05 GMT</pubDate>
            <atom:updated>2016-05-12T13:52:58.746Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/julienschmidt/httprouter">https://github.com/julienschmidt/httprouter</a> is lightweight and high performance Http router for golang. In this article, I would like to add namespace feature for httprouter.</p><p>You cannot use namespace in httprouter. Normally, You can use httprouter as follow:</p><pre>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;github.com/julienschmidt/httprouter&quot;<br>    &quot;net/http&quot;<br>    &quot;log&quot;<br>)<br><br>func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {<br>    fmt.Fprint(w, &quot;Welcome!\n&quot;)<br>}<br><br>func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {<br>    fmt.Fprintf(w, &quot;hello, %s!\n&quot;, ps.ByName(&quot;name&quot;))<br>}<br><br>func main() {<br>    router := httprouter.New()<br>    router.GET(&quot;/&quot;, Index)<br>    router.GET(&quot;/hello/:name&quot;, Hello)<br><br>    log.Fatal(http.ListenAndServe(&quot;:8080&quot;, router))<br>}</pre><p>But, sometime you might need namespace feature as follow.</p><pre>api/v1/route1<br>api/v1/route1<br>api/v1/route2</pre><p>So, you have to write the prefix in every route’s function.</p><p>For my personal requirements, I added namespace to httprouter as value added feature in my repo <a href="https://github.com/kyawmyintthein/httprouter">https://github.com/kyawmyintthein/httprouter</a>. Usage will be different. To be honest, I have no idea about the performance of the httprouter of my version. I hope it will be still heigh performance.</p><p>If you want to use namespace feature, you can use from my repo <a href="https://github.com/kyawmyintthein/httprouter">https://github.com/kyawmyintthein/httprouter</a>. I also support nested namespace such as api/v1, api/v2 and etc.</p><p>Here is the usage for nested namespace,</p><pre>package main<br><br>import (<br>    &quot;fmt&quot;<br>    &quot;github.com/kyawmyintthein/httprouter&quot;<br>    &quot;github.com/kyawmyintthein/httprouter/namespace&quot;<br>    &quot;net/http&quot;<br>    &quot;log&quot;<br>)<br><br>func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {<br>    fmt.Fprint(w, &quot;Welcome!\n&quot;)<br>}<br><br>func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {<br>    fmt.Fprintf(w, &quot;hello, %s!\n&quot;, ps.ByName(&quot;name&quot;))<br>}<br><br>func main() {<br>    router := httprouter.New()<br><br>    root := namespace.New(&quot;/api&quot;)<br>    root.RouteTo(&quot;GET&quot;, &quot;/&quot;, Index)<br><br>    v1 := root.Use(&quot;/v1&quot;)<br>    v1.RouteTo(&quot;GET&quot;,&quot;/hello/:name&quot;, Hello)<br><br>    root.Handle(router)<br><br>    log.Fatal(http.ListenAndServe(&quot;:8080&quot;, router))<br>}</pre><p>You can use multiple nested namespace with httprouter. httprouter is awesome lib. I hope it will better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8119b7213a6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang (Beego framework) + Mongodb + Nginx Server Deployment with Docker]]></title>
            <link>https://medium.com/@kyawmyintthein/golang-beego-framework-mongodb-nginx-server-deployment-with-docker-29a29fe00e6a?source=rss-6bf51df026d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/29a29fe00e6a</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kyaw Myint Thein]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 16:41:16 GMT</pubDate>
            <atom:updated>2016-02-16T16:44:34.785Z</atom:updated>
            <content:encoded><![CDATA[<p>This article about server deployment with golang. I want to share my experience. I have been working with Golang for 5 months, I need to find better solutions for my development environment. There are a lof of problems in Deployment with Golang. There is no complete tutorial or guide for deployment.</p><p>Previously, I use tmux to make sure golang project is running as background terminal process <a href="https://medium.com/@kyawmyintthein/auto-deployment-with-beego-tmux-and-gopistrano-4c6e1f05d92f#.exjxs3exb">https://medium.com/@kyawmyintthein/auto-deployment-with-beego-tmux-and-gopistrano-4c6e1f05d92f#.exjxs3exb</a>. But, it is not good solution. So, I’m looking for new deployment process.</p><p>I choose docker for this time. Docker will solve my problem. If you are not familiar with docker, take a look at this link <a href="https://www.docker.com/">https://www.docker.com/</a>. I want to explain about how to deploy the golang project with docker properly in server in this post. I will use Beego(Golang framework)<a href="http://beego.me/">http://beego.me/</a>, Mongdb ,ubuntu and nginx.</p><p>At first, we need to create ubuntu instance. Then, that need to install some dependencies packages, git and docker. You can follow this to install docker in your ubuntu instance <a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-14-04">https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-compose-on-ubuntu-14-04</a></p><p>If server is ready, we need to create the docker config. We may have 3 docker config files. So, we may also have 3 containers. One is for database, another one is for App (Beego project) and the last one is for nginx.</p><p>So, based on our system architecture, when the request is come in the nginx interact with Beego App as reverse proxy. Beego App also interact with Mongodb for database layer. So, these containers need to be linked.</p><p>Mongo Container =&gt; Beego App =&gt; Nginx</p><h4>Dockerfile for Beego App</h4><blockquote>Dockerfile<br>#Base image is in <a href="https://registry.hub.docker.com/_/golang/">https://registry.hub.docker.com/_/golang/</a><br># Refer to <a href="https://blog.golang.org/docker">https://blog.golang.org/docker</a> for usage<br>FROM golang:latest<br>MAINTAINER Kyaw <a href="/service/mailto:kyaw@40tasks.com">kyaw@40tasks.com</a><br># ENV GOPATH /go</blockquote><blockquote># Install beego &amp; bee<br>RUN go get github.com/astaxie/beego<br>RUN go get github.com/beego/bee<br>RUN go get gopkg.in/mgo.v2/bson<br>RUN go get github.com/dgrijalva/jwt-go<br>RUN go get github.com/garyburd/redigo/redis<br>ADD . /go/src/</blockquote><p>The above code should be in Dockerfile for Beego App. you can build docker container by using this file.</p><blockquote>docker build -t beego_app -f Dockerfile .</blockquote><p>If you run above command. The docker pull the lates golang image and also download the golang library package. Then, it will copy project folder under the GOPATH of container.</p><p>By using docker, It will help us to download all the go libraries which are using in my project at once. To be honest, I don’t know any package management tools like Gemfile in Ruby on rails, package.json in Node.js app. So, if you don’t use docker, you need to run “go get” for every single package. Now you got beego_app image.</p><h4>Dockerfile for Mongodb</h4><p>Dockerfile.nginx</p><blockquote># Dockerizing MongoDB: Dockerfile for building MongoDB images<br># Based on ubuntu:latest, installs MongoDB following the instructions from:<br># <a href="http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/">http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/</a></blockquote><blockquote>FROM ubuntu:latest<br>MAINTAINER Kyaw <a href="/service/mailto:kyaw@40tasks.com">kyaw@40tasks.com</a></blockquote><blockquote># Installation:<br># Import MongoDB public GPG key AND create a MongoDB list file<br>RUN apt-key adv — keyserver hkp://keyserver.ubuntu.com:80 — recv 7F0CEB10<br>RUN echo “deb <a href="http://repo.mongodb.org/apt/ubuntu">http://repo.mongodb.org/apt/ubuntu</a> “$(lsb_release -sc)”/mongodb-org/3.0 multiverse” | tee /etc/apt/sources.list.d/mongodb-org-3.0.list<br># Update apt-get sources AND install MongoDB<br>RUN apt-get update &amp;&amp; apt-get install -y mongodb-org</blockquote><blockquote># Create the MongoDB data directory<br>RUN mkdir -p /data/db</blockquote><blockquote># Expose port #27017 from the container to the host<br>EXPOSE 27017</blockquote><blockquote># Set /usr/bin/mongod as the dockerized entry-point application<br>ENTRYPOINT [“/usr/bin/mongod”]</blockquote><p>The above code is dockerizing mongdb database. It can be usedful any other project which is using docker and mongodb. You can run</p><blockquote>docker build -t mongo_database -f Dockerfile.mongo .</blockquote><p>After that, the docker will pull the ubuntu image and install mongodb in that image. I am using ubuntu based image because sometime I can use other tools if I use mongdb shell directly. This mongodb image will run at post 27017.</p><p>Now we also got mongodb container and Beego App container images. So, we need to run these two containers and these also need to be linked because Beego App is using mongodb as database. Firstly, you can run mongodb image by using:</p><blockquote>docker run — name app_dataase -P -d mongo_database</blockquote><p>After that, you can also check mongdb is running or not by using</p><blockquote>docker ps -a</blockquote><p>The follow command will run new command in running container. Also can enter to the container to access mongo database directly.</p><blockquote>docker exec -it #containerid bash</blockquote><p>After you run mongdb container, you can run Beego App container but it need to link to the mongo container. So,</p><blockquote>docker run — name app — link app_dataase:app_dataase -p 80:80 -d beego_app</blockquote><p>The above command will run the Beego App container linked to mongodb container by using 8080 as port. Now, you can see your Beego App is running on dockerip:8080</p><p>Currently it is ready to run Beego App on server. But, I want to use nginx as reverse proxy.</p><h4>Dockerfile for nginx</h4><p>Dockerfile.nginx</p><blockquote>FROM ubuntu</blockquote><blockquote># File Author / Maintainer<br>MAINTAINER Kyaw</blockquote><blockquote># Install Nginx</blockquote><blockquote># Add application repository URL to the default sources<br># RUN echo “deb <a href="http://archive.ubuntu.com/ubuntu/">http://archive.ubuntu.com/ubuntu/</a> raring main universe” &gt;&gt; /etc/apt/sources.list</blockquote><blockquote># Update the repository<br>RUN apt-get update</blockquote><blockquote># Install necessary tools<br>RUN apt-get install -y nano wget dialog net-tools</blockquote><blockquote># Download and Install Nginx<br>RUN apt-get install -y nginx</blockquote><blockquote># Remove the default Nginx configuration file<br>#RUN rm -v /etc/nginx/sites-avaliable/default</blockquote><blockquote># Copy a configuration file from the current directory<br>ADD app_conf /etc/nginx/sites-avaliable/app_conf</blockquote><blockquote>EXPOSE 80</blockquote><blockquote># Set the default command to execute when creating a new container<br>CMD service nginx start</blockquote><h4>Sample Nginx Config</h4><blockquote>server {<br> listen 80;<br> server_name localhost;</blockquote><blockquote>client_max_body_size 20m;<br> client_header_timeout 1200;<br> client_body_timeout 1200;<br> send_timeout 1200;<br> keepalive_timeout 1200;</blockquote><blockquote>location / {<br> proxy_pass <a href="http://loco_app:8080/">http://beego_ap:8080</a>;<br> }<br>}</blockquote><p>Finally we can setup nginx image. docker will pull ubuntu image and install nginx by using config file. Based on configuration, docker will replace the default to “app_conf” for nginx config. So, “app_conf” is config for nginx and it should be predefined and place in project/etc/nginx/sites-avaliable/. Then, docker will copy that file to replace with default. You can build nginx image by using following command.</p><blockquote>docker build -t nginx_container -f Dockerfile.nginx</blockquote><p>After you build nginx image, you can also run the container by using</p><blockquote>docker run — name app_nginx — link beego_app:beego_app -p 80:80 -d nginx_container</blockquote><p>It is also need to link with Beego App. Now, you can see you Beego App is running at server_ip:8080. This is my solution for Golang server deployment. Now I looking for package management and Automated deployment with Docker by using gopitrano. Next artilce will be for automated deployment with gopitrano.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29a29fe00e6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Auto deployment with Beego, tmux and gopistrano]]></title>
            <link>https://medium.com/@kyawmyintthein/auto-deployment-with-beego-tmux-and-gopistrano-4c6e1f05d92f?source=rss-6bf51df026d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c6e1f05d92f</guid>
            <category><![CDATA[beego]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[autodeployment]]></category>
            <dc:creator><![CDATA[Kyaw Myint Thein]]></dc:creator>
            <pubDate>Thu, 19 Nov 2015 15:47:26 GMT</pubDate>
            <atom:updated>2015-11-19T15:47:26.835Z</atom:updated>
            <content:encoded><![CDATA[<p>Auto deployment with Beego, tmux and <a href="https://github.com/kyawmyintthein/gopistrano">gopistrano</a></p><p>I’m not used to write the blog. Now I wanna share my experience about the auto deployment for Golang project (Beego framework). I have been working for a few day on it. Then, I found this solution. There will be other tools ( like docker, circus, supervisord and etc) to run the <strong>Golang</strong> project in production. But they not ok for me. I also want to do research for that tools and write blog.</p><p>Now, I used a tools called “<strong>tmux”</strong> to run <strong>Beego</strong> project as background. Then, <a href="https://github.com/kyawmyintthein/gopistrano"><strong>gopistrano</strong></a> is a golang originally from <a href="https://github.com/alanchavez88/gopistrano">https://github.com/alanchavez88/gopistrano</a>. But, it does not support for ssh login and tmux integration. So, I forked it and update some code for <em>tmux</em> and <em>beego</em> integration. You can also take a look at <a href="https://github.com/kyawmyintthein/gopistrano">https://github.com/kyawmyintthein/gopistrano</a>.</p><p><strong>tmux</strong> is a terminal multiplexer.</p><p><strong>What is a terminal multiplexer?</strong> It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal. And do a lot more. See <a href="https://tmux.github.io/">https://tmux.github.io/</a></p><p><strong>Beego? </strong>An open source framework to build and develop your applications in the Go way <a href="http://beego.me/">http://beego.me/</a></p><h3>Installing Golang (Go)</h3><p>In this blog, I don’t want to explain how to install <strong>Golang</strong> in details. You can reference from follow link to install and setup <strong>Golang</strong> in your computer.</p><p><a href="https://golang.org/doc/install">Download and install - The Go Programming Language</a></p><h3>Installing Beego</h3><pre>cd $GOPATH/src<br>go get -u github.com/beego/bee<br>go get -u github.com/astaxie/beego</pre><p>Now I want to create Beego Restful project. Use “bee api project_name” to generate API skeleton. That will generate skeleton for your project. <a href="http://beego.me/blog/beego_api">http://beego.me/blog/beego_api</a></p><pre>cd $GOPATH/src<br>bee api beego_api_project</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pu6iIqVe0Ildp0vK9PDjQg.png" /></figure><p>Run project by using “bee run project_name”. “-downdoc=true -gendoc=true” command is to generate swagger based API documenation. N</p><pre>cd beego_api_project<br>bee run beego_api_project -downdoc=true -gendoc=true</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FpbQCtuuN8veSh_zQR0DTQ.png" /></figure><p>Now, “Beego” is already compile the project to single file and running at localhost:8080 by default.</p><p>To deploy that project on production, use <a href="https://github.com/alanchavez88/gopistrano">gopistrano</a> to auto deployment. Before you deploy it, you need to do cross-compilation for you project file. I used mac and my production server will be ubuntu. So, Run</p><pre>GOOS=linux GOARCH=386 CGO_ENABLED=0 bee run -downdoc=true -gendoc=true</pre><p>Then, create Gopfile in project root folder and change the config.</p><pre>username = yourusername<br>password = yourpassword<br>hostname = server host (eg. 124.45.44.56 or domain.com)<br>port = 22<br>repository = project repo url from bitbucket or github<br>app_name = project_name<br>keep_releases = 5</pre><pre>path = root_path (eg. home/ubuntu/app)<br>use_sudo = falsessh = sshkey_path <br>webserver_user = nobody</pre><p>Then, run</p><pre>gopistrano deploy:setup<br>gopistrano deploy</pre><p>It will automatically pull the repo from your github or bitbucket and create current, releases and utils path. releases path holds the latest changes of your code by version. current path holding the symlink of latest releases code. In utils, there will be two script deploy.sh and run_app.sh.</p><p><strong>deploy.sh</strong> is used when you run “gopistrano deploy” to pull the code and update the latest releases.</p><p><strong>run_app.sh</strong> is for <strong>tmux. </strong>After deploy.sh is finished, the tmux kill existing session and create new one. Then, run the “<em>bee run project_name</em>” command in tmux session. After that, tmux detach the session but, you project is running at the background.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c6e1f05d92f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>