A hands-on DevOps starter kit for Node.js applications, demonstrating how to automate, containerize, and deploy apps to your local server using best practices and popular tools like Docker, Ansible, and GitHub Actions.
- Dockerized Node.js app: Easily containerize your application for consistent local or production environments.
- .env support: Manage configuration and secrets using environment variables.
- Ansible automation: Provision and configure your server with repeatable infrastructure-as-code.
- GitHub Actions: Pre-built CI/CD pipeline for testing and deployment (add your own workflows as needed).
- Extensible: Use as a template for any Node.js project.
- Docker installed on your local machine/server
- Node.js and npm (for local testing)
- Ansible (for automated server setup)
- (Optional) GitHub Actions for CI/CD
git clone https://github.com/adeelumar-17/mydevops.git
cd mydevops/app- Replace the contents of
/appwith your own Node.js (Express) application code, or use the provided sample as a starting point.
- Create a
.envfile inside the/appdirectory:
PORT=3000
# Add your app-specific environment variables hereNote: Never commit your
.envfile to a public repository.
docker build -t mydevops-app .
docker run -p 3000:3000 --env-file .env mydevops-app- Your app should now be accessible at
http://localhost:3000.
- Edit
/ansible/inventory.inito add your local server/domain. - Use the provided Ansible playbooks or create your own to automate:
- Installing Docker
- Deploying the Docker container
- Managing environment variables
Example command:
ansible-playbook -i ansible/inventory.ini ansible/playbook.yml- Add your workflow files in
.github/workflows/to automate testing, building, and deployment on push.
mydevops/
├── app/ # Node.js application code
│ ├── Dockerfile
│ ├── app.js
│ └── .env # (not committed)
├── ansible/ # Ansible inventory and playbooks
│ └── inventory.ini
└── .github/
└── workflows/ # (Add your CI/CD workflows here)
- Do not commit sensitive information (domains, credentials) to the repository.
- Use environment variables for secrets and configuration.
- If you have accidentally committed secrets, remove them from git history.
- Replace
/appwith any Node.js app (supports Express by default). - Modify or extend Ansible playbooks for more advanced automation.
- Add additional workflows to
.github/workflows/as needed.