docker-images/README.md

128 lines
7.8 KiB
Markdown
Raw Normal View History

2020-08-24 12:08:43 +00:00
# docker-images
2020-09-26 13:56:36 +00:00
> Dockerfiles and scripts to build various Docker images I rely on.
2021-03-26 22:54:22 +00:00
This repository contains a bunch of Dockerfiles that I've written myself. I run them on my Hashicorp [Consul](https://consul.io/) and [Nomad](https://www.nomadproject.io/) cluster, which is comprised of 5 Raspberry Pi 4B+ boards (3 server nodes for both Consul and Nomad).
2020-09-26 13:56:36 +00:00
2020-10-21 23:23:15 +00:00
## System Requirements
- Linux
- Bash
- Docker
## Getting started
The script that does the magic is called `imagebuilder.sh` in the root of this repository. Run it to get usage information:
```bash
./imagebuilder.sh
```
2021-03-26 22:54:22 +00:00
## FAQ
2020-10-22 00:46:57 +00:00
2021-03-26 22:54:22 +00:00
### Why write your own Dockerfiles for services that already ship with one?
Multiple reasons:
2020-10-22 00:46:57 +00:00
2021-03-26 22:54:22 +00:00
1. Educational purposes (learning how to write Dockerfiles; how Docker works, etc)
2. Bandwidth reduction / speed: basing them on my custom base image that proxies apt through a local [apt-cacher-ng](https://wiki.debian.org/AptCacherNg) instance
3. Security: I know precisely how the Dockerfile works and everything it depends on, because I've written it myself
4. Compatibility:
2021-04-03 19:10:33 +00:00
- I use [Hashicorp Nomad](https://www.nomadproject.io/), so some of these Dockerfiles are written explicitly with Hashicorp Nomad in mind - e.g. the [`NOMAD_PORT_*` environment variables](https://www.nomadproject.io/docs/job-specification/network#port-parameters).
- My Hashicorp Nomad cluster is comprised chiefly of Raspberry Pis (currently running armv7l, but an upgrade to arm64 is planned eventually), and many Docker containers on the Docker Hub are built by default for amd64
5. Maintainability: I want to ensure I keep my Docker images up-to-date, so I rebuild them myself regularly via my [Continuous Integration server](https://laminar.ohwg.net/) ([see also](https://starbeamrainbowlabs.com/blog/article.php?article=posts/392-own-your-code-series-list.html), and [also this](https://starbeamrainbowlabs.com/blog/article.php?article=posts/451-cluster-11-lock-and-key.html))
2021-03-26 22:54:22 +00:00
### Why do I need to run a private Docker registry for `imagebuilder.sh` to work?
`imagebuilder.sh` is designed to automatically build the specified Docker image and then push it to a private Docker registry because then the hosts in my Hashicorp Nomad
2020-10-22 00:46:57 +00:00
2021-04-03 19:10:33 +00:00
### These Dockerfiles don't work for me!
These Dockerfiles are specific to my environment. They depend on a patched version of `minideb` as a base image, which this package is also responsible for building. The key changes to `minideb` include:
1. Config directive to tell `apt` to use my local apt-cacher-ng instance to save bandwidth / speed things up
2. Apt repository definition for [my personal apt repository](https://apt.starbeamrainbowlabs.com/).
To set your own apt caching proxy address, do this before calling `imagebuilder.sh build minideb`:
```bash
export proxy_address="http://example.com:3142";
```
Note that an apt caching proxy is *required* for it to work. If you don't yet have one setup, I have a blog post about it here: [Cluster, Part 5: Staying current | Automating apt updates and using apt-cacher-ng](https://starbeamrainbowlabs.com/blog/article.php?article=posts/411-cluster-5-staying-current.html)
2021-03-26 22:54:22 +00:00
### I've found a security issue, how can I contact you?
Please use the contact details on my website and _privately_ get in touch (don't leave a public comment on my blog): <https://starbeamrainbowlabs.com/>
## Image Catalogue
2020-11-29 00:16:47 +00:00
2021-03-07 14:43:46 +00:00
Image | Purpose
--------------------|----------------
2021-04-10 15:04:52 +00:00
`certbot` | Dockerised certbot via certbot-auto - currently doesn't build anymore because "certbot doesn't support your OS anymore" or something like that, but the version pushed to our private registry works just fine until we can rectify the issue
2020-10-22 00:46:57 +00:00
`docker-registry-ui`| [docker registry ui](https://github.com/Joxit/docker-registry-ui), dockerised
2021-03-26 22:54:22 +00:00
`etherpad` | Dockerised [etherpad](https://etherpad.org/) (currently faulty, see [this GitHub issue](https://github.com/ether/etherpad-lite/issues/4962))
2021-04-10 15:04:52 +00:00
`gossa` | Dockerised [gossa](https://github.com/pldubouilh/gossa/)
2020-10-22 00:46:57 +00:00
`jellyfin` | Dockerised [jellyfin](https://jellyfin.org/)
2021-04-10 15:04:52 +00:00
`minetest` | Dockerised server for [minetest](https://github.com/minetest/minetest),, currently under construction
2021-03-26 22:54:22 +00:00
`minetest-mapserver`| Dockerised [minetest-mapserver](https://github.com/minetest-mapserver/mapserver)
`minideb` | Our main base image for (most) other images. Built from [minideb](https://github.com/bitnami/minideb), but customised to use our local apt-cacher-ng instance.
2021-04-10 15:04:52 +00:00
`minideb-node` | `minideb` with the latest Node.js installed via our [apt repository](https://apt.starbeamrainbowlabs.com/)
`mosquitto` | Dockerised Mosquitto MQTT server
`node-serve` | `minideb-node` with [serve](https://www.npmjs.com/package/serve) installed & set as the entrypoint
`paperless-ng` | Dockerised [paperless-ng](https://github.com/jonaswinkler/paperless-ng) - currently under construction
`redis` | Dockerised [redis](https://redis.io/), installs the latest stable version
`shiori` | Dockerised [shiori](https://github.com/go-shiori/shiori), built from source
2021-05-26 21:00:54 +00:00
`imap-download` | Fetchmail, procmail, inotifywait, and munpack working together to download emails and extract attachments. The provided fetchmailrc must be owned by `10000:10000`.
2021-06-27 11:30:32 +00:00
`archivebox` | Dockerised [ArchiveBox](https://archivebox.io/)
2021-12-14 22:52:15 +00:00
`tinyproxy` | Dockerised [tinyproxy](https://tinyproxy.github.io/) - config file should be mounted read-only to `/srv/tinyproxy.conf`
2021-06-27 11:30:32 +00:00
2020-10-21 23:23:15 +00:00
2020-09-26 13:56:36 +00:00
## Docker container UID/GID map
UID | GID | Container | Notes
--------|-------|-----------------------|-----------------
2020-09-26 13:59:25 +00:00
3 | 3 | docker-registry-ui |
60 | 60 | minetest-mapserver |
2020-09-26 13:56:36 +00:00
70 | 70 | etherpad |
2020-10-04 11:28:49 +00:00
80 | 80 | serve | Static HTTP Server based on Node.js
2021-04-10 15:04:52 +00:00
85 | 85 | mosquitto |
2020-10-17 16:49:20 +00:00
90 | 90 | jellyfin |
2021-04-10 15:04:52 +00:00
95 | 95 | shiori | Shiori bookmark system, built from source
2021-06-27 11:30:32 +00:00
999 | 994 | certbot | The same user & group as fabio, because file permissions
2100 | 2100 | redis |
0 | 0 | imap-download | Uses fetchmail to download emails and extract attachments. The provided fetchmailrc must be owned by `10000:10000`, and be chmodded to `0700`.
10200 | 10200 | archivebox |
2021-12-14 22:52:15 +00:00
10300 | 10300 | tinyproxy |
2021-03-26 22:54:22 +00:00
## Development Notes
At present, 3 image types are present:
- **`base`:** A base image - a script is called with an auto-generated output directory as the 1st and only argument. When the script exits the directory is checked for a `.tar.gz` file
- **`base-nopush`:** A variant of the above that doesn't automatically push to the docker registry on completion.
2021-03-26 22:54:22 +00:00
- **`docker`:** A `Dockerfile` is is built with `docker build` before being pushed to the docker registry.
- **`import`:** Imports a Docker image from another Docker registry.
2021-03-26 22:54:22 +00:00
### Creating a new image
Each image should have it's own subdirectory inside the `image` directory. The following files should be present for a `docker` image type:
- `type.txt`: Should contain the word `docker`
- `Dockerfile`: The Dockerfile to build
Any other files are given to Docker as [build context](https://stackoverflow.com/a/44466648/1460422).
For `base` and `base-nopush` image types, the following files should be present:
- `IMAGE_NAME.sh`: A `.sh` file named after the name of the parent directory. For example, the `minideb` image contains the script `minideb.sh`
- `type.txt`: Should contain either the word `base` or `base-nopush`
For `import` image types, the file `imagetype.txt` should be present and contain the (fully qualified) name of the image to import.
2021-03-26 22:54:22 +00:00
Optionally, any image type can contain the following files:
- `dependents.txt`: The names of images that depend on this image - 1 image name per file. This is read by my continuous integration system to queue rebuilds of dependent Docker containers once the current image has finished building & pushing automatically.
2021-03-26 22:55:32 +00:00
2021-03-26 22:55:40 +00:00
## Licence
The contents of this repository is licenced under the _Mozilla Public License 2.0_ (MPL-2.0). This license can be found in the _LICENSE_ file in this repository.