Sign inSign up

aetherinox/alpine-base

By aetherinox

•Updated over 1 year ago

Alpine linux base image integrated with s6-overlay. Can be used as a base for other docker projects.

Image
Internet of things
Operating systems
0

2.2K

aetherinox/alpine-base repository overview

⁠About

The files contained within this branch docker/alpine-base are utilized as a foundation. This base image only provides us with a docker image which has alpine linux, Nginx, a few critical packages, and the s6-overlay⁠ plugin.

This branch docker/alpine-base does NOT contain any applications. It is only to be used as a base image which will be called when you build your docker app's 📄 Dockerfile.

For a more detailed set of documentation, view the Github repo and alpine branch at:


The information here is very truncated to conserve space.



⁠Features

This docker image includes the following features:

  • Simple init process which allows the end-user to execute tasks like initialization (cont-init.d), finalization (cont-finish.d) and their own services with dependencies between them
  • s6-overlay integration provides proper PID 1 functionality
    • You'll never have zombie processes hanging around in your container, they are properly managed and cleaned up.
  • Multiple processes in a single container
  • Distributed as a small number of .tar.xz files depending on what exact functionality you need - to keep your image's number of layers small.
  • A whole set of utilities included in s6 and s6-portable-utils. Includes handy and composable utilities which make life much easier.
  • Log rotating out-of-the-box through logutil-service which uses s6-log⁠ under the hood.
  • Support for Docker's USER directive, to run your whole process tree as a specific user.

⁠Read First


To build a docker image using this base and the actual app you want to release, you need two different docker images:

  • Step 1: Build docker/alpine-base⁠ image (this repo)
    • When being built, the alpine-base 📄 Dockerfile will grab and install the files from the branch docker/core⁠
  • Step 2: Build your app's docker image that will run on top of this alpine image
  • Step 3: Release the docker image built from Step 2 to Github's Ghcr.io or hub.docker.com



⁠Building Image

These instructions outline how the alpine docker image is set up, and how to build your own docker image.


⁠Before Building

Prior to building the docker image, you must ensure the sections below are completed.


You must ensure when you build this docker image docker/alpine-base⁠, the following conditions must be met.


If the listed tasks above are not performed, your docker container will throw the following errors when started:

  • Failed to open apk database: Permission denied
  • s6-rc: warning: unable to start service init-adduser: command exited 127
  • unable to exec /etc/s6-overlay/s6-rc.d/init-envfile/run: Permission denied
  • /etc/s6-overlay/s6-rc.d/init-adduser/run: line 34: aetherxown: command not found
  • /etc/s6-overlay/s6-rc.d/init-adduser/run: /usr/bin/aetherxown: cannot execute: required file not found

⁠LF over CRLF

You cannot utilize Windows' Carriage Return Line Feed. All files must be converted to Unix' Line Feed. This can be done with Visual Studio Code⁠. OR; you can run the Linux terminal command 🗔 dos2unix to convert these files.

For the branches docker/alpine-base⁠ and your main app image, you can use the following recursive commands:


Caution

Be careful using the command to change **ALL** files. You should **NOT** change the files in your `📁 .git` folder, otherwise you will corrupt your git indexes.

If you accidentally run 🗔 dos2unix on your 📁 .git folder, do NOT push anything to git. Pull a new copy from the repo or reset your local files back to the remote:

git reset --hard origin/main

# Change ALL files
find ./ -type f | grep -Ev '.git|*.jpg|*.jpeg|*.png' | xargs dos2unix --

# Change run / binaries
find ./ -type f -name 'run' | xargs dos2unix --

For the branch docker/core⁠, you can use the following commands:

dos2unix docker-images.v3
dos2unix aetherxown.v1
dos2unix package-install.v1
dos2unix with-contenv.v1

⁠Set +x / 0755 Permissions

The files contained within this repo MUST have chmod 755 / +x executable permissions. If you are using our Github workflow sample deploy-docker-github.yml⁠, this is done automatically. If you are building the images manually; you need to do this. Ensure those files have the correct permissions prior to building the Alpine base docker image.

If you are building the docker/alpine-base⁠ or your main application images, you must ensure the files in those branches have the proper permissions. All of the executable files are named run:

find ./ -name 'run' -exec sudo chmod +x {} \;

