Skip to content

eliappo/DevOps26_RE_minitwit_NixOs

 
 

Repository files navigation

DevOps26_RE_minitwit

This repository contains a Go implementation of the MiniTwit application, designed for the ITU DevOps course. The project features a containerized development environment and automated cloud deployment on DigitalOcean.

🚀 Public Access

The application is deployed and reachable at the following endpoints:

Service URL
MiniTwit Web UI http://164.92.186.201:5001
Simulator API http://164.92.186.201:5001/api

💻 Local Development Quickstart

To get the project running locally for the first time, follow these steps to set up your environment:

1. Initialize Local Files

We use template files to prevent local configuration or binary data from cluttering the version control.

# 1. Create your local working database from the template
cp tmp/minitwit.db.example tmp/minitwit.db

# 2. Create the DB IP configuration file at root 
# (Set to 127.0.0.1 for local SQLite or your remote DB server IP)
echo "127.0.0.1" > db_ip.txt

2. Run with Docker (Recommended)

Following modern DevOps practices, we recommend using a single Dockerfile with multi-stage builds to handle both development and production.

  • Build image: ./develop.sh build
  • Enter Container: ./develop.sh run
  • Inside the container: The project root is synced to the container's workspace. You can run go run main.go directly.

3. Using Makefile (Shortcuts)

You can use the following commands for quick task execution:

  • make run: Starts the Go application locally.
  • make build: Compiles the Go binary.
  • make test-sim: Runs the Python simulator against your local instance.

🛠 Cloud Deployment (DigitalOcean)

Infrastructure provisioning and application deployment are automated using Vagrant with the DigitalOcean provider.

1. Prerequisites

Ensure the following environment variables are configured on your host machine:

Variable Description
DIGITAL_OCEAN_TOKEN Your DigitalOcean Personal Access Token.
SSH_KEY_NAME The name of the SSH key registered in your DigitalOcean account.
export DIGITAL_OCEAN_TOKEN="your_actual_token_here"
export SSH_KEY_NAME="your_key_name"

2. Provisioning

To provision the Database and Web servers and deploy the latest code:

vagrant up --provider=digital_ocean

🧪 Testing & Troubleshooting

Run Simulator API Tests

Test your API compatibility using the provided Python simulator:

# Ensure you are at the project root
python3 test/minitwit_simulator.py "http://localhost:5001/api"
python3 test/minitwit_simulator.py "http://164.92.186.201:5001/api"

Monitor Webserver Logs

To view real-time application logs, SSH into the webserver:

vagrant ssh webserver
tail -f /var/log/minitwit.log

📂 Project Structure

.
├── db/              # Database schema and initialization scripts (schema.sql is here)
├── docker/          # Dockerfiles (Multi-stage build strategy)
├── static/          # Static assets (CSS, Images, JS)
├── templates/       # HTML templates for the Gin framework
├── test/            # Python simulator and test scenario CSVs
├── tmp/             # Local DB templates (Real DB and legacy folder are ignored)
├── simulator_api.go          # Application entry point
├── minitwit.go          # Application entry point
├── Makefile         # Shortcuts for common tasks
└── Vagrantfile      # Infrastructure as Code (IaC) configuration
└── develop.sh    # for local developemnt

About

A NixOS powered version of ITU's DevOps course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 37.0%
  • Python 27.2%
  • Nix 10.3%
  • HTML 8.3%
  • CSS 7.3%
  • Shell 3.4%
  • Other 6.5%