WEBVTT

00:00:01.440 --> 00:00:06.150
In this demo, we will be setting up a continuous integration lab environment.

00:00:06.150 --> 00:00:12.040
And strictly speaking, this is not part of Dockle, but hopefully by showing you

00:00:12.040 --> 00:00:16.420
how easy it is to set up your own continuous integration environment, you will

00:00:16.420 --> 00:00:20.870
be able to follow along with the rest of the demos. First we're going to clone

00:00:20.870 --> 00:00:23.050
the gitlab‑demolab repository.

00:00:23.740 --> 00:00:27.960
Then we're going to use docker‑compose to fire up all Docker instances.

00:00:29.040 --> 00:00:31.460
Then we're going to create a GitLab project.

00:00:32.439 --> 00:00:36.380
We will be adding our SSH key in order to be able to push to that

00:00:36.380 --> 00:00:41.860
repository, and we'll push the tools‑image repository that we cloned in the

00:00:41.860 --> 00:00:47.540
previous demo to our newly minted GitLab instance. The code can be found on

00:00:47.540 --> 00:00:54.120
GitHub under /PeterMosmans/gitlab‑demolab. There you can also find

00:00:54.120 --> 00:00:56.560
extensive instructions on its usage.

00:00:57.640 --> 00:01:02.620
Let's go back to our console. Let's clone the repository which contains the code

00:01:02.620 --> 00:01:09.900
to spin up our GitLab instance, let's cd to that directory, and now in order to

00:01:09.900 --> 00:01:12.640
make sure that we're doing the exact same code,

00:01:12.830 --> 00:01:18.270
I'm going to check out the version tagged 1.0.0. This ensures

00:01:18.270 --> 00:01:22.300
that you will see the exact same thing when recreating the lab as

00:01:22.300 --> 00:01:24.350
you'll see me doing during this demo.

00:01:24.940 --> 00:01:27.910
Let's clear the screen. As I mentioned before,

00:01:28.050 --> 00:01:32.910
detailed instructions about it's usage can be found in the README file. For

00:01:32.910 --> 00:01:39.560
now, I'm going to copy the supplied environment variables to a .env file.

00:01:39.560 --> 00:01:46.020
The .env file contains all settings for this specific GitLab instance. And

00:01:46.020 --> 00:01:48.070
here you can select a strong password,

00:01:48.080 --> 00:01:52.630
a strong token, and the ports on which you will access the GitLab instance.

00:01:53.540 --> 00:01:56.950
I'm happy with these defaults, and all that's left to do is spin up

00:01:56.950 --> 00:02:01.320
our GitLab instance. We'll do that by running docker‑compose up,

00:02:01.360 --> 00:02:05.760
because you need to have Docker Compose installed as well, and

00:02:05.760 --> 00:02:08.669
let's supply the ‑‑detach flag to make sure it's running in the

00:02:08.669 --> 00:02:11.150
background. That was it.

00:02:11.540 --> 00:02:14.650
After a while, depending on how fast or how slow your machine is,

00:02:14.740 --> 00:02:18.650
you should be able to access the GitLab web interface on the URL

00:02:18.650 --> 00:02:22.680
and port specified in the .env file. In our instance, this is going

00:02:22.680 --> 00:02:25.250
to be gitlab on port 8080.

00:02:26.040 --> 00:02:29.760
I already made sure that gitlab resolves to localhost.

00:02:30.740 --> 00:02:32.400
So let's switch to the web interface.

00:02:33.140 --> 00:02:38.450
Now let's visit the address that we specified in the .env file, gitlab:8080.

00:02:39.740 --> 00:02:44.060
And as you can see, GitLab is already up and running. Hooray! Now

00:02:44.060 --> 00:02:47.570
let's enter root as username and the password that we specified in

00:02:47.570 --> 00:02:52.380
the .env file. Click on Sign in, and we successfully signed in on

00:02:52.380 --> 00:02:54.050
our local GitLab server.

00:02:54.540 --> 00:02:58.640
Let's now create a new project by clicking on the New project link. Let's

00:02:58.640 --> 00:03:04.830
select blank project, and for Project name let's select tools‑image. As we want

00:03:04.830 --> 00:03:08.580
to push the repository that we cloned earlier to this repository, the

00:03:08.580 --> 00:03:13.330
tools‑image repository, let's make sure that this is an empty repository, so

00:03:13.330 --> 00:03:17.530
I'm going to deselect Initialize repository with a README. Let's click on

00:03:17.530 --> 00:03:22.960
Create project, and conveniently, GitLab now reminds us that we haven't yet

00:03:22.970 --> 00:03:24.860
uploaded the public SSH key,

00:03:25.240 --> 00:03:28.560
which we will need if we want to push our code to this repository.

