Setting up a CI/CD pipeline with Jenkins, EC2, and Docker (1/3)

Mitch Jans
jstack.eu
Published in
3 min readSep 28, 2019

Offloading your builds, tests and deploys to the cloud

image by NeONBRAND

Part 1: Setting up Jenkins on AWS EC2

After building your application, running your tests and integration tests, and manually deploying it for the umpteenth time you’ll probably start to wonder if there is a better way to go about it. A decent CI/CD setup is the answer to your struggles.

In truth, if you’re building any type of (semi-)serious solution it’s probably a good idea to get your CI/CD set up as soon as possible to get the human errors out of the equation and free up precious coding time.

Step 1: setting up an AWS EC2 instance

For this example we’ll be using Ubuntu as OS, so head over to your AWS console and spin up an Ubuntu instance.

If you’ve never done this before you can follow this article by James Hamann to get you up and running (skip the very last step, we won’t need a PostgreSQL database).

Additionally, you’ll need to allocate an Elastic IP and associate it to your new instance so you can point you DNS entry to it. You can find out how to do that here. SSH in to your new server and let’s get to it.

Step 2: installing Jenkins

The first step is to get our Ubuntu installation up to date.

Now we’ll add the Jenkins repository key, install Java 8 (Jenkins doesn’t play nice with Java 9) and install Jenkins.

Once all this finishes, we can configure Jenkins for the first time.
Go to http://your-elastic-ip:8080 and you should be greeted with the Jenkins unlock screen. Jenkins will be locked with an initial password and will tell you where to find it.

Display the password, copy it and you can use it to unlock Jenkins.

The next screen will ask you which plugins you want to install, if you’re not sure which ones you’ll need just accept the suggested ones.

Next you’ll be asked to create an admin user. You can fill in any details you want here but be sure to take note of them or you won’t be able to access your Jenkins instance! (Although there is a way of getting back in as long as you can ssh into the host)

And finally Jenkins will be ready to use (congrats, you made it to the end!)

Click start using Jenkins to… start using Jenkins.

Stay tuned for part 2 where we’ll secure this setup with NGINX and Let’s Encrypt so you can build and deploy your projects safely. 👋

--

--