Mini Project: Docker နဲ့ Static Website တစ်ခု Run မယ်
ဒီ project မှာ HTML page သေးသေးတစ်ခုကို Nginx container ထဲထည့်ပြီး browser မှာ run လုပ်ပါမယ်။ ဒီနည်းလမ်းက landing page, documentation page, prototype page, simple portfolio page စတဲ့ static content များကို container အဖြစ် package လုပ်တဲ့အခါအသုံးဝင်ပါတယ်။
# 1) Create index.html
cat > index.html <<'EOF'
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Docker Static Site</title>
</head>
<body>
<h1>Hello Docker</h1>
<p>This page is running inside an Nginx container.</p>
</body>
</html>
EOF
# 2) Create Dockerfile
cat > Dockerfile <<'EOF'
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html
EXPOSE 80
EOF
# 3) Build image
docker build -t docker-static-site:1.0 .
# 4) Run container
docker run --name docker-static-demo -d -p 8080:80 docker-static-site:1.0ပထမဆုံး index.html ဖန်တီးပါတယ်။ ပြီးရင် Nginx base image ကိုသုံးတဲ့ Dockerfile ရေးပါတယ်။ Build လုပ်ပြီး image ထုတ်ကာ container အဖြစ် run လုပ်ပါတယ်။
Browser မှာ http://localhost:8080 ဖွင့်ပါက Hello Docker page ပေါ်လာပါမယ်။Info
ဒီ project က Docker workflow အပြည့်ကိုပြပါတယ် — file ပြင်, Dockerfile ရေး, image build, container run, browser မှာ result ကြည့်။ Project သေးပေမယ့် real workflow ကိုနားလည်စေတဲ့ practice ကောင်းတစ်ခုပါ။