From 8b9149e64d0eed7b3ff7455c6161b3d5e137e827 Mon Sep 17 00:00:00 2001 From: Dmitry Krasnoukhov Date: Sat, 31 Aug 2019 01:03:45 +0300 Subject: [PATCH] arm32v7 docker build setup (#97) --- Dockerfile.arm32v7 | 43 ++++++++++++++++++++++++++++++++++++++++ hooks/post_push | 6 ++++++ hooks/pre_build | 3 +++ multi-arch-manifest.yaml | 11 ++++++++++ 4 files changed, 63 insertions(+) create mode 100644 Dockerfile.arm32v7 create mode 100644 hooks/post_push create mode 100644 hooks/pre_build create mode 100644 multi-arch-manifest.yaml diff --git a/Dockerfile.arm32v7 b/Dockerfile.arm32v7 new file mode 100644 index 0000000..cc56149 --- /dev/null +++ b/Dockerfile.arm32v7 @@ -0,0 +1,43 @@ +FROM alpine AS builder + +ENV QEMU_URL https://github.com/balena-io/qemu/releases/download/v3.0.0%2Bresin/qemu-3.0.0+resin-arm.tar.gz +RUN apk add curl && curl -L ${QEMU_URL} | tar zxvf - -C . --strip-components 1 + +FROM arm32v7/alpine:3.9 + +COPY --from=builder qemu-arm-static /usr/bin +RUN mkdir application +WORKDIR /application +ADD . /application + +RUN apk add --no-cache tzdata python3 git bluez glib-dev make bluez-dev bluez-libs musl-dev linux-headers gcc grep && \ + python3 -m ensurepip && \ + rm -r /usr/lib/python*/ensurepip && \ + pip3 install --upgrade pip setuptools && \ + if [ ! -e /usr/bin/pip ]; then \ + ln -s pip3 /usr/bin/pip ; \ + fi && \ + if [[ ! -e /usr/bin/python ]]; then \ + ln -sf /usr/bin/python3 /usr/bin/python; \ + fi && \ + rm -r /root/.cache && \ + mkdir /config && \ + pip install -r requirements.txt && \ + ln -s /config/config.yaml ./config.yaml && \ + apk del --no-cache bluez-dev musl-dev gcc make git glib-dev linux-headers grep python2 + +RUN apk add --no-cache tzdata python3 git bluez glib-dev make bluez-dev bluez-libs musl-dev linux-headers gcc grep && \ + grep -P "(?<=REQUIREMENTS).*" workers/*.py | grep -Po "(?<=\[).*(?=\])" | tr ',' '\n' | tr "'" " "| tr "\"" " " > /tmp/requirements.txt && \ + cat /tmp/requirements.txt && \ + pip install -r /tmp/requirements.txt && \ + rm /tmp/requirements.txt && \ + apk del --no-cache bluez-dev musl-dev gcc make git glib-dev linux-headers grep python2 + +ADD ./start.sh /start.sh +RUN chmod +x /start.sh + +ENV DEBUG false + +VOLUME ["/config"] + +ENTRYPOINT ["/bin/sh", "-c", "/start.sh"] diff --git a/hooks/post_push b/hooks/post_push new file mode 100644 index 0000000..a284575 --- /dev/null +++ b/hooks/post_push @@ -0,0 +1,6 @@ +#!/bin/bash + +curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 +chmod +x manifest-tool + +./manifest-tool push from-spec multi-arch-manifest.yaml diff --git a/hooks/pre_build b/hooks/pre_build new file mode 100644 index 0000000..20bb431 --- /dev/null +++ b/hooks/pre_build @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run --rm --privileged multiarch/qemu-user-static:register --reset diff --git a/multi-arch-manifest.yaml b/multi-arch-manifest.yaml new file mode 100644 index 0000000..84e3797 --- /dev/null +++ b/multi-arch-manifest.yaml @@ -0,0 +1,11 @@ +image: zewelor/bt-mqtt-gateway:latest +manifests: + - image: zewelor/bt-mqtt-gateway:amd64 + platform: + architecture: amd64 + os: linux + - image: zewelor/bt-mqtt-gateway:arm32v7 + platform: + architecture: arm + os: linux + variant: v7