Skip to content

floatingman/aws-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AWS Starter App

A multi-service containerized application template with CI/CD pipeline, perfect for getting started with microservices on AWS or any container platform.

πŸ—οΈ Architecture

This starter app consists of three main services:

  • Frontend: NGINX serving a static page with API proxy
  • API: FastAPI backend with health endpoints
  • Worker: Python heartbeat worker service

✨ Features

  • 🐳 Containerized: All services run in Docker containers
  • πŸ”„ CI/CD Ready: GitHub Actions workflow for automated builds
  • πŸ“¦ Multi-Registry: Pushes to both GitHub Container Registry and Docker Hub
  • πŸ§ͺ Testing: Basic health checks and API tests
  • πŸ› οΈ Development Tools: Makefile for common operations
  • πŸ“ Clean Structure: Sensible .gitignore and .dockerignore files

🚦 Quick Start

Prerequisites

  • Docker and Docker Compose
  • Make (optional, but recommended)

1. Clone and Start

# Clone the repository
git clone <your-repo-url>
cd aws-starter

# Start all services
docker-compose up --build

2. Access the Application

3. Using Make Commands

# See all available commands
make help

# Build all images
make build

# Start services
make compose-up

# Run tests
make test

# Stop services
make compose-down

# Clean up
make clean

πŸ”§ Development

Project Structure

aws-starter/
β”œβ”€β”€ frontend/           # NGINX + Static HTML
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ nginx.conf
β”‚   └── index.html
β”œβ”€β”€ api/               # FastAPI Backend
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── main.py
β”œβ”€β”€ worker/            # Python Worker
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── worker.py
β”œβ”€β”€ .github/workflows/ # CI/CD Pipeline
β”‚   └── ci.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ Makefile
└── README.md

API Endpoints

  • GET / - Welcome message with timestamp
  • GET /health - Health check endpoint
  • GET /docs - Interactive API documentation

Environment Variables

Worker Service

  • HEARTBEAT_INTERVAL - Heartbeat interval in seconds (default: 30)

API Service

  • ENV - Environment name (development, production)

πŸš€ Deployment

GitHub Container Registry

# Push to GHCR (requires authentication)
make push-ghcr GITHUB_REPO=username/repo-name

Docker Hub

# Push to Docker Hub (requires authentication)
make push-dhub DOCKER_USERNAME=your-username

CI/CD Pipeline

The GitHub Actions workflow automatically:

  1. Builds all service images
  2. Pushes to GitHub Container Registry (always)
  3. Pushes to Docker Hub (if secrets configured)
  4. Tests the deployed services
  5. Runs on push to main/develop and pull requests

Required Secrets (Optional)

For Docker Hub integration, add these GitHub secrets:

  • DOCKERHUB_USERNAME - Your Docker Hub username
  • DOCKERHUB_TOKEN - Your Docker Hub access token

πŸ§ͺ Testing

Manual Testing

# Start services
make compose-up

# Run basic tests
make test

# Check specific endpoints
curl http://localhost:8000/
curl http://localhost:8000/health
curl http://localhost:8080/

Automated Testing

The CI pipeline includes:

  • Service health checks
  • API endpoint testing
  • Worker heartbeat verification

πŸ“ Customization

Adding New Services

  1. Create a new directory (e.g., database/)
  2. Add Dockerfile and application code
  3. Update docker-compose.yml
  4. Add to CI workflow matrix in .github/workflows/ci.yml
  5. Update Makefile if needed

Modifying Services

  • Frontend: Edit frontend/index.html or frontend/nginx.conf
  • API: Modify api/main.py and update api/requirements.txt
  • Worker: Update worker/worker.py logic

πŸ› Troubleshooting

Common Issues

  1. Port conflicts: Change ports in docker-compose.yml if 8080/8000 are in use
  2. Permission errors: Ensure Docker daemon is running and user has permissions
  3. Build failures: Check Dockerfile syntax and dependencies

Debugging

# View logs for all services
docker-compose logs

# View logs for specific service
docker-compose logs api

# Execute commands in running container
docker-compose exec api bash

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test locally with make test
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ”— Useful Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages