multi-arch attempt 1 (#71)

This commit is contained in:
Nicholas St. Germain 2019-01-16 12:00:41 -06:00
parent 7ec28e51fc
commit 855816a576
6 changed files with 131 additions and 14 deletions

View file

@ -1,15 +1,13 @@
sudo: true
dist: xenial
language: minimal
services:
- docker
jobs:
include:
- stage: "Build and Push"
script:
- docker build -t boerderij/varken:$TRAVIS_BRANCH .
- docker images
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push boerderij/varken:$TRAVIS_BRANCH
env:
global:
- secure: c91+zQXN28Anr2q94vhJAzN36teKovgniNmUI0MaejYfwcShN8TVeojkxbP+AxZuvGh1AfvB26LQeuPqAAntoNxvtPg3PLxv93rRSkAf0jk9apm9biYDAJNAM3OSiqCGfzfNhtUHmPmybRy2UmRXpHc6ZU1GmOdX2yyXCC2S6wjJOGabRpCA2Lw1vNnQuSJMDZ78amybZNmqAkK+rxe9hH2TGwcSImW8dlW2Ryt8H4a2s9VW9rbebQF+PzY4pw+OlIarpVUXZzUyEq8PS2EmJTuhrNA+RtZWJ4yRZ33jK4UqZRJzfC4FniZzSqtV/P3YGgSFNzhM87y5VhNiauX6QmtIDfLUV6c86cWCy24O41SrAJQOi4CLszJVkYfyggVFoRFegNS2+njN+f2Bbbx3rHtmNds0cDSfFuK3XhtTe0EhNgHLXOCX4IyAGzYWO+afmbqm/8S+m/QjCT28+0GgxYSqD2qO3FuPRA7woWucrKl2xa/tYikkurkDif0yBHxPac8mB8KLPLrjGzHlBG6SYYpTlpjWJrddbYhm0EZVmMkkFHRHLcOK8AOHKQipQBHmP+wvTGouwaZ8Uv5+uDNZ76st4BZR1tfXCtZ6A0RLRspo0wJ5EKlrNr8OIQGdj1G4TJ0H029mycqkAQ5yFPlvF/wAZ0shVFb/uMejpQw+2ks=
addons:
apt:
packages:
- docker-ce
branches:
only:
- master
script: bash deploy.sh

View file

@ -1,4 +1,4 @@
FROM lsiobase/alpine.python3
FROM amd64/python:3.7.2-alpine
LABEL maintainers="dirtycajunrice,samwiseg0"
@ -6,6 +6,8 @@ ENV DEBUG="False"
COPY / /app
COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static
RUN \
python3 -m pip install -r /app/requirements.txt && \
chown -R abc:abc \

21
Dockerfile.arm Normal file
View file

@ -0,0 +1,21 @@
FROM arm32v6/python:3.7.2-alpine
LABEL maintainers="dirtycajunrice,samwiseg0"
ENV DEBUG="False"
COPY / /app
COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static
RUN \
python3 -m pip install -r /app/requirements.txt && \
chown -R abc:abc \
/config \
/app
WORKDIR /app
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config
VOLUME /config

21
Dockerfile.arm64 Normal file
View file

@ -0,0 +1,21 @@
FROM arm64v8/python:3.7.2-alpine
LABEL maintainers="dirtycajunrice,samwiseg0"
ENV DEBUG="False"
COPY / /app
COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static
RUN \
python3 -m pip install -r /app/requirements.txt && \
chown -R abc:abc \
/config \
/app
WORKDIR /app
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config
VOLUME /config

21
Dockerfile.armhf Normal file
View file

@ -0,0 +1,21 @@
FROM arm32v7/python:3.7.2-slim
LABEL maintainers="dirtycajunrice,samwiseg0"
ENV DEBUG="False"
COPY / /app
COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static
RUN \
python3 -m pip install -r /app/requirements.txt && \
chown -R abc:abc \
/config \
/app
WORKDIR /app
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config
VOLUME /config

54
deploy.sh Normal file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env bash
VERSION="$(grep -i version varken.__init__.py | cut -d' ' -f3 | tr -d \")"
# Docker
GITHUB_USER='dirtycajunrice'
DOCKER_USER='dirtycajunrice'
PROJECT='varken'
NAMESPACE="boerderij/${PROJECT}"
# Docker experimental config
echo '{"experimental":true}' | sudo tee /etc/docker/daemon.json
[[ -d ~/.docker ]] || mkdir ~/.docker
[[ -f ~/.docker/config.json ]] || touch ~/.docker/config.json
echo '{"experimental":"enabled"}' | sudo tee ~/.docker/config.json
sudo service docker restart
# Auth
echo "$DOCKER_PASSWORD" | docker login -u="$DOCKER_USER" --password-stdin
# Latest x64
docker build -t "${NAMESPACE}:latest" . && \
docker push "${NAMESPACE}:latest" && \
# Versioned x64
docker tag "${NAMESPACE}:latest" "${NAMESPACE}:${VERSION}" && \
docker push "${NAMESPACE}:${VERSION}" && \
# x64 Arch
docker tag "${NAMESPACE}:latest" "${NAMESPACE}:latest-amd64" && \
docker push "${NAMESPACE}:latest-amd64"
# Prepare qemu for ARM builds
docker run --rm --privileged multiarch/qemu-user-static:register --reset
wget -P tmp/ "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-aarch64-static"
wget -P tmp/ "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-arm-static"
chmod +x tmp/qemu-aarch64-static tmp/qemu-arm-static
# ARM images
for i in $(ls *arm*); do
arch="$(echo ${i} | cut -d. -f2)"
# Latest
docker build -f "./Dockerfile.${arch}" -t "${NAMESPACE}:latest-${arch}" . && \
docker push "${NAMESPACE}:latest-${arch}" && \
# Versioned
docker tag "${NAMESPACE}:latest-${arch}" "${NAMESPACE}:${VERSION}-${arch}" && \
docker push "${NAMESPACE}:${VERSION}-${arch}"
done
wget -O manifest-tool https://github.com/estesp/manifest-tool/releases/download/v0.9.0/manifest-tool-linux-amd64 && \
chmod +x manifest-tool && \
python3 manifest_generator.py && \
./manifest-tool --username "$DOCKER_USER" --password "$DOCKER_PASSWORD" push from-spec ".manifest.yaml"
# Git tags
git remote set-url origin "https://${GITHUB_USER}:${GITHUB_API_KEY}@github.com/${NAMESPACE}.git" && \
git tag "${VERSION}" && \
git push --tags