This is a simple example demonstrating the use of the buildahcker Node.js library to create an Alpine Linux image for booting in a virtual machine (VM).
Make sure you have the following dependencies installed:
- Buildah: buildahcker requires it to create container images
- Node.js: buildahcker is a Node.js library
- QEMU: it can be used to run the generated image
Note that this was only tested on Linux.
- Clone this repository:
git clone https://github.com/davdiv/buildahcker-alpine-sample.git
cd buildahcker-alpine-sample
- Install npm dependencies:
npm install
- Build the Alpine image for qemu:
npm run build qemu
It will be generated in the output
folder.
Note that it is configured with the french (fr
) keyboard layout. You may want to change the configuration to match your own keyboard layout.
- Run the virtual machine with QEMU to test the image:
npm start
You should see QEMU booting the image. You can login as root
. There is no password.
It is also possible to connect through SSH:
ssh -p 55022 -i config/qemu/ssh/id_ed25519 root@localhost
The build.ts file uses the buildahcker library to create an Alpine Linux image with pre-installed packages, and customized network settings.
The script first creates a squashfs image from the Alpine base image, then writes it into a partition of a new disk image, and finally installs GRUB with a customized configuration to enable bootup in a VM.