# ── Step 1: Base Image ──────────────────────────────────────────────────────
# Use Ubuntu 24.04 LTS as the base operating system
FROM ubuntu:24.04

# Suppress interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive

# ── Step 2: Install Nginx ────────────────────────────────────────────────────
# Update package list, install nginx, then clean up to reduce image size
RUN apt-get update && \
    apt-get install -y nginx && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# ── Step 3: Copy Custom Configuration ───────────────────────────────────────
# Replace the default nginx config with our custom one
COPY ./nginx.conf /etc/nginx/nginx.conf

# ── Step 4: Copy Website Files ───────────────────────────────────────────────
# Copy the www-data folder (containing index.html) into nginx web root
COPY ./www-data /usr/share/nginx/html

# ── Step 5: Expose Port ──────────────────────────────────────────────────────
# Tell Docker this container listens on port 80 (HTTP)
EXPOSE 80

# ── Step 6: Start Nginx ──────────────────────────────────────────────────────
# Run nginx in the foreground so the container stays alive
CMD ["nginx", "-g", "daemon off;"]
