CI/CD with Gitlab Runner and Docker-Compose

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I came just gonna show you how to set up get that runner to use docker compose I have this project and get lab and it uses docker compose it's quite a complicated little docker compose that has two processes bringing it once and n Jenks which is public-facing and then there's a Python flask API on the backend just managing the data your docker composers are probably really complicated as well but anyway I want get lab runner to automatically install and run docker compose on my server whenever I make a change to the production branch or to run tests on the develop branch to develop I've got two branches here two main branches production develop you probably have a lot more branches I'm just gonna keep this demo quick and simple anyway CI CD why is it so good well one of the things I like is all the history and all the errors that you can always go back and check out if you like for example there was a problem here I can go back and look at that there was a problem during deployment and there's enough information in there for me to figure that out anyway I'm gonna get on with it now first thing I'm gonna need to do is get myself a server somewhere on the internet I'm gonna use digital ocean cuz it's nice and cheap I've already got to get lab running running there but I'm just going to delete that one destroy that cool I'm just gonna create another one excellent so this is crate another one just a very simple basically bun to serve our I'm just gonna have a minimum cheapest one I'm gonna put it in Amsterdam and I'm going to call it Shawn Shawn get lab run there we go now I'm gonna create that will take a minute and we'll get an IP address okay I'm gonna open up putty and I'm gonna log in okay I'm already logged on logged on now the process now to set up a get love run up you can generally get from the gitlab Runner page dedicated to this and I'm gonna follow most of those steps normally you would do a bun to upgrade an update I'm just kidding bypass that and keep this nice and quick sudo W get to get that runner binary okay age mod I have to call that one now okay we now have to create a gitlab user okay run the get lab install run our install let's start kid lab runner we can verify it's running by looking at the top I think it's 10 the bottom somewhere here it is right the bottom okay let's now register get lab run on please enter the get app CI coordinator okay so that default is that one it's very good please enter the get lab CI token okay this is here get that go into your get lab project and down here in settings the bottom-left CI CD so in runners expand you may have shared runners enabled so you can just click that and have it off like I've got but you want to set up a specific run to manually so we're going to use this token here copy there we go that's the CI token please enter the get lab description okay my runner please enter the tags I'm not going to have any tags register succeeded now enter the executor I'm going to use the shell executor okay it says it's running all good but there's a few more things to do we need to add docker to the get live runner user we also need to add get lebrun up to the sudo was whoops sudo nano sudo if I go down here I'm gonna add get Lebrun up like this or no password hall and to control X I will save by pressing Y and enter to overwrite that's good now we'll sudo gitlab run up restart that is get lab runner running on a digitalocean server now you could be using AWS or issue or anything else it doesn't really matter it's just new bun to server running keep that runner now if I to was to refresh this page we should see some information okay so the runner has activated let's just have a look at this runner okay that's good indicates whether this one I can pick jobs about tags & Canas locked excellent of my runner that's all good let's go over to the pipelines these are all the old pipelines from my previous runner which I've deleted I'm gonna just go to the project and delete the Cy just delete that and we'll build a new one okay delete that file delete it from actually all my or my branches delete and all such a leader from develop delete radio we're in developer I'm gonna create a get lab run a file new file or get that CI why am L I'm gonna scan apply a any template doesn't matter I'll mostly use bash and get rid of all of that and I'm gonna put in pretty much exactly what I had before uses the image docker docker in dhaka it's got two stages test and deploy now the test stage is going to run on the develop branch and the production branch and the deploy stage is only gonna run on the production branch see stage deploy and stage test there and the test stage at the moment is only gonna print this run tests in this section doesn't really do anything other than that but the deploy stage will actually run these scripts sudo apt-get install white Python pip actually don't need that bit all that you will call people installed docker compose docker compose up a deep build environment production when manual that means I will have to start it manually when everyone make a change to the production branch not demo that save that and then we'll go and look at the docker compose again there is the docker compose that it will be running and let's go to develop okay get lab CI yml see what we'll do is a look at the pipeline's test we can look at that run tests in this section that was triggered on the development branch you'll go develop just because I created that new file inside the get lab interface but what I'm gonna do is go to my project which I have for my local computer and I'm gonna write something I'm in the develop branch down the bottom and I'm gonna just write something like my amazing change now I'm gonna push that to get lab so get commit a demo change get push ok let's go and look at get lab pipelines there we go a new pipeline has just been added to the list and it's actually passed because it's not really doing anything it's just printing that on run tests now we're going to do something a little more exciting we're going to merge that amazing change into production get switch to production get re-up today git merge develop and there's a conflict get add git commit pushing to production okay let's go and have a look at pipelines okay so the first this is the production pipeline now the first bit the test passed the second bit I have to start manually so let's start that off and let's actually see what it's doing hey so running with gitlab runner using the shell executor fetching changes ok sudo apt-get install why python fit yep it's doing that then pip install docker compose it's doing that docker compose up it's now building my project so it's building Shaun's angular 6 Python 2.7 slim this is all from the docker compose and this is all running on the new server that I just bought from digitalocean you job succeeded seek reading in jinx sorry creating nginx there we go let's go and visit that server let's see whether we can see anything and there's my application and that data comes from a Python API back-end and these this user interface is just angular 6 that project is here in gitlab that's the docker compose have a look at the production that's the docker compose that's the gitlab ciy ml and there's some sample code that you can look at and the address is incorrect now doesn't matter you will set this up yourself probably and it's my amazing change what we just did is I have a project here Sean's angular six Python flask boilerplate public and that's it and you can copy that locally but what is what it does is a docker compose which builds the whole thing built as an engines proxy which hosts a static HTML which happens to be angular 6 but it also is a proxy for the flask API and you can get to avoid slash API and then mg then get lab runner upon any changes to the production branch pushes it to the server that I just bought from digitalocean link in the description and then the internet can get it brilliant that's get lab branagh with docker compose thanks for watching like comment subscribe and share
Info
Channel: seanwasere ytbe
Views: 114,863
Rating: undefined out of 5
Keywords: gitlab, docker-compose, gitlab runner, ci/cd, continuous integration, continuous deployment, gitlab aws, gitlab azure, gitlab digitalocean, gitlab ci, devops
Id: RV0845KmsNI
Channel Id: undefined
Length: 16min 31sec (991 seconds)
Published: Sun Aug 05 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.