Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe use of template repos and GitHub CI #41

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

This tutorial will walk you through the process of creating a custom Linux image using the Builder tool. We will start with the Builder example repository and build a feature to add an `nginx` HTTP server to our image.

Let's begin by cloning the Builder example repository:
Let's begin by creating a new GitHub repository based on the Builder example repository using this link:

https://github.com/new?template_name=builder_example&template_owner=gardenlinux

This repo has a GitHub Actions workflow enabled, so it will already start building the image on GitHub's hosted runners.

To customize the image, clone the repo locally:

```shell
git clone https://github.com/gardenlinux/builder_example
cd builder_example
git clone https://github.com/your_username/my_linux_image
cd my_linux_image
```

To ensure that your local Podman installation is working correctly, you can test it by running the following command:
Expand All @@ -15,10 +21,10 @@ To ensure that your local Podman installation is working correctly, you can test
./build base
```

This command will create a bootable Debian Bookworm disk image at `.build/base-amd64-bookworm-6f72b564.raw` (note that the commit may have changed since the time of writing). You can test run the image using QEMU:
This command will create a bootable Debian Trixie disk image at `.build/base-amd64-trixie-6f72b564.raw` (note that the commit may have changed since the time of writing). You can test run the image using QEMU:

```shell
qemu-system-x86_64 -m 2048 -nodefaults -display none -serial mon:stdio -drive if=pflash,unit=0,readonly=on,format=raw,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=virtio,format=raw,file=.build/base-amd64-bookworm-6f72b564.raw
qemu-system-x86_64 -m 2048 -nodefaults -display none -serial mon:stdio -drive if=pflash,unit=0,readonly=on,format=raw,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=virtio,format=raw,file=.build/base-amd64-trixie-6f72b564.raw
```

Now that we have verified that everything is working correctly, let's proceed to build our own feature.
Expand Down Expand Up @@ -86,9 +92,32 @@ To test your feature, build the image using the following command:
You can then run the image with QEMU using the following command:

```shell
qemu-system-x86_64 -m 2048 -nodefaults -display none -serial mon:stdio -drive if=pflash,unit=0,readonly=on,format=raw,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=virtio,format=raw,file=.build/base-nginx-amd64-bookworm-local.raw -netdev user,id=net0,hostfwd=tcp::8080-:80 -device virtio-net-pci,netdev=net0
qemu-system-x86_64 -m 2048 -nodefaults -display none -serial mon:stdio -drive if=pflash,unit=0,readonly=on,format=raw,file=/usr/share/OVMF/OVMF_CODE.fd -drive if=virtio,format=raw,file=.build/base-nginx-amd64-trixie-local.raw -netdev user,id=net0,hostfwd=tcp::8080-:80 -device virtio-net-pci,netdev=net0
```

If everything worked as intended, you should see the system boot up. Once the system is booted, opening http://localhost:8080 in a browser should display the "Hello World!" message.

Congratulations! You have successfully created your first feature for the Builder. :tada:
To also build the new image on GitHub Actions, we'll need to modify the `.github/workflows/build.yml` file.

Let's change the *build* step to include the `nginx` feature we just created, and let's upload our built image to GitHub's artifact storage:

```diff
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 181a646..9e4261e 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -13,4 +13,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build the image
- run: ./build base
+ run: ./build base-nginx
+ - uses: actions/upload-artifact@v3
+ with:
+ name: my-linux-image
+ path: .build/
```

Now commit and push your changes and GitHub will build the image for you.

Congratulations! You have successfully created your first feature for the Builder and setup a CI Pipeline to build the image. :tada:
Loading