From 572a852e09068d3b76bbcb8f5748c952527be82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sat, 30 Mar 2019 01:37:40 -0400 Subject: [PATCH 01/16] script to build arm images --- CHANGELOG.md.20190330 | 1 + tests/build_arm.sh | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 CHANGELOG.md.20190330 create mode 100755 tests/build_arm.sh diff --git a/CHANGELOG.md.20190330 b/CHANGELOG.md.20190330 new file mode 100644 index 00000000..d577cf2b --- /dev/null +++ b/CHANGELOG.md.20190330 @@ -0,0 +1 @@ +find . -iname 'dockerfile' -exec sed -i "s/FROM.*/ARG DISTRO=alpine:3.8\nFROM \$DISTRO/" '{}' \; diff --git a/tests/build_arm.sh b/tests/build_arm.sh new file mode 100755 index 00000000..3f85955f --- /dev/null +++ b/tests/build_arm.sh @@ -0,0 +1,4 @@ +#!/bin/bash -x + +export DISTRO="hypriot/rpi-alpine" +docker-compose -f build.yml build --build-arg DISTRO=$DISTRO # --parallel From 120b07c572897c0758d8c30df8c646a9658b48ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 00:20:01 -0400 Subject: [PATCH 02/16] use different alpine image for arm, add config for php images+arm --- .gitignore | 1 + tests/build_arm.sh | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 352989fc..8734dcdb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ pip-selfcheck.json /docker-compose.yml /.idea /.vscode +qemu-arm-static diff --git a/tests/build_arm.sh b/tests/build_arm.sh index 3f85955f..f93c4f6b 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -1,4 +1,9 @@ #!/bin/bash -x -export DISTRO="hypriot/rpi-alpine" -docker-compose -f build.yml build --build-arg DISTRO=$DISTRO # --parallel +DISTRO="balenalib/rpi-alpine" +PHP="arm32v7/php:7.2-apache" +QEMU="$(which qemu-arm-static)" +cp $QEMU ../webmails/rainloop/ +cp $QEMU ../webmails/roundcube/ + +docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP # --parallel From a053f908751085755856f99f52c6c8bb0e70b38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 00:56:42 -0400 Subject: [PATCH 03/16] docs: user ARG to chose image, install python3 before running pip3 --- docs/Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/Dockerfile b/docs/Dockerfile index c2661262..b3257a80 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -1,12 +1,13 @@ -FROM python:3-alpine +ARG DISTRO=alpine:3.8 +FROM $DISTRO COPY requirements.txt /requirements.txt ARG version=master ENV VERSION=$version -RUN pip install -r /requirements.txt \ - && apk add --no-cache nginx curl \ +RUN apk add --no-cache nginx curl python3 \ + && pip3 install -r /requirements.txt \ && mkdir /run/nginx COPY ./nginx.conf /etc/nginx/conf.d/default.conf From 3a108658247c59bd9f40a6f0d6eb7229ce535403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 01:06:42 -0400 Subject: [PATCH 04/16] install python for setup image, accept args for build_arm script --- setup/Dockerfile | 7 ++++--- tests/build_arm.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/Dockerfile b/setup/Dockerfile index 7c4ba773..101fc36a 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -1,11 +1,12 @@ -FROM python:3-alpine +ARG DISTRO=alpine:3.8 +FROM $DISTRO RUN mkdir -p /app WORKDIR /app COPY requirements.txt requirements.txt -RUN apk add --no-cache curl \ - && pip install -r requirements.txt +RUN apk add --no-cache curl python3 py3-pip +RUN pip3 install -r requirements.txt COPY server.py ./server.py COPY main.py ./main.py diff --git a/tests/build_arm.sh b/tests/build_arm.sh index f93c4f6b..c382095b 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -6,4 +6,4 @@ QEMU="$(which qemu-arm-static)" cp $QEMU ../webmails/rainloop/ cp $QEMU ../webmails/roundcube/ -docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP # --parallel +docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP $@ # --parallel From c0f4126a6c9519039f5a381c04993b80c67ce0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 09:17:11 -0400 Subject: [PATCH 05/16] use 3.8 for arm too --- tests/build_arm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/build_arm.sh b/tests/build_arm.sh index c382095b..3f188bde 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -1,9 +1,9 @@ #!/bin/bash -x -DISTRO="balenalib/rpi-alpine" +DISTRO="balenalib/rpi-alpine:3.8" PHP="arm32v7/php:7.2-apache" QEMU="$(which qemu-arm-static)" cp $QEMU ../webmails/rainloop/ cp $QEMU ../webmails/roundcube/ -docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP $@ # --parallel +docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP --parallel $@ From b711ef82da9f154448ea1622d2d1b7aa3f619020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 15:52:43 -0400 Subject: [PATCH 06/16] use edge for radicale --- tests/build_arm.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/build_arm.sh b/tests/build_arm.sh index 3f188bde..41b338d0 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -1,9 +1,11 @@ #!/bin/bash -x -DISTRO="balenalib/rpi-alpine:3.8" +ALPINE_VER="3.8" +DISTRO="balenalib/rpi-alpine:$ALPINE_VER" +EDGE_DISTRO="balenalib/rpi-alpine:edge" PHP="arm32v7/php:7.2-apache" QEMU="$(which qemu-arm-static)" cp $QEMU ../webmails/rainloop/ cp $QEMU ../webmails/roundcube/ -docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP --parallel $@ +docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP --build-arg EDGE_DISTRO=$EDGE_DISTRO --parallel $@ From 199b74a1449ff6e5a549e2b5e51ce51bd8c69ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Sun, 31 Mar 2019 23:47:39 -0400 Subject: [PATCH 07/16] update comments, add helper script to push local build to rpi --- tests/build_arm.sh | 6 ++++++ tests/deploy_to_pi.sh | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100755 tests/deploy_to_pi.sh diff --git a/tests/build_arm.sh b/tests/build_arm.sh index 41b338d0..280de51f 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -2,10 +2,16 @@ ALPINE_VER="3.8" DISTRO="balenalib/rpi-alpine:$ALPINE_VER" +# Used for Radicale EDGE_DISTRO="balenalib/rpi-alpine:edge" +# Used for webmails PHP="arm32v7/php:7.2-apache" + +# NOTE: Might not be needed since using multiarch/qemu QEMU="$(which qemu-arm-static)" cp $QEMU ../webmails/rainloop/ cp $QEMU ../webmails/roundcube/ +# use qemu-*-static from docker container +docker run --rm --privileged multiarch/qemu-user-static:register docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP --build-arg EDGE_DISTRO=$EDGE_DISTRO --parallel $@ diff --git a/tests/deploy_to_pi.sh b/tests/deploy_to_pi.sh new file mode 100755 index 00000000..dab5a53f --- /dev/null +++ b/tests/deploy_to_pi.sh @@ -0,0 +1,6 @@ +#!/bin/bash -x +# Small script to deploy locally built images to a remote docker +compose_options=$1 +images=$(docker-compose $1 images | awk 'NR > 2 { printf $2":"$3" " }') +docker save $images | pigz - > mail.local.tgz +echo "now run 'docker -H \"ssh://user@host\" load -i mail.local.tgz" From 42e520843e06f31bfcb1c4f9f13c07694fb78e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Mon, 1 Apr 2019 00:02:19 -0400 Subject: [PATCH 08/16] update docs --- docs/rpi_build.rst | 19 +++++++++++++++++++ docs/setup.rst | 5 +---- 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 docs/rpi_build.rst diff --git a/docs/rpi_build.rst b/docs/rpi_build.rst new file mode 100644 index 00000000..c3324cdc --- /dev/null +++ b/docs/rpi_build.rst @@ -0,0 +1,19 @@ +.. _rpi_build: + +Building for a Raspberry Pi +=========================== + +The build does not need to be done on the Pi. + +To do so, go to ``tests/`` and call ``./build_arm.sh``, it will build all necessary images for arm. + +To push the locally built images to a remote server, run ``./deploy_to_pi.sh``. Docker 18.09+ is needed to use ``-H ssh://@``. + +Adjustments +----------- + +``build_arm.sh`` uses some variables passed as ``build-arg`` to docker-compose: + +- ``DISTRO``: is the main distro used (ie: alpine:3.8) +- ``PHP_DISTRO``: is used for the ``rainloop`` and ``roundcube`` images +- ``EDGE_DISTRO``: is used for ``radicale`` as edge has dulwich and radicale as packages diff --git a/docs/setup.rst b/docs/setup.rst index df387c51..72a49ee3 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -19,9 +19,7 @@ Prepare the environment Mailu images are designed to work on x86 or equivalent hardware, so it should run on pretty much any cloud server as long as enough power is -provided. If you find yourself running Mailu on small hardware, e.g. -Raspberry Pi or other platforms based on ARM, you will probably find -some support from `MFAshby's fork`_. +provided. For non x86 machines, see :ref:`rpi_build` You are free to choose any operating system that runs Docker (>= 1.11), then chose between various flavors including Docker Compose, Kubernetes @@ -34,7 +32,6 @@ You should also have at least a DNS hostname and a DNS name for receiving emails. Some instructions are provided on the matter in the article :ref:`dns_setup`. -.. _`MFAshby's fork`: https://github.com/MFAshby/Mailu Pick a Mailu version -------------------- From 7684eda5d5b715a7a0b28b5575b34ecfb7f6f671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Mon, 1 Apr 2019 00:12:23 -0400 Subject: [PATCH 09/16] add changelog --- towncrier/newsfragments/985.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 towncrier/newsfragments/985.feature diff --git a/towncrier/newsfragments/985.feature b/towncrier/newsfragments/985.feature new file mode 100644 index 00000000..99caa7e2 --- /dev/null +++ b/towncrier/newsfragments/985.feature @@ -0,0 +1 @@ +Add options to support different architectures builds From a8f55aa73af283dddb68852d099881bebc905a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Mon, 1 Apr 2019 11:31:19 -0400 Subject: [PATCH 10/16] copy arm qemu --- tests/build_arm.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/build_arm.sh b/tests/build_arm.sh index 280de51f..eca34351 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -7,11 +7,10 @@ EDGE_DISTRO="balenalib/rpi-alpine:edge" # Used for webmails PHP="arm32v7/php:7.2-apache" -# NOTE: Might not be needed since using multiarch/qemu -QEMU="$(which qemu-arm-static)" -cp $QEMU ../webmails/rainloop/ -cp $QEMU ../webmails/roundcube/ - # use qemu-*-static from docker container docker run --rm --privileged multiarch/qemu-user-static:register -docker-compose -f build.yml build --build-arg DISTRO=$DISTRO --build-arg PHP_DISTRO=$PHP --build-arg EDGE_DISTRO=$EDGE_DISTRO --parallel $@ +docker-compose -f build.yml build \ + --build-arg DISTRO=$DISTRO \ + --build-arg PHP_DISTRO=$PHP \ + --build-arg EDGE_DISTRO=$EDGE_DISTRO \ + --parallel $@ From 124b1d4c71f8ffb86df31af6365d03b2119e6a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Wed, 21 Aug 2019 12:24:30 -0400 Subject: [PATCH 11/16] rebase and update for 3.10, avoid adding qemu file to x86 images --- core/admin/Dockerfile | 3 ++- core/dovecot/Dockerfile | 3 ++- core/nginx/Dockerfile | 3 ++- core/none/Dockerfile | 3 ++- core/postfix/Dockerfile | 3 ++- optional/clamav/Dockerfile | 3 ++- optional/postgresql/Dockerfile | 3 ++- optional/radicale/Dockerfile | 3 ++- services/fetchmail/Dockerfile | 6 ++++-- services/rspamd/Dockerfile | 3 ++- services/unbound/Dockerfile | 3 ++- tests/build_arm.sh | 7 ++----- webmails/rainloop/Dockerfile | 3 ++- webmails/roundcube/Dockerfile | 3 ++- 14 files changed, 30 insertions(+), 19 deletions(-) diff --git a/core/admin/Dockerfile b/core/admin/Dockerfile index f6d28bf5..ee719b27 100644 --- a/core/admin/Dockerfile +++ b/core/admin/Dockerfile @@ -11,7 +11,8 @@ RUN mkdir static \ # Actual application -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/core/dovecot/Dockerfile b/core/dovecot/Dockerfile index 4c25bfcb..404cafa5 100644 --- a/core/dovecot/Dockerfile +++ b/core/dovecot/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/core/nginx/Dockerfile b/core/nginx/Dockerfile index 2b6da845..c7eab173 100644 --- a/core/nginx/Dockerfile +++ b/core/nginx/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/core/none/Dockerfile b/core/none/Dockerfile index 96bf8411..b80a2d10 100644 --- a/core/none/Dockerfile +++ b/core/none/Dockerfile @@ -1,5 +1,6 @@ # This is an idle image to dynamically replace any component if disabled. -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO CMD sleep 1000000d diff --git a/core/postfix/Dockerfile b/core/postfix/Dockerfile index ef23f9f4..26479283 100644 --- a/core/postfix/Dockerfile +++ b/core/postfix/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/optional/clamav/Dockerfile b/optional/clamav/Dockerfile index 02d0279a..60f8c87b 100644 --- a/optional/clamav/Dockerfile +++ b/optional/clamav/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip bash \ diff --git a/optional/postgresql/Dockerfile b/optional/postgresql/Dockerfile index 7f44204a..a2317426 100644 --- a/optional/postgresql/Dockerfile +++ b/optional/postgresql/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip bash \ diff --git a/optional/radicale/Dockerfile b/optional/radicale/Dockerfile index 66c1d5ca..ab819d69 100644 --- a/optional/radicale/Dockerfile +++ b/optional/radicale/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ && apk add --no-cache radicale@testing curl bash diff --git a/services/fetchmail/Dockerfile b/services/fetchmail/Dockerfile index 756630f6..271dd68a 100644 --- a/services/fetchmail/Dockerfile +++ b/services/fetchmail/Dockerfile @@ -1,5 +1,6 @@ # First stage: Build -FROM alpine:3.10 as builder +ARG DISTRO=alpine:3.10 +FROM $DISTRO as builder # build dependencies RUN apk add --no-cache curl tar xz autoconf git gettext build-base openssl openssl-dev @@ -10,7 +11,8 @@ RUN cd fetchmail-7.0.0-alpha6 && \ ./configure --with-ssl --prefix /usr/local --disable-nls && \ make -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ diff --git a/services/rspamd/Dockerfile b/services/rspamd/Dockerfile index 1646330d..2e23a61e 100644 --- a/services/rspamd/Dockerfile +++ b/services/rspamd/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/services/unbound/Dockerfile b/services/unbound/Dockerfile index 62bc81ce..aa0abe25 100644 --- a/services/unbound/Dockerfile +++ b/services/unbound/Dockerfile @@ -1,4 +1,5 @@ -FROM alpine:3.10 +ARG DISTRO=alpine:3.10 +FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ python3 py3-pip git bash \ diff --git a/tests/build_arm.sh b/tests/build_arm.sh index eca34351..bf65c697 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -1,16 +1,13 @@ #!/bin/bash -x -ALPINE_VER="3.8" +ALPINE_VER="3.10" DISTRO="balenalib/rpi-alpine:$ALPINE_VER" -# Used for Radicale -EDGE_DISTRO="balenalib/rpi-alpine:edge" # Used for webmails -PHP="arm32v7/php:7.2-apache" +PHP="arm32v7/php:7.3-apache" # use qemu-*-static from docker container docker run --rm --privileged multiarch/qemu-user-static:register docker-compose -f build.yml build \ --build-arg DISTRO=$DISTRO \ --build-arg PHP_DISTRO=$PHP \ - --build-arg EDGE_DISTRO=$EDGE_DISTRO \ --parallel $@ diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 140e1aff..99aa9fde 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -1,4 +1,5 @@ -FROM php:7.3-apache +ARG PHP_DISTRO=php:7.3-apache +FROM $PHP_DISTRO #Shared layer between rainloop and roundcube RUN apt-get update && apt-get install -y \ python3 curl python3-pip git \ diff --git a/webmails/roundcube/Dockerfile b/webmails/roundcube/Dockerfile index 2ed2bda2..e094e8f9 100644 --- a/webmails/roundcube/Dockerfile +++ b/webmails/roundcube/Dockerfile @@ -1,4 +1,5 @@ -FROM php:7.3-apache +ARG PHP_DISTRO=php:7.3-apache +FROM PHP_DISTRO #Shared layer between rainloop and roundcube RUN apt-get update && apt-get install -y \ python3 curl python3-pip git \ From e1a4bf32a6b56462c5f44fa44ac8a81a457a9496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Fri, 23 Aug 2019 15:24:21 -0400 Subject: [PATCH 12/16] only insert qemu binary if building for arm --- core/admin/Dockerfile | 7 ++++--- tests/build_arm.sh | 6 ++++-- webmails/rainloop/Dockerfile | 12 ++++++++++-- webmails/roundcube/Dockerfile | 9 +++++++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/core/admin/Dockerfile b/core/admin/Dockerfile index ee719b27..a3aff3d4 100644 --- a/core/admin/Dockerfile +++ b/core/admin/Dockerfile @@ -1,5 +1,7 @@ # First stage to build assets -FROM node:8 as assets +ARG ARCH="" +FROM ${ARCH}node:8 as assets +COPY --from=balenalib/rpi-alpine:3.10 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static COPY package.json ./ RUN npm install @@ -41,5 +43,4 @@ ENV FLASK_APP mailu CMD /start.py -HEALTHCHECK CMD curl -f -L http://localhost/ui/login?next=ui.index || exit 1 - +HEALTHCHECK CMD curl -f -L http://localhost/ui/login?next=ui.index || exit 1 \ No newline at end of file diff --git a/tests/build_arm.sh b/tests/build_arm.sh index bf65c697..04836ddb 100755 --- a/tests/build_arm.sh +++ b/tests/build_arm.sh @@ -3,11 +3,13 @@ ALPINE_VER="3.10" DISTRO="balenalib/rpi-alpine:$ALPINE_VER" # Used for webmails -PHP="arm32v7/php:7.3-apache" +QEMU="arm" +ARCH="arm32v7/" # use qemu-*-static from docker container docker run --rm --privileged multiarch/qemu-user-static:register docker-compose -f build.yml build \ --build-arg DISTRO=$DISTRO \ - --build-arg PHP_DISTRO=$PHP \ + --build-arg ARCH=$ARCH \ + --build-arg QEMU=$QEMU \ --parallel $@ diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 99aa9fde..05f8fa2d 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -1,5 +1,13 @@ -ARG PHP_DISTRO=php:7.3-apache -FROM $PHP_DISTRO +ARG ARCH="" +ARG QEMU=other + +# NOTE: only add file if building for arm +FROM ${ARCH}php:7.3-apache as build_arm +ONBUILD COPY --from=balenalib/rpi-alpine:3.10 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static + +FROM ${ARCH}php:7.3-apache as build_other + +FROM build_${QEMU} #Shared layer between rainloop and roundcube RUN apt-get update && apt-get install -y \ python3 curl python3-pip git \ diff --git a/webmails/roundcube/Dockerfile b/webmails/roundcube/Dockerfile index e094e8f9..9a526617 100644 --- a/webmails/roundcube/Dockerfile +++ b/webmails/roundcube/Dockerfile @@ -1,5 +1,10 @@ -ARG PHP_DISTRO=php:7.3-apache -FROM PHP_DISTRO +# NOTE: only add file if building for arm +FROM ${ARCH}php:7.3-apache as build_arm +ONBUILD COPY --from=balenalib/rpi-alpine:3.10 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static + +FROM ${ARCH}php:7.3-apache as build_other + +FROM build_${QEMU} #Shared layer between rainloop and roundcube RUN apt-get update && apt-get install -y \ python3 curl python3-pip git \ From 34079244a6ce2be0390a0ca0799a02f5deab092e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Fri, 30 Aug 2019 10:24:08 -0400 Subject: [PATCH 13/16] fix ARG positions --- core/admin/Dockerfile | 2 +- webmails/roundcube/Dockerfile | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/admin/Dockerfile b/core/admin/Dockerfile index a3aff3d4..485ad261 100644 --- a/core/admin/Dockerfile +++ b/core/admin/Dockerfile @@ -1,4 +1,5 @@ # First stage to build assets +ARG DISTRO=alpine:3.10 ARG ARCH="" FROM ${ARCH}node:8 as assets COPY --from=balenalib/rpi-alpine:3.10 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static @@ -13,7 +14,6 @@ RUN mkdir static \ # Actual application -ARG DISTRO=alpine:3.10 FROM $DISTRO # python3 shared with most images RUN apk add --no-cache \ diff --git a/webmails/roundcube/Dockerfile b/webmails/roundcube/Dockerfile index 9a526617..3e888215 100644 --- a/webmails/roundcube/Dockerfile +++ b/webmails/roundcube/Dockerfile @@ -1,4 +1,6 @@ # NOTE: only add file if building for arm +ARG ARCH="" +ARG QEMU=other FROM ${ARCH}php:7.3-apache as build_arm ONBUILD COPY --from=balenalib/rpi-alpine:3.10 /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static From 2c95ed98a43a87c6c6939125f0efeadf195c5f74 Mon Sep 17 00:00:00 2001 From: Aurelien Date: Sat, 14 Sep 2019 20:58:12 -0400 Subject: [PATCH 14/16] Delete CHANGELOG.md.20190330 --- CHANGELOG.md.20190330 | 1 - 1 file changed, 1 deletion(-) delete mode 100644 CHANGELOG.md.20190330 diff --git a/CHANGELOG.md.20190330 b/CHANGELOG.md.20190330 deleted file mode 100644 index d577cf2b..00000000 --- a/CHANGELOG.md.20190330 +++ /dev/null @@ -1 +0,0 @@ -find . -iname 'dockerfile' -exec sed -i "s/FROM.*/ARG DISTRO=alpine:3.8\nFROM \$DISTRO/" '{}' \; From 98307f868a25e1864442b31dbec8bba81923093e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Wed, 9 Oct 2019 12:09:18 -0400 Subject: [PATCH 15/16] RPi: fix alpine version for setup, only one layer for pip install --- setup/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup/Dockerfile b/setup/Dockerfile index 101fc36a..2b3c3c6c 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -1,12 +1,12 @@ -ARG DISTRO=alpine:3.8 +ARG DISTRO=alpine:3.10 FROM $DISTRO RUN mkdir -p /app WORKDIR /app COPY requirements.txt requirements.txt -RUN apk add --no-cache curl python3 py3-pip -RUN pip3 install -r requirements.txt +RUN apk add --no-cache curl python3 py3-pip \ + && pip3 install -r requirements.txt COPY server.py ./server.py COPY main.py ./main.py From 5066129df09d0e768fcaaecca2f11eedf2c0ba45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bondis?= Date: Wed, 9 Oct 2019 12:17:40 -0400 Subject: [PATCH 16/16] RPi: update doc (alpine version + variables) --- docs/rpi_build.rst | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/rpi_build.rst b/docs/rpi_build.rst index c3324cdc..5796e188 100644 --- a/docs/rpi_build.rst +++ b/docs/rpi_build.rst @@ -5,15 +5,21 @@ Building for a Raspberry Pi The build does not need to be done on the Pi. -To do so, go to ``tests/`` and call ``./build_arm.sh``, it will build all necessary images for arm. +To do so, go to ``tests/`` and call ``./build_arm.sh``, it will build all +necessary images for arm. -To push the locally built images to a remote server, run ``./deploy_to_pi.sh``. Docker 18.09+ is needed to use ``-H ssh://@``. +To push the locally built images to a remote server, run ``./deploy_to_pi.sh``. +Docker 18.09+ is needed to use ``-H ssh://@``. Adjustments ----------- ``build_arm.sh`` uses some variables passed as ``build-arg`` to docker-compose: -- ``DISTRO``: is the main distro used (ie: alpine:3.8) -- ``PHP_DISTRO``: is used for the ``rainloop`` and ``roundcube`` images -- ``EDGE_DISTRO``: is used for ``radicale`` as edge has dulwich and radicale as packages +- ``ALPINE_VER``: version of ALPINE to use +- ``DISTRO``: is the main distro used. Dockerfiles are set on Alpine 3.10, and + build script overrides for ``balenalib/rpi-alpine:3.10`` +- ``QEMU``: Used by webmails dockerfiles. It will add ``qemu-arm-static`` only + if ``QEMU`` is set to ``arm`` +- ``ARCH``: Architecture to use for ``admin``, and ``webmails`` as their images + are available for those architectures.