00:03:29.240 --> 00:03:30.420
So I'm going to do that right now.

00:03:30.430 --> 00:03:34.540
I'm going to click on Add SSH key, and then I'm going to paste in the public

00:03:34.540 --> 00:03:38.060
SSH key which I'm going to use to access this repository.

00:03:38.640 --> 00:03:43.680
Let's click on Add key, done. If we now go to the project page by

00:03:43.680 --> 00:03:50.910
going to Menu, Projects, Your projects, and let's click on the

00:03:50.910 --> 00:03:54.380
freshly created tools‑image repository, here we can see the

00:03:54.390 --> 00:03:56.060
project that we just created.

00:03:56.540 --> 00:04:00.240
Now let's go back to the console and push our earlier cloned

00:04:00.250 --> 00:04:02.960
tools‑image repository to this server.

00:04:03.640 --> 00:04:05.650
Let's go to the tools‑image directory.

00:04:06.140 --> 00:04:10.340
This is the repository we cloned earlier from GitHub. Now we're

00:04:10.340 --> 00:04:15.420
going to push this repository to our own GitLab server. First let's

00:04:15.420 --> 00:04:19.720
create a new branch called ci. You can do that by performing a git

00:04:19.720 --> 00:04:21.860
checkout with the ‑b flag.

00:04:23.440 --> 00:04:27.890
Now we're going to add our GitLab server as a git remote by performing the

00:04:27.890 --> 00:04:33.050
git remote add command and specifying the repository.

00:04:34.340 --> 00:04:37.760
And finally, let's push our code to the GitLab server.

00:04:38.140 --> 00:04:41.050
We can do that by performing a git push upstream.

00:04:41.540 --> 00:04:44.060
This is the first time we connect to our GitLab server.

00:04:44.440 --> 00:04:47.560
I'm going to accept the public key, and it pushed our code.

00:04:48.140 --> 00:04:50.260
Let's go back to the GitLab web interface.

00:04:51.640 --> 00:04:54.870
Let's refresh the page, and you can see it pushed our

00:04:54.870 --> 00:04:56.950
code successfully to this repository.

00:04:57.340 --> 00:05:01.560
Now this repository already contains a basic GitLab pipeline definition.

00:05:02.040 --> 00:05:06.380
That's the file called .gitlab‑ci.yml. If we click on the

00:05:06.380 --> 00:05:09.060
file, we see our basic pipeline definition.

00:05:09.640 --> 00:05:13.960
And this is very standard, it contains a build stage and a test stage.

00:05:14.840 --> 00:05:18.700
The build stage builds our Docker container and the test stage tests whether

00:05:18.700 --> 00:05:23.610
everything is correct. If you now go to the menu item on the left, CI/CD, and

00:05:23.610 --> 00:05:26.950
click on Pipeline, huh, the pipeline failed.

00:05:27.640 --> 00:05:29.950
Okay, this was not what I was expecting.

00:05:30.840 --> 00:05:34.160
What I was expecting is that the pipeline would run successfully

00:05:34.170 --> 00:05:36.560
the build stage, as well as the test stage.

00:05:37.340 --> 00:05:38.760
You might see different results.

00:05:38.760 --> 00:05:41.150
You actually might see that the test stage works.

00:05:42.440 --> 00:05:43.850
I'm going to click on the pipeline.

00:05:44.340 --> 00:05:48.980
The build stage was successful, the test not, this seriously surprises me.

00:05:49.240 --> 00:05:53.360
I'm going to click on test to see what went wrong. And here I

00:05:53.360 --> 00:05:56.360
can see that the npm outdated test fails.

00:05:56.740 --> 00:06:00.490
So this is actually a great example of an automated test that

00:06:00.490 --> 00:06:03.060
fails without you having touched the code.

00:06:03.540 --> 00:06:08.890
Why does it fail? Because the package has been considered outdated. This project

00:06:08.900 --> 00:06:14.260
uses a Docker image as base, and apparently that base image now contains an

00:06:14.270 --> 00:06:19.510
outdated library, therefore, the test fails even if the test ran successfully

00:06:19.510 --> 00:06:23.520
the day before or even an hour before. Now,

00:06:23.520 --> 00:06:26.580
you might see a different result because this issue

00:06:26.590 --> 00:06:28.350
might have been resolved by now.

00:06:29.040 --> 00:06:31.760
However, this is not important for the rest of our demo.

00:06:32.140 --> 00:06:34.590
What is important is that we have our GitLab server

00:06:34.590 --> 00:06:39.060
up and running to test CI/CD with, we have a pipeline up and running,

00:06:39.440 --> 00:06:42.290
and in the next clip, we're going to add some Dockle to this

00:06:42.290 --> 00:06:44.860
pipeline, what this whole course is all about.
