From 1ea42e8eac0498a027f8c303e33a87f93df4dba5 Mon Sep 17 00:00:00 2001
From: Kai <sistason@sistason.de>
Date: Mon, 19 Aug 2019 21:58:11 +0200
Subject: [PATCH] Adds Docker for firmware-building

This commit adds a Dockerfile to build a docker container to build
the firmware with.
It also updates the documentation on how to do that.
---
 Dockerfile_fwbuild             | 10 ++++++++++
 Documentation/how-to-build.rst | 22 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)
 create mode 100644 Dockerfile_fwbuild

diff --git a/Dockerfile_fwbuild b/Dockerfile_fwbuild
new file mode 100644
index 000000000..6845cb52f
--- /dev/null
+++ b/Dockerfile_fwbuild
@@ -0,0 +1,10 @@
+FROM ubuntu
+
+RUN apt-get update && apt-get -y install gcc-arm-none-eabi binutils-arm-none-eabi libnewlib-arm-none-eabi python3 python3-pip ninja-build git
+
+RUN pip3 install meson crc16 pillow
+
+VOLUME /firmware
+WORKDIR /firmware
+
+CMD ./bootstrap.sh && ninja -C build && chown -R --reference=/firmware build
diff --git a/Documentation/how-to-build.rst b/Documentation/how-to-build.rst
index 33a6dc979..1cfee7f69 100644
--- a/Documentation/how-to-build.rst
+++ b/Documentation/how-to-build.rst
@@ -111,3 +111,25 @@ In order to do a rebuild you can issue a clean command to ninja via
   $ ninja -C build/ -t clean
 
 Otherwise, rerunning ``./bootstrap.sh`` will also clean the build-directory.
+
+Docker
+======
+Alternatively, clone the ``master`` branch of the firmware repository and enter it:
+
+.. code-block:: shell-session
+
+   $ git clone https://git.card10.badge.events.ccc.de/card10/firmware.git
+   $ cd firmware
+
+Afterwards, build a docker-container which will build the firmware via:
+
+.. code-block:: shell-session
+
+   $ docker build -f Dockerfile_fwbuild -t card10-firmware-builder .
+
+Now, you can start the container with the firmware directory mounted, which will build the 
+firmware into the firmware/build directory:
+
+.. code-block:: shell-session
+
+   $ docker run -v $(pwd):/firmware card10-firmware-builder
-- 
GitLab