• Stars
    star
    178
  • Rank 213,951 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Make customized Alpine Linux rootfs (base image) for containers

Make Alpine Linux RootFS

Build Status

This project provides a script for building customized Alpine Linux rootfs (a base image if you like) for containers. It’s quite simple (250 LoC of shell), fast and requires minimum dependencies (just common Linux tools).

Tip
Do you want to just quickly chroot into Alpine Linux, e.g. on CI? Check out alpine-chroot-install!

Requirements

  • Linux system

  • POSIX-sh compatible shell (e.g. Busybox ash, dash, ZSH, bash, …)

  • common userland with chroot, getopt, grep, sed, sha256sum, wget (e.g. from Busybox, GNU coreutils, …)

  • tar (full-blown)

Usage

Read documentation in alpine-make-rootfs. See .github/workflows/ci.yml for GitHub Actions example.

You can copy alpine-make-rootfs into your repository or download it on demand, e.g.:

wget https://raw.githubusercontent.com/alpinelinux/alpine-make-rootfs/v0.6.1/alpine-make-rootfs \
    && echo '73948b9ee3580d6d9dc277ec2d9449d941e32818  alpine-make-rootfs' | sha1sum -c \
    || exit 1

Examples

Installation Script in Heredoc

sudo ./alpine-make-rootfs \  # (1)
    --branch v3.8 \  # (2)
    --packages 'ruby ruby-bigdecimal sqlite' \  # (3)
    --timezone 'Europe/Prague' \  # (4)
    --script-chroot \  # (5)
    example-$(date +%Y%m%d).tar.gz - <<'SHELL'  # (6)
        # Copy some file from the repository root to the rootfs.
        install -D -m 755 examples/hello_world.rb /app/hello_world.rb

        # Install some dev packages and gem mailcatcher.
        apk add --no-progress -t .make build-base ruby-dev sqlite-dev
        gem install --no-document mailcatcher

        # Clean-up dev packages.  (7)
        apk del --no-progress .make
SHELL
  1. The script needs to create files owned by root or other users and optionally uses chroot (when --script-chroot is specified), so it must be run under root (e.g. using sudo).

  2. Alpine branch (release) to install (see Alpine Releases).

  3. You can name packages to install into the chroot, in addition to base packages (see ALPINE_BASE_PKGS in alpine-make-rootfs).

  4. You may specify timezone to set (default is UTC).

  5. This flag tells that the installation script will be executed inside chroot with the rootfs as new root. Your current working directory is binded at /mnt inside the chroot and $PWD for the script is set to /mnt, so you can easily access files out of the chroot and copy them into the rootfs.

  6. Installation script may be provided also via STDIN, using a convenient heredoc syntax. The script passed is executed using /bin/sh -e.

  7. Note that it’s not needed to clean apk cache, this is done automatically.

Create Docker Base Image

Create your own (customized) up-to-date base image.

sudo ./alpine-make-rootfs --branch v3.8 - | docker import -c 'CMD /bin/sh' - my/alpine:3.8

Create OCI Image

You can use simply shell script sloci-image to pack the generated rootfs as a single-layer OCI image.

sudo ./alpine-make-rootfs --branch v3.8 --script-chroot rootfs.tar.gz ./install.sh
./sloci-image --entrypoint /start.sh --port 80/tcp --tar rootfs.tar.gz alpine:3.8

License

This project is licensed under MIT License. For the full text of the license, see the LICENSE file.

More Repositories

1

docker-alpine

Official Alpine Linux Docker image. Win at minimalism!
Lua
1,067
star
2

aports

[MIRROR] Alpine packages build scripts
Shell
634
star
3

alpine-make-vm-image

Make customized Alpine Linux disk image for virtual machines
Shell
293
star
4

alpine-chroot-install

Install Alpine Linux in chroot with a breeze. Build ARM on Travis CI or any other x86_64 CI.
Shell
285
star
5

apk-tools

[MIRROR] Alpine package manager
C
164
star
6

alpine-conf

[MIRROR] Alpine configuration management scripts
Shell
67
star
7

abuild

[MIRROR] Build script to build Alpine packages
Shell
59
star
8

mkinitfs

[MIRROR] Tool to create initramfs images
Shell
54
star
9

awall

[MIRROR] Alpine firewall configuration tool
Lua
46
star
10

alpine-secdb

[MIRROR] Alpine Linux security database
Lua
40
star
11

aports-turbo

[MIRROR] Alpine Linux package database
Lua
24
star
12

docker-abuild

WARNING This project has moved to Alpine Linux GitLab instance
Shell
19
star
13

linux-stable-grsec

grsecurity backports for linux-stable branches
C
17
star
14

alpine-iso

Alpine ISO image generation scripts (mirror)
Makefile
16
star
15

alpine-docker-gitlab

[MIRROR] Gitlab docker image based on Alpine Linux
Shell
14
star
16

turbo-paste

[MIRROR] Turbo paste
Lua
13
star
17

alpine-netboot

Alpine netboot (mirror)
CSS
9
star
18

ca-certificates

Mirror of git://git.alpinelinux.org/ca-certificates
Perl
9
star
19

alpine-wiki

Alpine Linux wiki
HTML
8
star
20

alpine-backup

Alpine Remote Backup (mirror)
Shell
6
star
21

alpine-baselayout

[MIRROR] Alpine boot scripts
Makefile
6
star
22

lua-aports

[MIRROR] Aports tools written in Lua
Lua
6
star
23

dmvpn-tools

[MIRROR] Userland tools to setup and manage DMVPN
Shell
4
star
24

alpine-mksite

[MIRROR] Website for alpinelinux.org
CSS
3
star
25

alpine-drone-ci

Build Alpine Linux packages with drone CI
Shell
2
star
26

alpine-mirror-status

[MIRROR] Scripts to generate Alpine mirror statistics
Lua
2
star
27

alpine_bootstrap

Alpine Linux bootstrap theme for drupal
CSS
1
star
28

build-server-status

[MIRROR] Web page for Alpine Linux build servers
Go
1
star