Introduction to the Course

Get introduced to the course in this lesson and learn its prerequisites.

Prerequisites

In this course, we’ll learn the basics of creating Alpine Linux packages. You don’t need any prior knowledge about Alpine Linux packages to take this course. However, you should know how to use the CLI and have a basic understanding of how a Linux distribution works.

We’ve provided integrated terminals for each lesson within the course, in which you can execute commands yourself. You won’t need any further set up on your computer, and you’ll find all the required Docker commands for this course and their explanations within the course. For more detailed explanations of the commands, please refer to Docker’s manual.

Docker
Docker

Goal of this course

In this course, we’ll learn how to use Alpine Linux productively and how to create our own apk packages for when a package we need isn’t available in the repositories or we want to package a private project. We’ll also explore how to set up our private apk repository and how we can use it in our own Docker containers.

Hello World

To get an initial idea of how packaging in Alpine Linux works, we can look at the APKBUILD below. Don’t worry if you don’t understand what it does yet—we’ll learn all about it in this course.

Press + to interact
pkgname=hello-world
pkgver=1.0.0
pkgrel=1
pkgdesc="A simple hello world program"
arch="noarch"
url="https://educative.io"
license="UNLICENSE"
options="!check"
prepare() {
mkdir -p "$srcdir"
}
package() {
mkdir -p "$pkgdir"/usr/bin
cat <<EOF > "$pkgdir"/usr/bin/hello-world
#!/bin/sh
echo "Hello world!"
EOF
chmod +x "$pkgdir"/usr/bin/hello-world
}

We can now try building this APKBUILD to get a first taste of how building a package works. Try running the commands below in the provided terminal.

Press + to interact
abuild -r # Build the package
apk add hello-world # Install the package we just built
hello-world # Run the "hello-world" executable from the package we just installed

Upon starting the terminal, some prerequisites will be installed for you.

After that, you can build the .apk package with abuild -r, install the .apk package with apk add hello-world, and execute the command that’s contained in the hello-world package.

Terminal 1
Terminal
Loading...