BM: Baca dalam Bahasa Melayu
World T4: Modules & Pipelines
Capstone mission 8: Blueprint Kedai Kancil
You will learn: to write Kedai Kancil's web counter as a blueprint, build it on your own Docker, and plan it on a pull request.
Checked with OpenTofu 1.13 on 1 Nov 2026
The problem
Mission 8: write Kedai Kancil’s web counter as a blueprint. Docker on your own laptop is the building site. What will your very first tofu plan show?
Pick one answer.
Try it
Step 1: tools and a folder. Then write providers.tf (below). It uses the Docker provider, version 4.6 or a newer 4.x.
Real mission
tofu versiondocker infomkdir kedai-blueprint && cd kedai-blueprint && git init
0 of 4 steps done · Your ticks are saved.
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 4.6"
}
}
}
provider "docker" {}Try it
Step 2: the blueprint. Which line opens the shop on your laptop’s port 8080?
Pick one answer.
Save this as main.tf. Add outputs.tf too: output "url" { value = "http://localhost:8080" }.
resource "docker_image" "web" {
name = "nginx:1.30-alpine"
keep_locally = true
}
resource "docker_container" "web" {
name = "kedai-kancil-web"
image = docker_image.web.image_id
ports {
internal = 80
external = 8080
}
}Try it
Step 3: build it on your laptop. Plan first, always.
Real mission
tofu inittofu fmt -check && tofu validatetofu plantofu apply
0 of 5 steps done · Your ticks are saved.
Try it
Step 4: the plan workflow. Build it, then save it as .github/workflows/plan.yml.
Tap blocks to add them. Put them in order.
Blocks
Your workflow
Tap a block above to start.
Workflow file .github/workflows/
name: Plan
What runs
Nothing to run yet.
Try it
Step 5: push it, then open a pull request that changes the port.
Real mission
printf "*.tfstate\n*.tfstate.*\n.terraform/\n" > .gitignoregit add . && git commit -m "Blueprint Kedai Kancil"git remote add origin https://github.com/YOUR-NAME/kedai-blueprint.git && git push -u origin maingit switch -c port-8081
0 of 5 steps done · Your ticks are saved.
Check
Let GitHub’s public API confirm it. Type your username, then check.
Check it on GitHub
- Your kedai-blueprint repo is publicNot checked yet
- It has main.tfNot checked yet
- It has the lock fileNot checked yet
- It has the plan workflowNot checked yet
- The workflow ran at least onceNot checked yet
- You opened a pull request thereNot checked yet
Check
The API can’t see everything. Check these yourself, then clean up.
Real mission
tofu destroydocker ps -a --filter name=kedai-kancil-web
0 of 5 steps done · Your ticks are saved.
You did it!
You can now blueprint a real service, build it, and plan every change in CI.
Go deeper (optional)
Safety: only your own laptop, port 8080 free, and tofu destroy at the end. Install OpenTofu: opentofu.org/docs/intro/install. With kind instead, the kubernetes provider works the same way. Where the story breaks: CI planned with an empty register. Real teams give CI the shared backend (T3·1), so its plan matches the building.
Bahasa Melayu
Misi 8: tulis kaunter web Kedai Kancil sebagai pelan. Docker di laptop anda sendiri ialah tapak binaan. Apa yang tofu plan pertama anda akan tunjuk?
Langkah 1: alat dan folder. Kemudian tulis providers.tf (di bawah). Ia guna provider Docker, versi 4.6 atau 4.x yang lebih baharu.
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 4.6"
}
}
}
provider "docker" {}
Langkah 2: pelan. Baris mana yang buka kedai pada port 8080 laptop anda?
Simpan ini sebagai main.tf. Tambah outputs.tf juga: output "url" { value = "http://localhost:8080" }.
resource "docker_image" "web" {
name = "nginx:1.30-alpine"
keep_locally = true
}
resource "docker_container" "web" {
name = "kedai-kancil-web"
image = docker_image.web.image_id
ports {
internal = 80
external = 8080
}
}
Langkah 3: bina di laptop anda. Plan dahulu, sentiasa.
Langkah 4: workflow plan. Binanya, kemudian simpan sebagai .github/workflows/plan.yml.
Langkah 5: push, kemudian buka pull request yang tukar port.
Biar API awam GitHub sahkan. Taip nama pengguna anda, kemudian semak.
API tak nampak semua. Semak ini sendiri, kemudian kemas.
Kini anda boleh tulis pelan servis sebenar, binanya, dan plan setiap perubahan dalam CI.
You finished this before. Practice is always welcome!
Official docs: Install OpenTofu · Docker provider (kreuzwerker/docker) on the OpenTofu Registry · Docker provider docs (Terraform Registry) · Get Docker · opentofu/setup-opentofu
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?