/Node-Podman-OpenShift-CI-CD

A project to demonstrate CI/CD and containerisation using Podman deployed on OpenShift with Node.js application.

Primary LanguageVueMIT LicenseMIT

Node-Podman-OpenShift-CI-CD

Project Specification

A containerised CI/CD pipeline for OpenShift applications using Github Actions containerised using Podman.

Develop a persistent application that consists of a front-end component.
Set up a CI/CD pipeline to BUILD, BAKE and DEPLOY your application to a container platform using GitOps methodologies and approaches (fully automated deployment).
Include scanning of code, container images and production environments for best practices and security purposes in your automated process.

Demonstration

Demo-Group-39.mov

Development

This project is of a two-part project.

  • Pipeline

  • Application
    For application related documentation, refer to the DEVELOP.MD in .\covid-vue-app

    Read more on containerisation in CONTAINER.md in .\docker.

Pipeline

There are two different pipelines.

  • Continuous Integration

  • Continuous Deployment (And Continuous Delivery which we do not implement here)

    A team normally has to choose between Deployment or Delivery.
    Continuous Delivery is Continuous Deployment with an extra step of needing deployment approval.


Continuous Integration

An example of a Continuous Integration pipeline is this.

We will be explaining using this branch where we have test and linting outside of a container.

In Github Actions, we define the pipeline in a YAML file (indentation strict), which is also supported by other pipelining solutions.

We first define the name of this pipeline (or workflow in Github Actions),

name: Node.js CI

Then, we define the trigger condition, this would trigger on push,

on: [push]

configure triggers on multiple events, (list of events here)

on: [push, pull_request]

We could also restrict the workflow to trigger on certain branches, this triggers on push and pull_request to the main branch.

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

Then we specify the job (or actions), we first make a job called build.
We specify the runner environment (where the code would be running), we have it running on ubuntu-latest.

jobs:
  build:
    runs-on: ubuntu-latest

Due to the structure of our code, we have our application in Covid-Application, so we need to move to the correct directory.

defaults:
  run:
    working-directory: ./Covid-Application

I was led to believe that a step running cd Covid-Application/ would also work.
Now that we're in the correct directory, let's start to do something.

We define steps (actions) here, which would mimic someone typing this into the terminal of this runner environment.
We could name our actions with name: <name> for clarity, and our actions would usually be in the form of

  • uses: <some actions>
  • run: <some command>
    Find premade actions here

This is part checkouts the code of our repo to this runner environment.

steps:
  - uses: actions/checkout@v2

This part here declare the Node.js version (12.x) and install it into the current runner environment.
We named this action "Use Node.js".

- name: Use Node.js
  uses: actions/setup-node@v1
  with:
    node-version: "12.x"

This part here declare the actions (commands to run), in which we execute these commands respectively.
Yarn is supported out of the box with Node.js Read more here (also includes boilerplate).

yarn # npm install
yarn lint # npm run lint
yarn build # npm run build
yarn test # npm test
- name: Install dependencies with Yarn
  run: yarn
- name: Lint with ESLint
  run: yarn lint
- name: Build with Webpack
  run: yarn build
- name: Run tests
  run: yarn test

If there were any errors from these steps, the pipeline will fail and the developers would be notified.

Resources

Containerisation

Container Orchestration

Monitoring

Continuous Integration

Web servers

Pipeline Template

Author

Author Current Year Course
Cormac Madden 3rd year Computer science and business
Dabreadman 3rd year Computer science
Neil Shevlin 2nd year Computer science and business
Prathamesh Sai 2nd year Computer science
Emer Murphy 2nd year Computer science
Tom Roberts 2nd year Computer science