|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Building my own infrastructure I" |
| 4 | +date: 2020-08-10 10:00:00 +0100 |
| 5 | +categories: development |
| 6 | +comments: true |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +I used to have my projects spread in different systems: |
| 12 | + |
| 13 | +* [Github pages](https://pages.github.com/) |
| 14 | +for my [Jekyll](https://jekyllrb.com/) personal blog. |
| 15 | +* [Heroku](https://heroku.com) for my [Django](https://www.djangoproject.com/) |
| 16 | +apis and also a [React](https://reactjs.org/) web application. |
| 17 | +* External services for databases |
| 18 | +([Postgres](https://www.postgresql.org/), [Elasticsearch](https://www.elastic.co/)...). |
| 19 | +* Other static hostings... |
| 20 | + |
| 21 | +I decided to start the trip of building my own infrastructure |
| 22 | +and migratinf all projects to a centralized system. |
| 23 | + |
| 24 | +What do I gain with this? |
| 25 | + |
| 26 | +* Costs reduction |
| 27 | +* Easier customization |
| 28 | +* Services are centralized & you gain control |
| 29 | +* Lots of learning! |
| 30 | + |
| 31 | +And what do I lose? |
| 32 | + |
| 33 | +* Time and speed. |
| 34 | + |
| 35 | +Is it worth? Maybe... |
| 36 | +In my case I was willing to introduce my self in systems world |
| 37 | +so I decided to put my hands on work to figure it out! |
| 38 | + |
| 39 | +The first thing I did was improve my linux skills with two |
| 40 | +[lpic-1](https://www.lpi.org/our-certifications/lpic-1-overview) courses. |
| 41 | +It is always really useful to have a good operating system knowledge, |
| 42 | +even if you are not working as devops nor system administrator. |
| 43 | + |
| 44 | +Before starting the migration of any project I though about what I needed and |
| 45 | +how to structure my server. |
| 46 | +These are the projects I had: |
| 47 | + |
| 48 | +* [jordifierro's](https://jordifierro.com) My personal blog. |
| 49 | +It uses Jekyll framework and was hosted on Github pages |
| 50 | +(which has Jekyll automatic building integrated). |
| 51 | +* [Taddapp](https://taddapp.com) A simple landing page for an Android application. |
| 52 | +I don't want to remeber where it was hosted... |
| 53 | +* [Pachatary](https://pachatary.com) An Android & iOS application. |
| 54 | +I had the api in Heroku and was using heroku plugins (external services) |
| 55 | +for databases, mailer, etc. Images were (and are) stored on AWS S3. |
| 56 | +* [Llaor](https://llaor.com) A dictionary web. Same as pachatary: |
| 57 | +api and web where hosted on Heroku. |
| 58 | + |
| 59 | +_(Heroku is a great service to quickly/easily deploy and scale anything, |
| 60 | +but it is a bit expensive...)_ |
| 61 | + |
| 62 | +So, I must implement a multiple domain hosting server |
| 63 | +that can deliver statics, respond RESTful api requests, |
| 64 | +store databases and connect to external services... |
| 65 | + |
| 66 | +To achieve that, projects have to be prepared: |
| 67 | +* Dockerize them (for both testing and running). |
| 68 | +* Make them configurable. Setup variables must be injectable (eg: `env.list` files). |
| 69 | +* Write an strong README documentation. |
| 70 | + |
| 71 | +Once I'd had the schema in my mind I defined the pieces. |
| 72 | +I should pick a linux distro ([Ubuntu server](https://releases.ubuntu.com/20.04/)). |
| 73 | +Use [Nginx](https://www.nginx.com/) as a server |
| 74 | +(to deliver statics and also as reverse proxy for api's). |
| 75 | +[Docker](https://www.docker.com/) plays a very important role: |
| 76 | +to build statics, run applications and test, store databases, etc. |
| 77 | +making dependencies management much more easy. |
| 78 | +And [Jenkins](https://www.jenkins.io/) to handle tests, deploys, backups... |
| 79 | + |
| 80 | +And... to complicate it a little bit I added a requirement: |
| 81 | +zero-downtime deployments. |
| 82 | +So [Haproxy](http://www.haproxy.org/) comes into the equation. |
| 83 | +Putting Haproxy before Nginx allows you to have multiple instances of an app |
| 84 | +and load balance between them. |
| 85 | + |
| 86 | +I already had the domains (at [namecheap](https://namecheap.pxf.io/4bR69)) |
| 87 | +so I opened an account on [digital ocean](https://m.do.co/c/8edd7aed3fee) |
| 88 | +(it is a cheap and easy ,I didn't want any complicated features). |
| 89 | +I created a server instance there choosing Ubuntu 20.04 (LTS) x64 as image. |
| 90 | + |
| 91 | +Here starts the journey! |
| 92 | + |
| 93 | +Follow me to the [next post](https://jordifierro.com/building-my-own-infrastructure-2)! |
0 commit comments