# Alpine

[Source files](https://github.com/bfren/docker-alpine) (GitHub)\
[Container images](https://hub.docker.com/r/bfren/alpine) (Docker Hub)

## Acknowledgements

[Docker Alpine](https://github.com/alpinelinux/docker-alpine) is a tiny distribution of Linux designed specifically for use in containers.

[esh](https://github.com/jirutka/esh) is a lightweight templating engine using POSIX-compatible syntax.

## Tags

*x.x and x.x.x refer to the bfren image versions.*

<table><thead><tr><th width="209.49763033175356">Alpine Version</th><th>Tags</th></tr></thead><tbody><tr><td>3.12</td><td>alpine3.12, alpine3.12.9, alpine3.12-x.x, alpine3.12-x.x.x</td></tr><tr><td>3.13</td><td>alpine3.13, alpine3.13.7, alpine 3.13-x.x, alpine3.13-x.x.x</td></tr><tr><td>3.14</td><td>alpine3.14, alpine3.14.3, alpine3.14-x.x, alpine3.14-x.x.x</td></tr><tr><td>3.15</td><td>latest, alpine3, alpine3.15, alpine3.15.0, alpine3.15-x.x, alpine3.15-x.x.x</td></tr><tr><td>edge</td><td>alpineedge, alpineedge-x.x, alpineedge-x.x.x</td></tr></tbody></table>

In addition, you can add `-dev` and `-beta` suffixes to access development / test builds (see Docker Hub for further details).

## Environment Variables

<table><thead><tr><th width="150">Name</th><th width="150">Values</th><th width="248.47063429913857">Description</th><th>Default</th></tr></thead><tbody><tr><td><code>BF_DEBUG</code></td><td>0 or 1</td><td>Set to 0 to disable debug log output messages.</td><td>1</td></tr></tbody></table>

## Packages

If you need to build the image with a different timezone to the default ("Europe/London"), you can do so by setting the `TZ` ARG, or by installing the `tzdata` package. (Please note this is only possible if you are building the image yourself - otherwise you will need to use [bf-tz](https://docs.bfren.dev/docker/alpine-s6/executables#bf-tz).)

As well as the standard repositories, the edge repos are tagged with `@edgemain` and `@edgecomm`. This means you can, for example, do `apk add curl@edgemain` or `apk add php8@edgecomm` to add the edge versions of packages.

## Cron

This image contains only one service: `cron`, which is enabled by default. If you want to add scripts or executables to the cron you have two options.

### Option 1: `/etc/periodic/`

The simplest way to add tasks to the cron in Alpine Linux is to place an executable file in one of the directories under `/etc/periodic/` (remember to set the executable attribute in `/etc/fix-attrs.d/`):

```bash
$ ls /etc/periodic/
1min    15min    daily    hourly    monthly    weekly
```

It's pretty obvious how frequently they run! An example of this method can be found in the [Nginx PHP](https://docs.bfren.dev/docker/base-images/nginx-php) image.

### Option 2: `/etc/crontabs/root`

If you want more control over your cron tasks you can create a normal crontab file:

```bash
$ head -n 1 /etc/crontabs/root
0 */8 * * * db-backup > /dev/null 2>&1
```

However, if you do this, remember you will be overriding the default file when your `/overlay/` is copied over the image files, so you need to include the [default directives](https://github.com/bfren/docker-alpine-s6/blob/main/overlay/etc/crontabs/root) if you don't want to break the cron further down the line.

## Templating with esh

The image comes pre-installed with [esh](https://github.com/jirutka/esh), a simple shell-based templating engine. It is extremely lightweight, and very easy to use.

All dynamic configuration files in the bfren ecosystem are built using esh, and the default location for those templates is `/etc/bf/templates`.
