Skip to main content
Deploy the AWS Certified App using Docker for consistent, portable deployments across any environment.

Prerequisites

Docker Engine

Version 20.10 or higher

Docker Compose

Version 2.0+ (optional)

Verify Docker Installation

docker --version
# Docker version 24.0.0 or higher

docker compose version
# Docker Compose version v2.20.0 or higher
If Docker is not installed, download it from docker.com

Quick Start with Docker Hub

The fastest way to run the app is using the pre-built image from Docker Hub:
1

Pull the image

Download the official image:
docker pull thisisrober/aws-exam-prep-app:latest
Expected output:
latest: Pulling from thisisrober/aws-exam-prep-app
Digest: sha256:abc123...
Status: Downloaded newer image for thisisrober/aws-exam-prep-app:latest
2

Run the container

Start the container:
docker run -d \
  --name aws-exam-app \
  -p 5173:5173 \
  --restart unless-stopped \
  thisisrober/aws-exam-prep-app:latest
The -d flag runs the container in detached mode (background)
3

Access the application

Open your browser and navigate to:http://localhost:5173

Building from Source

If you want to customize the image or build from source code:

Dockerfile Overview

The application uses a multi-stage build for optimal image size:
Dockerfile
# Stage 1: Build
FROM node:18-alpine AS builder

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy application files
COPY . .

# Build the application
RUN npm run build

# Stage 2: Runtime
FROM node:18-alpine

WORKDIR /app

# Install serve to host the built app
RUN npm install -g serve

# Copy built application from builder stage
COPY --from=builder /app/dist ./dist

# Create non-root user for security
RUN addgroup -g 1001 -S nodejs && \
    adduser -S nodejs -u 1001
USER nodejs

# Expose port
EXPOSE 5173

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD node -e "require('http').get('http://localhost:5173', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"

# Start the application
CMD ["serve", "-s", "dist", "-l", "5173"]

Build Your Own Image

1

Clone the repository

git clone https://github.com/thisisrober/aws-certified-app.git
cd aws-certified-app
2

Build the Docker image

docker build -t aws-exam-app:custom .
The build process:
  1. Installs dependencies with npm ci
  2. Builds the production bundle with npm run build
  3. Creates a lightweight runtime image
  4. Copies only the built files
The build typically takes 2-5 minutes depending on your system.
3

Run your custom image

docker run -d \
  --name aws-exam-app \
  -p 5173:5173 \
  aws-exam-app:custom

Docker Compose Deployment

For easier management and configuration, use Docker Compose:

docker-compose.yml

The project includes a docker-compose.yml file:
docker-compose.yml
version: '3.8'

services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: aws-exam-app
    ports:
      - "5173:5173"
    environment:
      - NODE_ENV=production
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "node", "-e", "require('http').get('http://localhost:5173', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s
    networks:
      - app-network

networks:
  app-network:
    driver: bridge

Deploy with Docker Compose

# Build and start the services
docker compose up -d --build

# View logs
docker compose logs -f

# Stop the services
docker compose down

Container Management

Common Docker Commands

# Start the container
docker start aws-exam-app

# Stop the container
docker stop aws-exam-app

# Restart the container
docker restart aws-exam-app

# Remove the container
docker rm aws-exam-app

# Remove the container (force)
docker rm -f aws-exam-app

Configuration Options

Port Mapping

Change the host port while keeping container port 5173:
# Run on port 8080
docker run -d -p 8080:5173 --name aws-exam-app thisisrober/aws-exam-prep-app:latest

# Access at http://localhost:8080

Environment Variables

Pass environment variables to the container:
docker run -d \
  --name aws-exam-app \
  -p 5173:5173 \
  -e NODE_ENV=production \
  thisisrober/aws-exam-prep-app:latest

Resource Limits

Limit CPU and memory usage:
docker run -d \
  --name aws-exam-app \
  -p 5173:5173 \
  --memory="512m" \
  --cpus="0.5" \
  thisisrober/aws-exam-prep-app:latest

Restart Policies

Restart unless manually stopped:
docker run -d --restart unless-stopped aws-exam-app

Health Checks

The Docker image includes a built-in health check:
# Check health status
docker inspect --format='{{json .State.Health}}' aws-exam-app | jq
Health check configuration:
  • Interval: 30 seconds
  • Timeout: 10 seconds
  • Start Period: 5 seconds
  • Retries: 3 attempts
The health check makes an HTTP request to http://localhost:5173 and verifies a 200 status code.

Troubleshooting

Check the logs for errors:
docker logs aws-exam-app
Common causes:
  • Build errors in the application
  • Port already in use
  • Insufficient permissions
If you see “port is already allocated”:
# Find what's using port 5173
lsof -i :5173  # macOS/Linux
netstat -ano | findstr :5173  # Windows

# Use a different port
docker run -d -p 8080:5173 --name aws-exam-app thisisrober/aws-exam-prep-app:latest
Ensure Docker is running:
# Check Docker status
docker info

# Start Docker Desktop (if installed)
# Or start Docker service
sudo systemctl start docker  # Linux
If pulling from Docker Hub fails:
  1. Check your internet connection
  2. Verify the image name is correct
  3. Try with explicit tag:
docker pull thisisrober/aws-exam-prep-app:latest
  1. If behind a proxy, configure Docker:
# Create/edit ~/.docker/config.json
{
  "proxies": {
    "default": {
      "httpProxy": "http://proxy:port",
      "httpsProxy": "http://proxy:port"
    }
  }
}
Increase Docker memory limit:Docker Desktop:
  1. Open Settings → Resources
  2. Increase Memory to at least 2GB
  3. Click Apply & Restart
Linux:
# Build with resource limits
docker build --memory=2g -t aws-exam-app .

Security Best Practices

Always follow security best practices when deploying containers:

Non-root User

The image runs as user nodejs (UID 1001), not root

Minimal Base Image

Uses node:18-alpine for a small attack surface

Health Checks

Built-in health monitoring for container orchestration

Multi-stage Build

Separates build and runtime for smaller images

Production Considerations

1

Use specific image tags

Instead of latest, use version tags:
docker pull thisisrober/aws-exam-prep-app:v1.0.0
2

Set up reverse proxy

Use Nginx or Traefik for HTTPS and load balancing
3

Configure monitoring

Set up container monitoring with Prometheus or similar tools
4

Implement logging

Forward logs to a centralized logging system

Next Steps

Production Deployment

Learn about production optimization and best practices

Local Development

Set up a local development environment

Build docs developers (and LLMs) love