Skip to content

Server Tour: Understanding the Setup

Progress: Module 1 of 4 → Page 2 of 3

Overview

Now that you have SSH access, let's understand what's running on the EgyGeeks server. You'll learn about Docker containers, Traefik routing, and GitHub Actions automation.

Time: 10 minutes

Prerequisites Checklist

Before you start, make sure you have:

  • Completed Lesson 1: Get Access
  • SSH access to the server working
  • Ability to run commands on the server via SSH

What's Running on the Server?

The EgyGeeks server runs three main technologies:

User Browser/Request
    Traefik (Port 80/443)
    (Reverse Proxy Router)
    ┌────┴────┬─────────┐
    ↓         ↓         ↓
 Docker    Docker    Docker
Container 1 Container 2 Container 3
(App A)   (App B)   (App C)

Let's explore each:


1. Docker Containers

What is Docker?

Docker packages your application and all its dependencies into a container - a lightweight, isolated environment that runs the same way everywhere.

Without Docker:

Local Machine: Works perfectly
Server: "But I'm missing Python 3.9!"
Production: "It works on my machine!"

With Docker:

Local Machine: Docker container runs Python 3.9, Node 16, etc.
Server: Docker container runs Python 3.9, Node 16, etc.
Production: Same container, always works

Key Docker Concepts

Concept Explanation
Image Blueprint (like a recipe)
Container Running instance of an image
Dockerfile Instructions to build an image
docker-compose.yml Configuration to run multiple containers

Explore Docker on Server

Log into the server and explore:

# SSH to server
ssh username@50.3.85.110

# List all running containers
docker ps

# Output example:
# CONTAINER ID   IMAGE        COMMAND         PORTS
# a1b2c3d4e5f6   nginx:latest "nginx..."      0.0.0.0:80->80/tcp
# f6e5d4c3b2a1   app:latest   "npm start"     8080->8080/tcp

# See container details
docker ps -a

# View logs from a container
docker logs container_name

# Stop/Start a container
docker stop container_name
docker start container_name

Ask AI for Help

Copy this prompt to Claude or ChatGPT:

I'm learning about Docker on the EgyGeeks server. I can see containers running when I use `docker ps`.

Can you explain:
1. What's the difference between a Docker image and a container?
2. Why use Docker instead of just installing apps directly on the server?
3. How does a Dockerfile work?
4. What does docker-compose.yml do?

Use simple analogies to help me understand.

Docker Compose

Most applications on the server use docker-compose.yml for multi-container setups:

version: '3'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"

  app:
    image: app:latest
    environment:
      - NODE_ENV=production

Location on Server:

# View all docker-compose files
find /opt/apps -name "docker-compose.yml"

# View a specific docker-compose file
cat /opt/apps/egygeeks-docs/docker-compose.yml


2. Traefik: Smart Routing

The Problem Traefik Solves

You have multiple applications running, but only one server. How do you route traffic to the right app?

Request: http://50.3.85.110/app-a
Traefik (decision point)
"Route /app-a to Container A"
Container A responds

How Traefik Works

  1. Listens on port 80 and 443
  2. Routes requests based on the URL path
  3. Automatically discovers containers
  4. Handles SSL/HTTPS certificates

Traefik Configuration

Traefik learns about containers from their labels in docker-compose:

services:
  my-app:
    image: my-app:latest
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.my-app.rule=PathPrefix(`/my-app`)"
      - "traefik.http.services.my-app.loadbalancer.server.port=3000"

This tells Traefik: "Route requests to /my-app to port 3000 of this container"

Real Example on Server

# SSH to server
ssh username@50.3.85.110

# Check Traefik dashboard (if enabled)
curl http://localhost:8080/dashboard/

# View Traefik logs
docker logs traefik

# List Traefik routes
docker exec traefik traefik config dump

Common Routing Patterns

URL Routes To Purpose
http://50.3.85.110/developers Documentation Team docs
http://50.3.85.110/api API Server Backend API
http://50.3.85.110/app Web App Frontend application

Ask AI for Help

Copy this prompt to Claude or ChatGPT:

I'm learning about Traefik on our server at 50.3.85.110.

Our docker-compose.yml files have labels like:
- "traefik.enable=true"
- "traefik.http.routers.my-app.rule=PathPrefix(`/my-app`)"
- "traefik.http.services.my-app.loadbalancer.server.port=3000"

Questions:
1. Why do we need a reverse proxy like Traefik?
2. How does Traefik know which container to route requests to?
3. What do these labels mean?
4. How does URL routing work (e.g., /my-app goes to container A)?
5. What's the difference between Traefik and nginx?

3. GitHub Actions: Automated Deployment

What is GitHub Actions?

GitHub Actions automatically runs scripts when you push code. Common uses:

  • Testing: Run tests automatically
  • Building: Build Docker images
  • Deploying: Deploy to server automatically
  • Notifications: Notify the team of status

Workflow

You push code to GitHub
GitHub Actions triggers
Runs tests (e.g., npm test)
Builds Docker image (e.g., docker build)
Pushes image to registry
Connects to server
Updates running container
Application is live!

Example Workflow File

GitHub Actions workflows are YAML files in .github/workflows/:

name: Deploy
on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Build Docker image
        run: docker build -t app:latest .

      - name: Push to server
        run: |
          ssh user@50.3.85.110 'cd /opt/apps/my-app && docker-compose up -d'

Check Workflow Status

# View workflow files in your project
cat .github/workflows/deploy.yml

# On GitHub, go to: Actions tab → View logs of past deployments

# On server, check deployment logs
ssh username@50.3.85.110
docker logs my-app

Deployment Flow

  1. Code Push: You git push to GitHub
  2. Workflow Triggers: GitHub Actions reads .github/workflows/
  3. CI/CD Pipeline: Tests, builds, deploys
  4. Server Update: Container is restarted with new code
  5. Live: Your changes are now live!

Ask AI for Help

Copy this prompt to Claude or ChatGPT:

I'm trying to understand GitHub Actions and continuous deployment for our server.

Our workflow file (.github/workflows/deploy.yml) does this:
1. Checks out code
2. Builds Docker image
3. SSHs to 50.3.85.110
4. Runs docker-compose up -d

Questions:
1. How does continuous deployment work step-by-step?
2. How does GitHub Actions connect to our server securely?
3. What happens if the deployment fails?
4. How do I check if my deployment was successful?
5. What's the difference between CI and CD?

Understanding the Tech Stack

Here's how everything works together:

┌─────────────────────────────────────────────────────────┐
│                    GitHub Repository                    │
│                    Your source code                      │
└──────────────────────┬──────────────────────────────────┘
                       │ (you push code)
         ┌─────────────────────────────┐
         │   GitHub Actions CI/CD       │
         │  - Run tests                 │
         │  - Build Docker image        │
         │  - Deploy to server          │
         └──────────────┬────────────────┘
                        │ (ssh deploy)
    ┌───────────────────────────────────────┐
    │     EgyGeeks Server (50.3.85.110)     │
    │                                       │
    │  ┌────────────────────────────────┐   │
    │  │   Traefik (Reverse Proxy)      │   │
    │  │   - Listens on port 80/443     │   │
    │  │   - Routes requests to apps    │   │
    │  └────┬──────────────┬────────────┘   │
    │       │              │                 │
    │  ┌────▼──┐      ┌────▼──┐             │
    │  │Docker │      │Docker │             │
    │  │App A  │      │App B  │             │
    │  └───────┘      └───────┘             │
    └───────────────────────────────────────┘
              User accesses app
         http://50.3.85.110/my-app

Server Directory Structure

Now that you understand the setup, here's how apps are organized:

# SSH to server
ssh username@50.3.85.110

# Navigate to apps directory
cd /opt/apps

# List all apps
ls -la

# Example structure:
# /opt/apps/
# ├── egygeeks-docs/       # Documentation
# │   ├── docker-compose.yml
# │   ├── Dockerfile
# │   └── docs/
# ├── my-app/              # Your app
# │   ├── docker-compose.yml
# │   ├── Dockerfile
# │   └── src/
# └── traefik/             # Reverse proxy
#     └── docker-compose.yml

# View an app's docker-compose
cat /opt/apps/egygeeks-docs/docker-compose.yml

# Check an app's status
cd /opt/apps/my-app && docker-compose ps

Verification Steps

Complete these checks to verify your understanding:

  • You can SSH to the server
  • You can run docker ps and see containers
  • You understand the difference between image and container
  • You can explain what Traefik does
  • You can describe how GitHub Actions deploys code

Key Takeaways

  • Docker packages applications into isolated containers
  • Traefik routes requests from the internet to the right container
  • GitHub Actions automates testing and deployment
  • Together they enable fast, reliable application deployment

Common Commands Reference

# Docker commands
docker ps                          # List running containers
docker ps -a                       # List all containers
docker logs container_name         # View container logs
docker exec container_name bash    # Run command in container
docker stop container_name         # Stop a container
docker start container_name        # Start a container

# Docker Compose commands
docker-compose up -d               # Start services in background
docker-compose down                # Stop all services
docker-compose logs service_name   # View service logs
docker-compose restart             # Restart services

# Server navigation
cd /opt/apps                       # Go to apps directory
ls -la                             # List apps
docker-compose ps                  # View status of one app

What's Next?

Now you understand the infrastructure. Let's deploy a simple Hello World application!

Next Lesson: 3. First Deployment

Previous Lesson: 1. Get Access


Need Help?

Common Questions

Q: What if a container keeps crashing? A: Check its logs: docker logs container_name

Q: How do I stop all containers? A: docker-compose down (from the app directory)

Q: How do GitHub Actions know the server login? A: SSH keys are stored securely in GitHub repository secrets

Q: Can I run commands directly on the server? A: Yes, SSH in and run any command: ssh user@50.3.85.110 'docker ps'

Quick Help

Quick AI Prompts

Docker basics:

Explain Docker containers in simple terms with real-world analogies.
What's the difference between images and containers?

Traefik routing:

I'm using Traefik on server 50.3.85.110. How does URL routing work?
Explain how PathPrefix routing directs traffic to containers.

CI/CD pipeline:

Explain continuous deployment with GitHub Actions step-by-step.
How does code go from git push to running on the server?

Docker commands:

I'm managing Docker containers on the EgyGeeks server.
Show me the essential Docker and docker-compose commands I need to know.

References


Tags: Server Setup, Docker, Traefik, GitHub Actions, Infrastructure

Module: 1 of 4 | Page: 2 of 3