mirror of
https://github.com/optim-enterprises-bv/Mailu.git
synced 2025-11-01 18:47:52 +00:00
Merge #985
985: Permit raspberry pi (and other architectures) builds r=mergify[bot] a=abondis ## What type of PR? Enhancement ## What does this PR do? Add an option to select base images and permit building for different CPU architectures. ### Related issue(s) N/A ## Prerequistes - [X] documentation updated accordingly - [x] Unless it's docs or a minor change: add [changelog](https://mailu.io/master/contributors/guide.html#changelog) entry file. Co-authored-by: Aurélien Bondis <aurelien.bondis@gmail.com> Co-authored-by: Aurelien <aurelien.bondis@gmail.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@ pip-selfcheck.json
|
|||||||
/docker-compose.yml
|
/docker-compose.yml
|
||||||
/.idea
|
/.idea
|
||||||
/.vscode
|
/.vscode
|
||||||
|
qemu-arm-static
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# First stage to build assets
|
# First stage to build assets
|
||||||
FROM node:8 as 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
|
||||||
|
|
||||||
COPY package.json ./
|
COPY package.json ./
|
||||||
RUN npm install
|
RUN npm install
|
||||||
@@ -11,7 +14,7 @@ RUN mkdir static \
|
|||||||
|
|
||||||
|
|
||||||
# Actual application
|
# Actual application
|
||||||
FROM alpine:3.10
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
@@ -40,5 +43,4 @@ ENV FLASK_APP mailu
|
|||||||
|
|
||||||
CMD /start.py
|
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
|
||||||
|
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# This is an idle image to dynamically replace any component if disabled.
|
# 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
|
CMD sleep 1000000d
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
FROM python:3-alpine
|
ARG DISTRO=alpine:3.8
|
||||||
|
FROM $DISTRO
|
||||||
|
|
||||||
COPY requirements.txt /requirements.txt
|
COPY requirements.txt /requirements.txt
|
||||||
|
|
||||||
ARG version=master
|
ARG version=master
|
||||||
ENV VERSION=$version
|
ENV VERSION=$version
|
||||||
|
|
||||||
RUN pip install -r /requirements.txt \
|
RUN apk add --no-cache nginx curl python3 \
|
||||||
&& apk add --no-cache nginx curl \
|
&& pip3 install -r /requirements.txt \
|
||||||
&& mkdir /run/nginx
|
&& mkdir /run/nginx
|
||||||
|
|
||||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|||||||
25
docs/rpi_build.rst
Normal file
25
docs/rpi_build.rst
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
.. _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://<user>@<host>``.
|
||||||
|
|
||||||
|
Adjustments
|
||||||
|
-----------
|
||||||
|
|
||||||
|
``build_arm.sh`` uses some variables passed as ``build-arg`` to docker-compose:
|
||||||
|
|
||||||
|
- ``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.
|
||||||
@@ -19,9 +19,7 @@ Prepare the environment
|
|||||||
|
|
||||||
Mailu images are designed to work on x86 or equivalent hardware, so it
|
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
|
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.
|
provided. For non x86 machines, see :ref:`rpi_build`
|
||||||
Raspberry Pi or other platforms based on ARM, you will probably find
|
|
||||||
some support from `MFAshby's fork`_.
|
|
||||||
|
|
||||||
You are free to choose any operating system that runs Docker (>= 1.11),
|
You are free to choose any operating system that runs Docker (>= 1.11),
|
||||||
then chose between various flavors including Docker Compose, Kubernetes
|
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
|
emails. Some instructions are provided on the matter in the article
|
||||||
:ref:`dns_setup`.
|
:ref:`dns_setup`.
|
||||||
|
|
||||||
.. _`MFAshby's fork`: https://github.com/MFAshby/Mailu
|
|
||||||
|
|
||||||
Pick a Mailu version
|
Pick a Mailu version
|
||||||
--------------------
|
--------------------
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip bash \
|
python3 py3-pip bash \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip bash \
|
python3 py3-pip bash \
|
||||||
|
|||||||
@@ -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 \
|
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
|
||||||
&& apk add --no-cache radicale@testing curl bash
|
&& apk add --no-cache radicale@testing curl bash
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# First stage: Build
|
# First stage: Build
|
||||||
FROM alpine:3.10 as builder
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO as builder
|
||||||
|
|
||||||
# build dependencies
|
# build dependencies
|
||||||
RUN apk add --no-cache curl tar xz autoconf git gettext build-base openssl openssl-dev
|
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 && \
|
./configure --with-ssl --prefix /usr/local --disable-nls && \
|
||||||
make
|
make
|
||||||
|
|
||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
|
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
FROM alpine:3.10
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip git bash \
|
python3 py3-pip git bash \
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
FROM python:3-alpine
|
ARG DISTRO=alpine:3.10
|
||||||
|
FROM $DISTRO
|
||||||
|
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY requirements.txt requirements.txt
|
COPY requirements.txt requirements.txt
|
||||||
RUN apk add --no-cache curl \
|
RUN apk add --no-cache curl python3 py3-pip \
|
||||||
&& pip install -r requirements.txt
|
&& pip3 install -r requirements.txt
|
||||||
|
|
||||||
COPY server.py ./server.py
|
COPY server.py ./server.py
|
||||||
COPY main.py ./main.py
|
COPY main.py ./main.py
|
||||||
|
|||||||
15
tests/build_arm.sh
Executable file
15
tests/build_arm.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash -x
|
||||||
|
|
||||||
|
ALPINE_VER="3.10"
|
||||||
|
DISTRO="balenalib/rpi-alpine:$ALPINE_VER"
|
||||||
|
# Used for webmails
|
||||||
|
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 ARCH=$ARCH \
|
||||||
|
--build-arg QEMU=$QEMU \
|
||||||
|
--parallel $@
|
||||||
6
tests/deploy_to_pi.sh
Executable file
6
tests/deploy_to_pi.sh
Executable file
@@ -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"
|
||||||
1
towncrier/newsfragments/985.feature
Normal file
1
towncrier/newsfragments/985.feature
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Add options to support different architectures builds
|
||||||
@@ -1,4 +1,13 @@
|
|||||||
FROM php:7.3-apache
|
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
|
#Shared layer between rainloop and roundcube
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
python3 curl python3-pip git \
|
python3 curl python3-pip git \
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
FROM php:7.3-apache
|
# 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 ${ARCH}php:7.3-apache as build_other
|
||||||
|
|
||||||
|
FROM build_${QEMU}
|
||||||
#Shared layer between rainloop and roundcube
|
#Shared layer between rainloop and roundcube
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
python3 curl python3-pip git \
|
python3 curl python3-pip git \
|
||||||
|
|||||||
Reference in New Issue
Block a user