Build Test Deploy

Muhammad Naufal Irbahhana
HappyFresh Fleet Tracker
3 min readNov 14, 2019
https://cdn.lynda.com/course/587665/587665-636670833995526359-16x9.jpg

Both CI and CD have its different meaning, CI stands for Continuous Integration and CD is Continuous Delivery. CI is to automate the build and to test the code. And CD usually people calls it Continuous Development because its for deployment automation.

Source: Danny August Ramaputra

This long .yml file is the configuration of several stages and test for the deployment. so first we have stages . the stages here is to let the runner know we have three pipelines namely build, test and deploy. we have each for frontend and backend. and next we have variables here we put the Golang build paths because Golang’s project structure is quite comprehensive.

the next lines is called the task . Task is defined in each pipelines. for the build task, we have two task that is for the front end and the back end. Each build task have different image for the backend we use Danny August Ramaputra’s self-made image and for the frontend we use NodeJS image. this image is meant for the runner to know which image to use on what stage. script is what command should the runner execute so that it can complete the task. Usually consist of preparation of the dependancies and building it. here we have a script both named init_backend.sh and init_frontend.sh, so we can easily execute that. you can see the script in our repository. we also have artifacts this is to pass the file from one stage to the others. in our case is to pass it to the test stage so that what we build can be tested.

next we have two test task, here we execute the test this test the artifact that we past from the previous build by utilising the dependencies filed.

last we have six deploy task. all three environment have each front end and back end deployment task. here we will do the same thing that is pushing to registry, and let EC2 do their stuff. with docker tags they can build the docker image to take these tasks. also the dependency field we do not need the past artifact. and with docker in docker (DinD) to build the image inside the docker container.

CD !

CD will deploy and deliver our app to user faster and better! It’s also safer because it is automated so that less human error done! Here in SS, we actually use docker. We use predefined image so that we don't have to install our dependancy one by one. In deploying stage, we use docker Docker in Docker (DIND)to deploy our docker image. Because we actually need docker application to deploy our docker image to registry provided by fasilkom. We use two docker file each for backend and frontend. Below I gave snippet of our docker file.

Dockerfile for back-end Source: Danny August Ramaputra
Dockerfile for Front-end Source: Danny August Ramaputra

This Dockerfile is the recipe (thank you pak adin) of our image and determine how it going to deploy. So for the backend, we use Danny August Ramaputra’s image builder version 1.13. Every image can have multiple tags. We see in the Front-end Dockerfile, the nginx part, alpine is actually a linux version that is so light to host the nginx that acted as the http server.

Thank you for reading!

--

--