Module 2: Deploying Apps 🎯¶
Master different deployment approaches and learn how to deploy various types of applications with Docker and Traefik.
Progress Indicator¶
┌─────────────────────────────────────────────┐
│ ✨ Module 1: Getting Started [Completed] │
├─────────────────────────────────────────────┤
│ 🎯 Module 2: Deploying Apps [Current] │
├─────────────────────────────────────────────┤
│ 🌟 Module 3: Going Live [Upcoming] │
├─────────────────────────────────────────────┤
│ 👥 Module 4: Team Workflow [Upcoming] │
└─────────────────────────────────────────────┘
Module 2 of 4 | Estimated Time: 1-2 hours
Overview¶
In this module, you'll learn how to deploy different types of applications:
- Single container web applications (Node.js, Python, Go)
- Applications with databases (PostgreSQL, MongoDB)
- Static sites (MkDocs, Next.js static exports)
- Proper configuration with Traefik and Docker Compose
What You'll Learn¶
- Containerizing applications with Docker
- Creating production-ready docker-compose configurations
- Using Traefik as a reverse proxy with automatic SSL
- Managing environment variables and secrets
- Health checks and monitoring
- Common deployment pitfalls and how to avoid them
Prerequisites Checklist¶
Before starting this module, ensure you have:
- Completed Module 1: Getting Started
- Access to your EgyGeeks server
- Docker and Docker Compose installed locally (for testing)
- Basic familiarity with Docker and containers
- A sample application ready to deploy (or use our examples)
- Your domain name configured (you'll set up DNS in Module 3)
- SSH access to the server
- Basic command-line knowledge
Need help with prerequisites?
If you're missing any of these, return to Module 1 or check the troubleshooting section.
Lessons in This Module¶
1. Simple Web App Deployment¶
Learn the fundamentals with a single container application
Deploy a standalone web application (Node.js, Python, or Go) using Docker and Traefik.
Key Topics: - Creating a Dockerfile - docker-compose.yml configuration - Health checks and container monitoring - Traefik routing and SSL configuration
Time: 30-40 minutes Difficulty: Beginner
2. App with Database Deployment¶
Deploy applications with persistent data storage
Set up a complete application stack with a database (PostgreSQL or MongoDB) using multi-container Docker Compose.
Key Topics: - Multi-container architecture - Network configuration and security - Volume management for data persistence - Environment variables and secrets - Database initialization and backups
Time: 40-50 minutes Difficulty: Intermediate
3. Static Sites Deployment¶
Deploy static content with optimized configurations
Deploy static websites, documentation, and single-page applications (MkDocs, Next.js static exports).
Key Topics: - Dockerfile for static content - Lightweight containers (using Alpine) - Static file serving optimization - Caching strategies - Build-time vs runtime configuration
Time: 25-35 minutes Difficulty: Beginner
Module Structure¶
Each lesson includes:
- Learning Objectives - What you'll accomplish
- Prerequisites Checklist - Required knowledge and setup
- Step-by-Step Guide - Detailed instructions
- Complete Code Examples - Copy-paste ready templates
- ⚠️ Common Mistakes - Warnings about frequent errors
- 🔍 Verification Commands - How to test your deployment
- 💡 AI Prompts - Use these to ask Claude/ChatGPT for help
- Real Examples - Links to reference implementations
- What's Next - Path forward after completing lesson
- Need Help? - Troubleshooting and support links
Key Concepts You'll Master¶
Docker Fundamentals¶
- Images are blueprints (like a class)
- Containers are running instances (like an object)
- docker-compose.yml orchestrates multiple containers
Traefik Integration¶
Traefik automatically: - Routes incoming traffic to your container - Provisions SSL certificates (Let's Encrypt) - Handles multiple applications on same server - Monitors container health
Deployment Flow¶
- Push code to GitHub
- GitHub Actions triggers automatically
- Builds Docker image
- Starts container on server
- Traefik routes traffic to it
Important Warnings¶
Localhost vs 127.0.0.1
In Alpine-based Docker images, use 127.0.0.1 instead of localhost in health checks and connection strings. localhost may not resolve correctly in containers.
✅ Correct: http://127.0.0.1:8000 ❌ Wrong: http://localhost:8000
Health Checks Are Critical
Traefik only routes traffic to healthy containers. Always include a HEALTHCHECK in your Dockerfile. Without it, Traefik will think your container is failing.
Never Use Default Passwords
Change default database passwords in all configurations. Use strong, random passwords in production. Store secrets in .env files on the server, never in git.
Docker Compose v2
Use docker compose (not docker-compose). The newer version is faster and more reliable.
Quick Reference¶
Common Application Ports¶
| Framework | Port |
|---|---|
| Node.js/Express | 3000 |
| Python/Flask | 5000 |
| Python/FastAPI | 8000 |
| Python/Django | 8000 |
| Go apps | 8080 |
| Ruby on Rails | 3000 |
| Java Spring | 8080 |
| Static sites | 8000 |
Docker Compose Essentials¶
# Build and start containers
docker compose up -d
# View running containers
docker compose ps
# View logs
docker compose logs -f app
# Stop containers
docker compose down
# Rebuild without cache
docker compose up -d --build
Health Check Examples¶
# Python HTTP Server
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --quiet --tries=1 --spider http://127.0.0.1:8000/ || exit 1
# Node.js with curl
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl -f http://127.0.0.1:3000/health || exit 1
# Generic TCP check
HEALTHCHECK --interval=30s --timeout=3s \
CMD nc -z 127.0.0.1 8000 || exit 1
AI Prompts for This Module¶
Understanding Docker Concepts¶
Explain Docker to Me
Getting Help with Traefik Labels¶
Traefik Configuration Help
Writing Production Dockerfiles¶
Dockerfile for My Application
Create a production-ready Dockerfile for my [Node.js/Python/Go] application:
Application details:
- Framework: [Express/FastAPI/Gin]
- Port: [3000/8000/8080]
- Dependencies: [package.json/requirements.txt/go.mod]
- Build step: [npm build/poetry install/go build]
Include:
- Multi-stage build to reduce image size
- Health check endpoint at /health
- Non-root user for security
- Proper layer caching
Database Integration¶
App + Database Setup
I need help setting up docker-compose.yml for:
App: [Node.js/Python/Go] on port [PORT]
Database: [PostgreSQL/MongoDB]
Requirements:
- Database data should persist after container restart
- App should wait for database to be ready
- Secure internal network (database not exposed to internet)
- Environment variables for database credentials
Provide complete docker-compose.yml with network and volume configuration.
Debugging Failed Deployments¶
Container Health Check Failing
My container starts but Traefik shows it as unhealthy:
docker compose ps output:
[PASTE OUTPUT]
My Dockerfile HEALTHCHECK:
[PASTE HEALTHCHECK LINE]
Application logs (docker compose logs app):
[PASTE RELEVANT LOGS]
Help me debug why the health check is failing. The app runs on [PORT] and uses [FRAMEWORK].
Optimizing Docker Images¶
Reduce Image Size
Real Examples¶
All examples in this module link to the egygeeks-docs GitHub repository where you can see complete, working setups for:
- Node.js/Express web application
- Python/FastAPI API with PostgreSQL
- Go microservice
- Next.js static site
- MkDocs documentation
- Full-stack application
Browse the examples/ directory in the repo to see real code.
Module Flow¶
Start Here
↓
[Lesson 1] Single Container
↓
[Lesson 2] App + Database
↓
[Lesson 3] Static Sites
↓
[Review] Practice with your own app
↓
[Next] Module 3: Going Live
What's Next After This Module¶
After completing this module, you'll:
- Be able to deploy any type of application
- Understand Docker and containers deeply
- Have reusable templates for your future projects
- Be ready to move on to Module 3: Going Live (production deployment)
Getting Help¶
Stuck? Try these resources:
Documentation¶
Within EgyGeeks¶
- Check the "Need Help?" section in each lesson
- Review the troubleshooting guides
- Ask in community forums (coming soon)
Templates and Examples¶
- See
/docs/project-templates/docker-compose/for ready-to-use templates - See
/docs/project-templates/workflows/for GitHub Actions examples - Check
/examples/in the repository
Time Estimate¶
- Lesson 1: 30-40 minutes
- Lesson 2: 40-50 minutes
- Lesson 3: 25-35 minutes
- Practice & Experimentation: 20-30 minutes
- Total Module Time: 1.5-2.5 hours
Tags¶
Deploy Docker Traefik Containers Deployment