Skip to content

Alm-4/DockerizedService

Repository files navigation

Dockerized Service

Dockerizes a Node.js service and deploys it to a remote server using a CI/CD workflow implemented with GitHub Actions.

The Node.js service is a web app with two routes: a home "/" route and a "/secret" route which has basic authentication requiring a "username" and "password".

The workflow dockerizes the Node.js web app and deploys it a remote server via SSH making use of github secrets. This project creates a digital ocean droplet running Ubuntu for the remote server.

Requirements

  • Terraform version 1.14+
  • Ansible version 2.16+
  • Node.js version 18.19.1+
  • Npm

Usage

Prerequisites:

  • An SSH key pair (generate by running the ssh-keygen command)
  • DigitalOcean Personal Access Token

Run these commands from within the project directory or folder to setup the server:

Bash:

npm install
cd terraform 
terraform init
# This command requests a personal access token (do_token) and the filepath of a public SSH key (pub_key). Enter them to continue
terraform apply
cd ../ansible
ansible-playbook -i inventory.ini setup.yml

CMD and Powershell:

npm install
cd terraform 
terraform init
# This command requests a personal access token (do_token) and the filepath of a public SSH key (pub_key). Enter them to continue
terraform apply
cd ..\ansible
ansible-playbook -i inventory.ini setup.yml

For running the workflow:

  1. Fork this repository.
  2. Add the remote server's public ip address as "HOST" and the matching private SSH key (not the filepath) as "KEY" as secrets in the repository
  3. Add a "SECRET_MESSAGE", "USERNAME" and "PASSWORD" as secrets in the repository naming them as stated.
  4. Make some non functional change/s to one or more of the project's files (make a change to this README.md file for example) and commit the changes to the repository making sure the action is enabled.

The workflow should be able to be seen running in the actions tab of the repository.

To access the Node.js web app after the workflow has run, go to the public ip of the remote server using a modern browser (run terraform output to see the ip).

About

Dockerizes a Node.js service and deploys it to a remote server using GitHub Actions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors