aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--.travis.yml60
-rw-r--r--Makefile37
-rw-r--r--README.md46
3 files changed, 86 insertions, 57 deletions
diff --git a/.travis.yml b/.travis.yml
index 4cfdeb1..3259496 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,28 +1,3 @@
-# I used a guide to set up multiarch builds [1].
-# I don't understand it completely at the moment, but whatever.
-
-# The goal is to have a single multiarch repo on Docker Hub for each of the
-# services.
-# The approach is to use Docker's new BuildKit builder + the buildx command
-# line plugin.
-#
-# Other possibilities are:
-# * use QEMU + multiarch base images directly [2][3], and create a manifest
-# file manually,
-# * build natively on multiple architectures (not sure how to combine them in
-# a single manifest then though).
-#
-# The disadvantages of the approach taken are:
-# * newer Docker version is required,
-# * docker-compose doesn't seem to support that method natively.
-#
-# [1]: https://mirailabs.io/blog/multiarch-docker-with-buildx/
-# [2]: https://lobradov.github.io/Building-docker-multiarch-images/
-# [3]: https://ownyourbits.com/2018/06/27/running-and-building-arm-docker-containers-in-x86/
-
-# TODO: Docker Hub automated builds instead of Travis?
-# TODO: docker-compose instead of docker buildx?
-
language: minimal
os: linux
dist: bionic
@@ -33,26 +8,29 @@ services:
addons:
apt:
update: true
- # Newer docker for buildx support:
+ # Newer docker for BuildKit/buildx support:
sources:
- key_url: 'https://download.docker.com/linux/ubuntu/gpg'
sourceline: 'deb https://download.docker.com/linux/ubuntu "$(lsb_release -cs)" stable'
packages:
- docker-ce
-env:
- # Enable experimental buildx support
- DOCKER_CLI_EXPERIMENTAL: enabled
- platforms: linux/i386,linux/amd64,linux/armhf
+install:
+ # GCR & BuildKit don't work together, e.g.:
+ # https://github.com/moby/buildkit/issues/606
+ - echo '{}' | sudo tee /etc/docker/daemon.json
+ - sudo systemctl restart docker
-script:
- - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
- - docker buildx create --use
- - docker buildx build --platform "$platforms" dump1090/
- - docker buildx build --platform "$platforms" fr24feed/
- - |-
- if [ "$TRAVIS_BRANCH" = master ]; then
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker buildx build --platform "$platforms" -t "$DOCKER_USERNAME/dump1090" --push dump1090/
- docker buildx build --platform "$platforms" -t "$DOCKER_USERNAME/fr24feed" --push fr24feed/
- fi
+jobs:
+ include:
+ - name: Build and publish multi-arch images
+ script: |-
+ if [ "$TRAVIS_BRANCH" = master ]; then
+ make login && make builder/create && make push
+ else
+ make builder/create && make build
+ fi
+ - name: Build native images using Compose
+ script: sudo make install-compose && make compose-build
+ - name: Build native images using Docker
+ script: make docker-build
diff --git a/Makefile b/Makefile
index d8a82e4..e5e52ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+PROJECT = fr24feed
# Use BuildKit, which is required:
export DOCKER_BUILDKIT = 1
# Enable buildx support:
@@ -6,7 +7,7 @@ export DOCKER_CLI_EXPERIMENTAL = enabled
export COMPOSE_DOCKER_CLI_BUILD = 1
# Target platforms (used by buildx):
platforms = linux/i386,linux/amd64,linux/armhf
-# One of the latest (at the moment Compose versions) that supports BuildKit:
+# One of the latest (at the moment) Compose versions that supports BuildKit:
compose_version = 1.25.3
# Docker Hub credentials:
DOCKER_USERNAME = egortensin
@@ -26,19 +27,31 @@ install-compose:
compose: install-compose
-# Three kinds of builds:
-# * docker build (for testing only),
-# * docker-compose build (for testing only, Compose doesn't support buildx
-# yet),
-# * docker buildx (the right way for multiarch repos).
+# Re-register binfmt_misc formats with the F flag (required i.e. on Bionic):
+fix-binfmt:
+ docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
+
+binfmt: fix-binfmt
+
+# `docker build` has week support for multiarch repos (you need to use multiple
+# Dockerfile's, create a manifest manually, etc.), so it's only here for
+# testing purposes, and native builds.
docker-build/%:
docker build -t "$(DOCKER_USERNAME)/$*" "$*/"
docker-build: docker-build/dump1090 docker-build/fr24feed
+# `docker-compose build` has the same problems as `docker build`.
compose-build:
docker-compose build
+# The simple way to build multiarch repos.
+builder/create: fix-binfmt
+ docker buildx create --use --name "$(PROJECT)_builder"
+
+builder/rm:
+ docker buildx rm "$(PROJECT)_builder"
+
buildx/%:
docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" "$*/"
@@ -47,19 +60,19 @@ buildx: buildx/dump1090 buildx/fr24feed
# buildx is used by default.
build: buildx
-# Three kinds of pushes:
-# * docker push (for testing only),
-# * docker-compose push (for testing only, Compose doesn't support buildx and
-# multiarch repos yet),
-# * docker buildx --push (the right way for multiarch repos).
+# `docker push` would replace the multiarch repo with a single image by default
+# (you'd have to create a manifest and push it instead), so it's only here for
+# testing purposes.
docker-push/%: docker-build/%
docker push "$(DOCKER_USERNAME)/$*"
docker-push: docker-push/dump1090 docker-push/fr24feed
+# `docker-compose push` has the same problems as `docker push`.
compose-push: compose-build
docker-compose push
+# The simple way to push multiarch repos.
buildx-push/%:
docker buildx build -t "$(DOCKER_USERNAME)/$*" --platform "$(platforms)" --push "$*/"
@@ -80,4 +93,4 @@ pull:
clean:
docker system prune --all --force --volumes
-.PHONY: all login install-compose compose docker-build compose-build buildx build docker-push compose-push buildx-push push up down pull clean
+.PHONY: all login install-compose compose fix-binfmt binfmt docker-build compose-build builder/create builder/rm buildx build docker-push compose-push buildx-push push up down pull clean
diff --git a/README.md b/README.md
index 831ebde..72c4d5a 100644
--- a/README.md
+++ b/README.md
@@ -32,18 +32,56 @@ the receiver in dump1090-fa's arguments (`--lat` and `--lon`).
Start the containers using
- docker-compose pull && docker-compose up -d
+ make pull && make up
You can now access the interactive map at http://0.0.0.0:8080/dump1090-fa/ and
the fr24feed web interface at http://0.0.0.0:8754/.
Stop the containers using
- docker-compose down -v
+ make down
Development
-----------
-Build the images using
+TL;DR: build the native images using
- docker-compose build --force-rm
+ make compose-build
+
+Or, if you have Compose version 1.24.x or below,
+
+ make docker-build
+
+### Dependencies
+
+* Docker with BuildKit support (18.09 or higher),
+* Compose with BuildKit support for `compose-build` (1.25.0 or higher).
+
+### CI
+
+I used a guide to set up multiarch builds ([1][1]).
+I don't understand it completely at the moment, but whatever.
+
+The goal is to have a single multiarch repo on Docker Hub for each of the
+services.
+The approach is to use Docker's new BuildKit builder + the buildx command line
+plugin.
+
+Other possibilities are:
+* use QEMU + multiarch base images directly ([2][2], [3][3]), and create a manifest file
+manually,
+* build natively on multiple architectures (not sure how to combine them in a
+single manifest then though).
+
+The disadvantages of the approach taken are:
+* newer Docker version is required,
+* docker-compose doesn't seem to support that method natively.
+
+[1]: https://mirailabs.io/blog/multiarch-docker-with-buildx/
+[2]: https://lobradov.github.io/Building-docker-multiarch-images/
+[3]: https://ownyourbits.com/2018/06/27/running-and-building-arm-docker-containers-in-x86/
+
+### TODO
+
+* Docker Hub automated builds instead of Travis?
+* docker-compose instead of docker buildx?