#!/bin/sh
# Start containers for Docker exercises
# Requires: docker load -i busybox.tar (run once before interview)

set -e

echo "Starting interview containers..."

# Start web container with busybox httpd
docker run -d \
    --name web \
    -p 8080:8080 \
    -e SERVICE_NAME=web \
    -e SERVICE_TYPE=http \
    busybox:latest \
    sh -c "echo 'OK' > /tmp/index.html && httpd -f -p 8080 -h /tmp"

# Start worker container
docker run -d \
    --name worker \
    -e SERVICE_NAME=worker \
    -e WORKER_ID=1 \
    busybox:latest \
    sh -c "while true; do echo '[worker] Processing task...'; sleep 45; done"

# Start scheduler container
docker run -d \
    --name scheduler \
    -e SERVICE_NAME=scheduler \
    -e INTERVAL=60 \
    busybox:latest \
    sh -c "while true; do echo '[scheduler] Running scheduled job'; sleep 60; done"

echo ""
echo "Containers started:"
docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"