Optional - If you want to set the permissions manually, run the following below. If you executed the find command above, you don't need to run the list of commands below:

sudo chmod +x ./root/etc/s6-overlay/s6-rc.d/init-adduser/run \
  ./root/etc/s6-overlay/s6-rc.d/init-crontab-config/run \
  ./root/etc/s6-overlay/s6-rc.d/init-custom-files/run \
  ./root/etc/s6-overlay/s6-rc.d/init-envfile/run \
  ./root/etc/s6-overlay/s6-rc.d/init-folders/run \
  ./root/etc/s6-overlay/s6-rc.d/init-keygen/run \
  ./root/etc/s6-overlay/s6-rc.d/init-migrations/run \
  ./root/etc/s6-overlay/s6-rc.d/init-permissions/run \
  ./root/etc/s6-overlay/s6-rc.d/init-samples/run \
  ./root/etc/s6-overlay/s6-rc.d/init-version-checks/run \
  ./root/etc/s6-overlay/s6-rc.d/svc-cron/run \
  ./root/etc/s6-overlay/s6-rc.d/svc-php-fpm/run \
  ./root/etc/s6-overlay/s6-rc.d/svc-nginx/run \
  ./root/etc/s6-overlay/s6-rc.d/init-php/run \
  ./root/etc/s6-overlay/s6-rc.d/init-nginx/run

For the branch docker/core⁠, there are a few files to change. The ending version number may change, but the commands to change the permissions are as follows:

sudo chmod +x docker-images.v3 \
  chmod +x aetherxown.v1 \
  chmod +x package-install.v1 \
  chmod +x with-contenv.v1


⁠Build Images

After completing the steps above; we will now build the 🔆 docker/alpine-base⁠ image.


⁠amd64

Creates the alpine amd64 docker image:

# Build alpine amd64
docker buildx build \
  --build-arg ARCH=x86_64 \
  --build-arg VERSION=3.22 \
  --build-arg BUILDDATE=20260812 \
  --build-arg RELEASE=stable \
  --tag ghcr.io/aetherinox/alpine-base:latest \
  --tag ghcr.io/aetherinox/alpine-base:3 \
  --tag ghcr.io/aetherinox/alpine-base:3.2 \
  --tag ghcr.io/aetherinox/alpine-base:3.22 \
  --tag ghcr.io/aetherinox/alpine-base:3.22-amd64 \
  --attest type=provenance,disabled=true \
  --attest type=sbom,disabled=true \
  --output type=docker \
  --builder default \
  --file Dockerfile \
  --platform linux/amd64 \
  --allow network.host \
  --network host \
  --no-cache \
  --push \
  .

⁠arm64

Creates the alpine arm64 docker image:

# Build alpine arm64
docker buildx build \
  --build-arg ARCH=aarch64 \
  --build-arg VERSION=3.22 \
  --build-arg BUILDDATE=20260812 \
  --build-arg RELEASE=stable \
  --tag ghcr.io/aetherinox/alpine-base:latest \
  --tag ghcr.io/aetherinox/alpine-base:3 \
  --tag ghcr.io/aetherinox/alpine-base:3.2 \
  --tag ghcr.io/aetherinox/alpine-base:3.22 \
  --tag ghcr.io/aetherinox/alpine-base:3.22-arm64 \
  --attest type=sbom,disabled=true \
  --output type=docker \
  --builder default \
  --file Dockerfile \
  --platform linux/arm64 \
  --allow network.host \
  --network host \
  --no-cache \
  --push \
  .

Note

If you want to only build the alpine docker image locally; remove `--push`.

After building the image, you can now call this base alpine image in your project's Dockerfile.




⁠Usage

To utilize this image, open the Dockerfile for the project you wish to utilize this image as your base, and then add the following at the top:

ARG ARCH=amd64
ARG ALPINE_VERSION=3.22

# from Dockerhub
FROM --platform=linux/${ARCH} aetherinox/alpine-base:${ALPINE_VERSION}

# from Github
FROM --platform=linux/${ARCH} ghcr.io/aetherinox/alpine-base:${ALPINE_VERSION}

Tag summary

Content type

Image

Digest

sha256:1dbe9a72f…

Size

15.5 MB

Last updated

over 1 year ago

docker pull aetherinox/alpine-base