This repository contains the solution for the DevOps assignment provided by DQ. The project is designed to demonstrate proficiency in DevOps practices, including CI/CD, infrastructure as code, and automated testing.
To get started with this project, follow the instructions below:
- Clone the repository:
git clone https://github.com/MichaelGift/dq-devops-assignment.git
- Navigate to the project directory:
cd dq-devops-assignment - Install dependencies:
npm install
- Run the application:
npm start
Automated build and test processes using GitHub Actions.
The pipeline is defined in .github/workflows/ci.yaml.
It tests then builds a Docker image and pushes it to Docker Hub on successful builds.
Depending on the branch, it tags the image appropriately:
mainbranch: tagged asprod-latestandprod-<commit-hash>devbranch: tagged asdev-latestanddev-<commit-hash>
Code quality checks using ESLint.
The linting workflow is defined in .github/workflows/lint.yaml.
Code coverage is measured using vitest.
The coverage reports are uploaded to Codecov after each successful CI build.
The project is set up to use bash scripts for deployment automation.
The deployment scripts can be found in the scripts/ directory.
They require a swarm cluster to deploy the Docker container as this simulates a production environment.
The configuration is setup to rollback to the previous version in case of deployment failure. This ensures high availability of the application.
To setup the swarm cluster, run:
./scripts/deploy_swarm.shThis requires Docker to be installed and initialized as a swarm manager.
You can initialize a swarm by running
docker swarm initon your local machine.
The deployment script is designed to be idempotent, ensuring that running them multiple times does not produce unintended side effects.
To deploy the application, run:
./scripts/cd.shThis will pull the latest Docker image from Docker Hub and deploy it to the swarm cluster.
The swarm configuration includes basic health checks and performance constraints to ensure the application runs smoothly.
The logs are observable via docker service logs and live monitoring via docker stats.