mirror of
https://github.com/nicolabs/nicobot.git
synced 2025-09-05 06:33:25 +02:00
~ doc update about docker taggging
~ tags' name construction is now inverted to reflect the convention (i.e. 'debian-signal' becomes 'signal-debian') + trying to fix the build failing because it's out of space by moving docker from /var/lib to /mnt
This commit is contained in:
parent
138984e71d
commit
f23848b084
28
.github/workflows/dockerhub.yml
vendored
28
.github/workflows/dockerhub.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
|||
pip install -r requirements-build.txt
|
||||
# Stores a variable for each variant
|
||||
echo DEBIAN_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo DEBIAN_SIGNAL_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian-signal --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo DEBIAN_SIGNAL_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant signal-debian --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo ALPINE_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant alpine --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
# Also stores the computed version
|
||||
echo NICOBOT_VERSION=$(python3 setup.py --version) >> $GITHUB_ENV
|
||||
|
@ -53,11 +53,21 @@ jobs:
|
|||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Patch Docker Daemon data-root
|
||||
run: |
|
||||
DOCKER_DATA_ROOT='/mnt/var/lib/docker'
|
||||
DOCKER_DAEMON_JSON='/etc/docker/daemon.json'
|
||||
sudo mkdir -p "${DOCKER_DATA_ROOT}"
|
||||
jq --arg dataroot "${DOCKER_DATA_ROOT}" '. + {"data-root": $dataroot}' "${DOCKER_DAEMON_JSON}" > "/tmp/docker.json.tmp"
|
||||
sudo mv "/tmp/docker.json.tmp" "${DOCKER_DAEMON_JSON}"
|
||||
sudo systemctl restart docker
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-alpine-${{ github.sha }}
|
||||
# See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-alpine-
|
||||
${{ runner.os }}-buildx-
|
||||
|
@ -114,7 +124,7 @@ jobs:
|
|||
pip install -r requirements-build.txt
|
||||
# Stores a variable for each variant
|
||||
echo DEBIAN_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo DEBIAN_SIGNAL_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant debian-signal --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo DEBIAN_SIGNAL_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant signal-debian --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
echo ALPINE_TAGS=$(python3 setup.py -q docker_tags --image nicolabs/nicobot --variant alpine --ref ${{ github.ref }} --sep ,) >> $GITHUB_ENV
|
||||
# Also stores the computed version
|
||||
echo NICOBOT_VERSION=$(python3 setup.py --version) >> $GITHUB_ENV
|
||||
|
@ -129,11 +139,21 @@ jobs:
|
|||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Patch Docker Daemon data-root
|
||||
run: |
|
||||
DOCKER_DATA_ROOT='/mnt/var/lib/docker'
|
||||
DOCKER_DAEMON_JSON='/etc/docker/daemon.json'
|
||||
sudo mkdir -p "${DOCKER_DATA_ROOT}"
|
||||
jq --arg dataroot "${DOCKER_DATA_ROOT}" '. + {"data-root": $dataroot}' "${DOCKER_DAEMON_JSON}" > "/tmp/docker.json.tmp"
|
||||
sudo mv "/tmp/docker.json.tmp" "${DOCKER_DAEMON_JSON}"
|
||||
sudo systemctl restart docker
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-debian-${{ github.sha }}
|
||||
# See https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-debian-
|
||||
${{ runner.os }}-buildx-
|
||||
|
@ -164,12 +184,12 @@ jobs:
|
|||
- name: Image digest
|
||||
run: echo ${{ steps.docker_build_debian.outputs.digest }}
|
||||
|
||||
- name: Build and push debian-signal
|
||||
- name: Build and push signal-debian
|
||||
id: docker_build_debian_signal
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: ./
|
||||
file: ./debian-signal.Dockerfile
|
||||
file: ./signal-debian.Dockerfile
|
||||
builder: ${{ steps.buildx.outputs.name }}
|
||||
platforms: linux/arm/v7,linux/arm64,linux/386,linux/amd64
|
||||
push: true
|
||||
|
|
19
Develop.md
19
Develop.md
|
@ -2,7 +2,7 @@
|
|||
|
||||
[![Build Status on 'master' branch][travisci-shield]][travisci-link] [![PyPi][pypi-shield]][pypi-link]
|
||||
[![Build and publish to Docker Hub][dockerhub-shield]][dockerhub-link]
|
||||
[![Docker debian][docker-debian-size] ![Docker debian-signal][docker-debian-signal-size] ![Docker alpine][docker-alpine-size]](https://hub.docker.com/r/nicolabs/nicobot/tags)
|
||||
[![Docker debian][docker-debian-size] ![Docker signal-debian][docker-signal-debian-size] ![Docker alpine][docker-alpine-size]](https://hub.docker.com/r/nicolabs/nicobot/tags)
|
||||
|
||||
|
||||
|
||||
|
@ -89,12 +89,12 @@ They all have [multiple stages](https://docs.docker.com/develop/develop-images/m
|
|||
|
||||
`debian.Dockerfile` is quite straight. It builds using *pip* in one stage and copies the resulting *wheels* into the final one.
|
||||
|
||||
`debian-signal.Dockerfile` is more complex because it needs to address :
|
||||
`signal-debian.Dockerfile` is more complex because it needs to address :
|
||||
- including both Python and Java while keeping the image size small
|
||||
- compiling native dependencies (both for _signal-cli_ and _qr_)
|
||||
- circumventing a number of bugs in multiarch building
|
||||
|
||||
`debian-alpine.Dockerfile` produces smaller images but may not be as much portable than debian ones and misses Signal support for now.
|
||||
`alpine.Dockerfile` produces smaller images but may not be as much portable than debian ones and misses Signal support for now.
|
||||
|
||||
Note that the _signal-cli_ backend needs a _Java_ runtime environment, and also _rust_ dependencies to support Signal's group V2. This approximately doubles the size of the images and almost ruins the advantage of alpine over debian...
|
||||
|
||||
|
@ -130,13 +130,20 @@ Then run with the provided sample configuration :
|
|||
_Github actions_ are currently used (see [`.github/workflows/dockerhub.yml`](.github/workflows/dockerhub.yml) to automatically build and push the images to [Docker Hub](https://hub.docker.com/r/nicolabs/nicobot) so they are available whenever commits are pushed to the _master_ branch :
|
||||
|
||||
1. A *Github Action* is triggered on each push to [the central repo](https://github.com/nicolabs/nicobot)
|
||||
2. All images are built in order using caching (see [.github/workflows/dockerhub.yml](.github/workflows/dockerhub.yml))
|
||||
2. Alpine images and Debian images are built in parallel to speed up things. Debian-signal is built after Debian. Caching is used for both. See [.github/workflows/dockerhub.yml](.github/workflows/dockerhub.yml).
|
||||
3. Images are uploaded to [Docker Hub](https://hub.docker.com/repository/docker/nicolabs/nicobot)
|
||||
|
||||
#### Tagging strategy
|
||||
|
||||
Since I could not find an easy way to generate exactly the tags I wanted, the `setup.py` script embeds a custom command to generate them from the git context (tag, commit) and the image variant :
|
||||
|
||||
- [docker/github-actions](https://github.com/docker/github-actions) tagging strategy does not explicitely allows to tag with *latest* an image of choice (I may be able to force it by tagging the wanted image in the end but it does not look 100% sure)
|
||||
- [crazy-max/ghaction-docker-meta](https://github.com/crazy-max/ghaction-docker-meta) is quite complex to understand and I could not figure out a way to implement my strategy
|
||||
- See [setup.py#DockerTagsCommand](setup.py#DockerTagsCommand) for the custom solution
|
||||
|
||||
### Docker build process overview
|
||||
|
||||
This is the view from the **master** branch on this repository.
|
||||
This diagram is the view from the **master** branch on this repository.
|
||||
It emphasizes *FROM* and *COPY* relations between the images (base and stages).
|
||||
|
||||

|
||||
|
@ -274,6 +281,6 @@ This led to build separate images (same _repo_ but different _tags_), to allow u
|
|||
[pypi-link]: https://pypi.org/project/nicobot
|
||||
[dockerhub-shield]: https://github.com/nicolabs/nicobot/workflows/Docker%20Hub/badge.svg
|
||||
[dockerhub-link]: https://hub.docker.com/r/nicolabs/nicobot
|
||||
[docker-debian-signal-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/debian-signal.svg?label=debian-signal
|
||||
[docker-signal-debian-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/signal-debian.svg?label=signal-debian
|
||||
[docker-debian-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/debian.svg?label=debian
|
||||
[docker-alpine-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/alpine.svg?label=alpine
|
||||
|
|
20
README.md
20
README.md
|
@ -7,7 +7,7 @@ Python package :
|
|||
Docker images :
|
||||
|
||||
[![Build and publish to Docker Hub][dockerhub-shield]][dockerhub-link]
|
||||
[![Docker debian][docker-debian-size] ![Docker debian-signal][docker-debian-signal-size] ![Docker alpine][docker-alpine-size]](https://hub.docker.com/r/nicolabs/nicobot/tags)
|
||||
[![Docker debian][docker-debian-size] ![Docker signal-debian][docker-signal-debian-size] ![Docker alpine][docker-alpine-size]](https://hub.docker.com/r/nicolabs/nicobot/tags)
|
||||
|
||||
|
||||
|
||||
|
@ -90,11 +90,19 @@ Now you can run the bots by their name as if they were installed via the package
|
|||
|
||||
At the present time there are [several Docker images available](https://hub.docker.com/r/nicolabs/nicobot/tags), with the following tags :
|
||||
|
||||
- **debian** : this is the most portable image ; in order to keep it relatively small it does not include the *Signal* backend (will throw an error if you try --> use XMPP instead)
|
||||
- **debian-signal** : this is the most complete image ; it is also the largest one, but allows *Signal* messaging
|
||||
- **alpine** : this should be the smallest image, but it's more complex to maintain and therefore might not always meet this expectation. Also, due to the lack/complexity of Alpine support for some Python, Java & native dependencies, images may support less platforms and it currently doesn't provide the Signal backend (you can use XMPP instead).
|
||||
- **debian** (or **vX.Y.Z-debian**) : this is the most portable image ; in order to keep it relatively small it does not include the *Signal* backend (will throw an error if you try --> use XMPP instead)
|
||||
|
||||
Please have a look at the status pills at the top of this document to get more details like status and size.
|
||||
- **signal-debian** (or **vX.Y.Z-signal-debian**) : this is the most complete image ; it is also the largest one, but allows *Signal* messaging
|
||||
|
||||
- **alpine** (or **vX.Y.Z-alpine**) : this should be the smallest image, but it's more complex to maintain and therefore might not always meet this expectation. Also, due to the lack/complexity of Alpine support for some Python, Java & native dependencies, images may support less platforms and it currently doesn't provide the Signal backend (you can use XMPP instead).
|
||||
|
||||
- **vX.Y.Z-\<image variant\>** tags are simply version *vX.Y.Z* of *\<image variant\>*. E.g. *v1.2.3-alpine* is nicobot version 1.2.3 in the *alpine* variant (not related with alpine's version).
|
||||
|
||||
- **latest** points to the latest versioned image of *signal-debian* (which offers all features).
|
||||
|
||||
- **dev-\<image variant\>** tags are development versions of the master branch. **Do not use : they are probably broken !** History is currently not preserved : there is only one *dev-* tag of an image variant at a time.
|
||||
|
||||
Please have a look at the status shields at the top of this document to get more details like status and size.
|
||||
|
||||
> **ADVICE**
|
||||
> The current state of those images is such that I suggest you try the **alpine** image first and switch to a **debian\*** one if you need Signal or encounter runtime issues.
|
||||
|
@ -412,6 +420,6 @@ Example :
|
|||
[pypi-link]: https://pypi.org/project/nicobot
|
||||
[dockerhub-shield]: https://github.com/nicolabs/nicobot/workflows/Docker%20Hub/badge.svg
|
||||
[dockerhub-link]: https://hub.docker.com/r/nicolabs/nicobot
|
||||
[docker-debian-signal-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/debian-signal.svg?label=debian-signal
|
||||
[docker-signal-debian-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/signal-debian.svg?label=signal-debian
|
||||
[docker-debian-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/debian.svg?label=debian
|
||||
[docker-alpine-size]: https://img.shields.io/docker/image-size/nicolabs/nicobot/alpine.svg?label=alpine
|
||||
|
|
|
@ -32,7 +32,7 @@ docker_context ...> nicobot_debian : COPY
|
|||
|
||||
|
||||
''''''''''''''''''''''''
|
||||
' debian-signal.Dockerfile
|
||||
' signal-debian.Dockerfile
|
||||
''''''''''''''''''''''''
|
||||
|
||||
object "<i>rust:1.49-buster</i>" as rust $baseimage
|
||||
|
@ -43,7 +43,7 @@ object "rust fix" as nicobot_rust_fix <<temp>> $tempimage {
|
|||
object "signal-cli builder" as nicobot_signal_builder <<temp>> $tempimage {
|
||||
Builds signal-cli & libzkgroup
|
||||
}
|
||||
object "nicolabs/nicobot:debian-signal" as nicobot_debian_signal $finalimage {
|
||||
object "nicolabs/nicobot:signal-debian" as nicobot_debian_signal $finalimage {
|
||||
Installs signal-cli & dependencies
|
||||
}
|
||||
|
||||
|
|
12
setup.py
12
setup.py
|
@ -19,14 +19,14 @@ def local_scheme(version):
|
|||
with the setup script.
|
||||
|
||||
See https://dankeder.com/posts/adding-custom-commands-to-setup-py/
|
||||
What variables are available from Githu Actions : https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
|
||||
What variables are available from Github Actions : https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context
|
||||
"""
|
||||
class DockerTagsCommand(setuptools.Command):
|
||||
|
||||
description = "Prints a tag list for the given 'base tag'"
|
||||
user_options = [
|
||||
('image=', 'i', 'Image name (defaults to nicolabs/nicobot)'),
|
||||
('variant=', 'v', 'Image variant / base tag : debian|debian-signal|alpine'),
|
||||
('variant=', 'v', 'Image variant / base tag : debian|signal-debian|alpine'),
|
||||
('branch=', 'b', 'The git ref as <branch name> or refs/heads/<branch name>'),
|
||||
('tag=', 't', 'The git ref as <tag name> or refs/tags/<tag name>'),
|
||||
('ref=', 'r', 'The git ref as refs/tags|heads/<tag or branch name>'),
|
||||
|
@ -72,13 +72,13 @@ class DockerTagsCommand(setuptools.Command):
|
|||
# When git-tagged, the variant name alone means : the 'latest' for this variant
|
||||
tags = [ "%s:%s" % (self.image,self.variant) ]
|
||||
# It is also tagged with the version
|
||||
tags = tags + [ "%s:%s-%s" % (self.image,self.variant,self.tag) ]
|
||||
# Only debian-signal is tagged with 'latest' additionaly
|
||||
if self.variant == "debian-signal":
|
||||
tags = tags + [ "%s:%s-%s" % (self.image,self.tag,self.variant) ]
|
||||
# Only signal-debian is explicitely tagged with 'latest', additionaly
|
||||
if self.variant == "signal-debian":
|
||||
tags = tags + [ "%s:latest" % (self.image) ]
|
||||
elif self.branch:
|
||||
# All non git-tagged commits overwrite the 'dev' tag (only one is useful currently)
|
||||
tags = tags + [ "%s:%s-dev" % (self.image,self.variant) ]
|
||||
tags = tags + [ "%s:dev-%s" % (self.image,self.variant) ]
|
||||
print( self.sep.join(tags) )
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue