From ea7b55cb6423ff338c45e62a22dbd973a541fe9c Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Wed, 9 Oct 2024 12:54:25 +0100 Subject: [PATCH] Add project --- src/data/projects/iac-digitalocean.md | 3 +- .../projects/nodejs-service-deployment.md | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/data/projects/nodejs-service-deployment.md diff --git a/src/data/projects/iac-digitalocean.md b/src/data/projects/iac-digitalocean.md index 4fcafcb95..ed02e8faa 100644 --- a/src/data/projects/iac-digitalocean.md +++ b/src/data/projects/iac-digitalocean.md @@ -36,5 +36,4 @@ Write Ansible playbook that will configure the server. You can use the same play
-Once you are done with the project, you should have a good understanding of setting up a basic infrastructure on DigitalOcean using Terraform and configuring it using Ansible. - +Once you are done with the project, you should have a good understanding of setting up a basic infrastructure on DigitalOcean using Terraform and configuring it using Ansible. \ No newline at end of file diff --git a/src/data/projects/nodejs-service-deployment.md b/src/data/projects/nodejs-service-deployment.md new file mode 100644 index 000000000..df2abfd45 --- /dev/null +++ b/src/data/projects/nodejs-service-deployment.md @@ -0,0 +1,63 @@ +--- +title: 'Node.js Service Deployment' +description: 'Use GitHub Actions to Deploy a Node.js Service to a remote server' +isNew: false +sort: 10 +difficulty: 'intermediate' +nature: 'CI/CD' +skills: + - 'nodejs' + - 'docker' + - 'devops' +seo: + title: 'Node.js Service Deployment' + description: 'Use GitHub Actions to Deploy a Node.js Service to a remote server' + keywords: + - 'Node.js' + - 'DigitalOcean' + - 'Docker' +roadmapIds: + - 'devops' +--- + +The goal of this project is to practice setting up a CI/CD pipeline for a Node.js service using GitHub Actions. You will practice using GitHub Actions for deployment (including Secrets and environment variables), Terraform to provision a server, Ansible to configure the server, and SSH to deploy the application. + +## Requirements + +If you haven't completed the previous projects for [Configuration Management](/projects/configuration-management) and [IaC](/projects/iac-digitalocean), you should do that first. You will be able to reuse the Ansible and Terraform code from those projects. + +You are required to have the following setup: + +- Setup a [DigitalOcean droplet using Terraform](/projects/iac-digitalocean) +- Setup the server using [Ansible](/projects/configuration-management) including installing Node.js and `npm` +- Create a simple Node.js service that just has a `/` route which returns `Hello, world!` +- Push the codebase to GitHub repository + +Once you have the above setup, you are required to implement the following: + +### Task #1: Manual Ansible Deployment + +- Setup a role in ansible called `app` that will connect to the server, clone the repository, install the dependencies, build the application, and start the application. +- You should be able to run the playbook using the following command and the application should be up and running on port `80`: + + ```bash + ansible-playbook node_service.yml --tags app + ``` + +- You should be able to access the application using the public IP address of the server. + +### Task #2: Automate Deployment using GitHub Actions + +Write a GitHub Action workflow that will deploy the application to the server using one of the following methods. You are welcome to try both options, but you are not required to do that. You are also welcome to use any other method to accomplish the same result. + +#### Option #1: Run the playbook in GitHub Actions + +Use the `ansible-playbook` command to run the playbook and deploy the application + +#### Option #2: Use SSH to connect and deploy the application + +Use SSH to connect and deploy the application. Look into [rsync](https://linux.die.net/man/1/rsync) and these GitHub Actions to accomplish this: [ssh-agent](https://github.com/webfactory/ssh-agent), [appleboy/ssh-action](https://github.com/appleboy/ssh-action). + +
+ +Once you have the application deployed, you should have a good understanding of automating the process of setting up a server and deploying an application to it. \ No newline at end of file