-: In the last section,
we created our service account
and we downloaded a JSON file
that contains some credentials for that service account.
We now need to download and install the Travis CLI
which is a program that we're going to use
to encrypt that service account JSON file
and tie it to our Travis CI account.
Remember, the entire idea behind this
is that the JSON file we just downloaded.
So this one right here has some very sensitive information
inside of it and we do not want to expose it
to the outside world
from our GitHub account.
All right, so to download and install the Travis CLI,
we can go to Github.com blah blah blah,
and download this thing and install it.
However, there's just one little awkward thing
about the Travis CLI,
and that is that it requires Ruby
to be installed on your local system.
Now, if you are on a mac Os machine,
you're in luck because by default,
Ruby is installed on mac Os.
However, if you are on Windows,
well, life is a little bit harder.
On Windows, installing Ruby is a little bit more challenging
and it's kind of a pain in the rear.
Now, I would hate to have to go
through the Ruby installation process with you
if you're on Windows
because it is a little bit of a pain
and it takes a decent amount of time.
But there is a little work around that we can use.
I want you to remember,
what have we been doing in this entire course?
We've been creating Docker images and containers
and the entire purpose of these containers
is that we can very easily get some different environment
up and running on our local machine
with some very customized dependencies
inside of that container.
So I think that rather than trying to install Ruby locally
on your machine,
especially if you are on Windows,
instead, let's try getting a Docker image
that has Ruby pre-installed inside of it.
So we're going to get an image that has Ruby pre-installed.
We'll then open up a shell or a terminal
inside of that container and then we'll use that
to install and run the Travis CLI.
There's only a single command we have to run
with Travis CLI essentially, you know,
just the one command to encrypt that file
that we care about.
So we don't really need a persistent version
of the Travis CLI to sit around
because we just want to use it one time
and then throw it away.
So this would actually be a great use case
where we could use a Docker container
with Ruby already installed inside of it
to install Travis CLI,
use it to encrypt the file,
and then throw the entire container away
'cause we don't need it for anything else.
So let's give this a shot.
Now, in this section as we go through this process
we are going to be running a good number of commands.
And so, I wanted to put all the commands up here
and all the different steps we're going to go through
just in case you are skipping
through this video rather quickly,
I wanna make sure that you don't accidentally skip
one of the commands inside of here.
So I would almost recommend that you take a screenshot
of this diagram right here just to make sure
that you nail each and every one of these commands.
So the first thing we're going to do
is execute a Docker run command.
The image that we're going to be running
is Ruby version 2.3.
And then at the same time,
we're gonna start up a shell inside there
and we're also gonna set up a volume.
The purpose of the volume right here
is to eventually get the service account JSON file
inside the container.
Remember, this is the file that we want to encrypt
so we need to make sure
that it is available inside the container.
So we're going to use a volume to do that.
Now, notice that we're using the dollar sign parentheses
and interpolation here.
This is only valid if you're on a Unix-based system
or if you're on Windows using Git Bash as your terminal.
If you are on Windows and you're using something
like the command line or PowerShell,
you're going to use curly braces there instead.
So just be aware of that little difference.
Okay, so let's get to it.
I'm gonna open up my terminal and I'm going to make sure
that I'm inside of my complex directory
because we're going to eventually put that JSON file
inside of here and encrypt it.
And we're using specifically the complex directory
'cause remember we're going to make sure
that the volume is available
inside the container.
All right, so we'll do Docker run
dash I T
dash V
to set up the volume.
I'll say dollar sign PWD
to say present working directory
of the complex folder.
I'll then do a colon
and I'm going to map this present working directory
of complex to the folder
about app inside the container.
Now we don't actually have any app thing to put
inside the container,
I'm just choosing that folder name totally at random.
You could probably figure out a better name
but honestly it just doesn't really matter that much.
We'll then specify the image of Ruby 2.3
and then the command that I want to run inside
of this container is sh
to start up a shell inside there.
Okay, so I'm gonna run this command.
Now when I run the command,
I immediately get kicked into a terminal right here
or a shell inside the container
because I've already downloaded the Ruby image
in the past.
For you, you probably need to download this image
and so it's gonna take maybe a minute or two
to download the image
and then eventually create a container out of it.
So I encourage you to pause the video right now
and just leave it paused until you eventually get
into a shell like so.
Okay, so if you're now here
I'm going to assume that you've successfully gotten
into a shell inside the container.
So if we now do an ls, we can see that app folder.
So there's the app folder right there
the one that we just set up as a volume.
If I change into that app folder
and I encourage you to do so right now as well.
So I'm gonna make sure I'm inside that app folder.
I can do an ls and I'll see all of the project folders
out of our original complex directory.
Okay, so that definitely worked out pretty well so far.
So now the next thing we're going to do
is install Travis.
This is the Travis CLI
We're installing it by using the program, jim
Jim is essentially a dependency manager
for the Ruby programming language.
So we're using the jim program to install Travis.
So I'll do jiminstalltravis
and I'll put on
no dash r doc
and no RI
And these two flags over here at the right hand side
these are a hundred percent optional.
They're essentially just saying
do not attempt to
install any documentation along with this jim
It just makes the installation go very
very slightly faster.
All right, so I'm gonna run this and then
we're going to very quickly see everything get installed.
All right, now it looks like I paused there
for a second on building native extensions.
Now something kind of interesting that I want to mention
this is a total side topic,
completely unrelated
from all this Travis stuff and you're probably gonna hate me
for going on a side topic
while we're running all these intense commands,
but I have to do it,
I have to tell you about this side topic.
I feel a hundred percent compelled to do so.
So you'll notice during that entire process
it says building native extensions right here.
That's essentially a step where Ruby
and the jim program
are taking a bunch of Ruby Source code files
and essentially compiling them to get them to work
on your local system.
Now that's kind of a build step
and it requires some modules inside
of Ruby to be installed or essentially these kind
of development programs to be installed with Ruby.
One thing you might notice
that's kind of interesting is when we originally ran
that docker run command right here
we specified a image tagged as 2.3 from Ruby.
If you actually open up the Docker hub page,
so Docker hub for that Ruby image
we just made use of...
So I'm gonna search for Ruby
and then go to the repository right here.
You'll notice that
there are a ton of other versions available,
some of which are tagged as alpine.
So remember a alpine version
of an image is essentially just saying,
Hey, this is a stripped down version of this image
with just the bare minimum required
to get this thing running.
Now in our case
we had to install a jim that did this extra build step
and like I said
that requires some extra packages to be installed with Ruby.
If we had used the Alpine version of this Ruby image
this step right here would've actually completely failed.
'Cause remember the Alpine version is a hundred
percent stripped down.
And so the Alpine version of the Ruby image does
not have those extra packages required to do this step
of building a native extension.
So if we had used,
I keep scrolling up 'cause I think the command is up there,
but it's not.
If we had used an Alpine version
like say Alpine 2.3 right here
that jim installs step would've failed
because we did not have all the dependencies
required to build this jim.
So this is a great example where the Alpine version
of an image is not always the best solution,
not always the best solution.
Okay, I apologize for that little quick aside,
I just had to mention it.
I felt compelled, like I mentioned.
All right, so it looks
like everything successfully got installed.
So now to make sure everything is set up correctly
I'll do the command Travis like so
it's gonna ask me
if I want to install some shell completion.
This is essentially some autocomplete stuff.
We don't need it
because we're just running like one or two commands here.
So I'll just say no.
And then after that I'll get prompted here
with the list of all the commands that are available
to me tied to the Travis CLI
Okay, so Travis is definitely up
and running successfully without us having to go
through that long process of installing Ruby.
Now let's take a quick pause right here.
We're gonna come back to the next section
and we're gonna continue going
through a couple of other steps.
So quick break and I'll see you in just a minute.