/jenkins-fcc-readme

Follow-along instructions for the freeCodeCamp Jenkins course.

Jenkins

Follow-along instructions for the freeCodeCamp Jenkins course.

Table of Contents

Overview

This is a tutorial showing how to build a CI/CD pipeline for a web application using Jenkins. I use one of my previous tutorial apps - the Curriculum App - from my livestreams to create this. One interesting thing about that app is that I already have Github actions written to deploy it automatically to Dockerhub in the repo. That will give you an opportunity to compare the Jenkins pipeline I set up in this tutorial to an already working CI/CD pipeline in the repo.

Technologies

  • Debian servers running on Linode (Jenkins from Linode marketplace)
  • Jenkins
  • Docker & Dockerhub
  • Github
  • Some command line for settings things up

Sections

Every section here corresponds to a section in the freeCodeCamp video.

What is Jenkins?

Why would want you use Jenkins as an app developer?

Why do companies use Jenkins?

How does Jenkins compare to other CI/CD tools?

Terms & Definitions

Project Architecture

jenkins_architecture_balsamiq_diagram2

Setting Up Linode

  • Signing up for Linode ($100 credit)

  • Jenkins in the Linode marketplace

  • Configuring Jenkins - admin account, plugins, settings

  • Deploying an app to Github and using the Jenkins Github plugin

  • Using Jenkins to test and deploy to Dockerhub

  • Another Linode server will be watching for updates on Dockerhub and pull & run the updated container

  • Reviewing Jenkins features like build history

Setting Up Jenkins

Make sure you follow these steps to set up Jenkins from the Linode marketplace: https://www.linode.com/marketplace/apps/linode/jenkins/

Jenkins Plugins

Blue Ocean UI

Jenkins Pipelines

Shell scripts from the tutorial:

ls -la

cd curriculum-front && npm i && npm run test:unit

docker build -f curriculum-front/Dockerfile . -t fuze365/curriculum-front

docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD

docker push fuze365/curriculum-front:latest

SSH'ing into Linode Servers (installing Git)

Commands for installing Git and Node on server:

# install Git
apt install git
git --version

# node version 16 (comes with npm)
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt-get install -y nodejs
node --version
npm --version

Jenkinsfile

Docker & Dockerhub

Extra Material

There are two main ways to handle app deployments with our Jenkins setup:

  1. We could deploy the app to Dockerhub and have the app server watch for changes to the docker image. It will pull whenever there are changes. (this is what we have set up now)
  2. The more advanced setup is to have Jenkins deploy directly to our app server when all of the CI steps pass. This requires a bit of extra configuration in Jenkins and also ensuring security in the app server.

You can see this tutorial for a walkthrough of how I set up the app server to watch for changes to a Docker image on Dockerhub.

Helpful Jenkins Resources

Related Projects