DevOps isn't just for big companies or production workloads. If you're working on a side project, it's one of the best ways to get hands-on experience with real tools, improve your workflow, and build something that can grow over time.
This guide shows you how to structure a DevOps side project using Docker, GitHub Actions, and DigitalOcean.
Prerequisites
- Basic knowledge of Docker and GitHub
- A DigitalOcean account (free with GitHub Student Pack or via credits)
- A side project you'd like to deploy (a simple Python or Node app works great)
Project Structure
Here's a simple directory layout:
my-app/
├── app/ # Your app source code
├── Dockerfile # Container definition
├── .github/
│ └── workflows/
│ └── deploy.yml # CI/CD pipeline
├── terraform/ # Infra as code
│ ├── main.tf
│ └── variables.tf
└── README.md
This gives you a clean separation between app code, infrastructure, and deployment automation.
Step 1: Containerize Your App
To make your project portable and easy to deploy anywhere, you’ll want to containerize it. This means packaging your app and its dependencies into a Docker image.
Create a Dockerfile
in your project root:
# Use a slim base image
FROM node:20-slim
WORKDIR /app
COPY ./app .
RUN npm install
CMD ["node", "index.js"]
This defines how to build and run your app in a container. It's lightweight and reproducible.
Step 2: Define Infrastructure with Terraform
Next, you'll want to define your infrastructure as code. This helps you version your server setup and makes redeploying easier and more consistent.
In the terraform/
folder, create a simple setup for a DigitalOcean Droplet:
provider "digitalocean" {
token = var.do_token
}
resource "digitalocean_droplet" "web" {
name = "my-app-server"
region = "nyc3"
size = "s-1vcpu-1gb"
image = "docker-20-04"
}
This creates a small Droplet with Docker pre-installed. Add variables to variables.tf
:
variable "do_token" {
type = string
}
You'll need to pass your API token when applying.
Step 3: Automate with GitHub Actions
Automation helps you deploy consistently with minimal manual work. You can use GitHub Actions to connect your repo to your server and trigger deployments on each push.
Add a simple deployment workflow at .github/workflows/deploy.yml
:
name: Deploy to DigitalOcean
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: SSH and deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
docker stop my-app || true
docker rm my-app || true
docker pull my-dockerhub-username/my-app:latest
docker run -d --name my-app -p 80:3000 my-dockerhub-username/my-app:latest
This action connects to your server over SSH and redeploys your container. Make sure to add your secrets (SERVER_IP
, SSH_PRIVATE_KEY
) to the GitHub repo.
Example Workflow
Here's how everything flows together:
+------------+ push +-----------+ deploy +-----------------+
| Developer | -----------> | GitHub CI | ---------------> | DO Droplet |
| (You) | | Actions | | (App Container) |
+------------+ +-----------+ +-----------------+
You write code, push to GitHub, and your app redeploys automatically.
Final Touches
If you want to learn more about DevOps in general, check out DevOps Daily. It's a site packed with DevOps tools, guides, and labs.
Instead of paying for a heavyweight platform-as-a-service, running your own Dockerized app on a $4/mo Droplet can actually be cheaper and more flexible. You get full control over the environment, and you can customize it however you like.
- Add a custom domain to your Droplet
- Set up basic monitoring
This setup is lightweight but mirrors real DevOps workflows. It helps you build habits that scale: automation, reproducibility, and observability.
If you're using a different cloud provider or want to expand this with CI testing, containers in staging, or config management tools, you’re already on the right path.
Let me know what you're building or if you want help refining your setup.
Top comments (0)