From 3896f5242bd2d6cf06c9208b62fe1d0e9c3e40ec Mon Sep 17 00:00:00 2001 From: "Nicholas St. Germain" Date: Fri, 25 Jan 2019 12:34:29 -0600 Subject: [PATCH] refactor docker deployment --- Dockerfile | 10 +++++++--- Dockerfile.arm | 12 ++++++++---- Dockerfile.arm64 | 12 ++++++++---- Dockerfile.armhf | 17 ----------------- deploy.sh | 21 ++------------------- manifest_generator.py | 37 ------------------------------------- prebuild.sh | 3 +++ varken/__init__.py | 2 +- 8 files changed, 29 insertions(+), 85 deletions(-) delete mode 100644 Dockerfile.armhf delete mode 100644 manifest_generator.py create mode 100644 prebuild.sh diff --git a/Dockerfile b/Dockerfile index 04e8806..8c84f9c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,12 +4,16 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="False" -COPY / /app +WORKDIR /app + +COPY /requirements.txt /Varken.py /app/ + +COPY /varken /app/varken + +COPY /data /app/data RUN python3 -m pip install -r /app/requirements.txt -WORKDIR /app - CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config VOLUME /config diff --git a/Dockerfile.arm b/Dockerfile.arm index 5d5624e..3bcad32 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -4,14 +4,18 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="False" -COPY / /app +WORKDIR /app -COPY /tmp/qemu-arm-static /usr/bin/qemu-arm-static +COPY /qemu-arm-static /usr/bin/qemu-arm-static + +COPY /requirements.txt /Varken.py /app/ + +COPY /varken /app/varken + +COPY /data /app/data RUN python3 -m pip install -r /app/requirements.txt -WORKDIR /app - CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config VOLUME /config \ No newline at end of file diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 5922d9a..d18a154 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -4,14 +4,18 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="False" -COPY / /app +WORKDIR /app -COPY /tmp/qemu-aarch64-static /usr/bin/qemu-aarch64-static +COPY /qemu-aarch64-static /usr/bin/qemu-aarch64-static + +COPY /requirements.txt /Varken.py /app/ + +COPY /varken /app/varken + +COPY /data /app/data RUN python3 -m pip install -r /app/requirements.txt -WORKDIR /app - CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config VOLUME /config \ No newline at end of file diff --git a/Dockerfile.armhf b/Dockerfile.armhf deleted file mode 100644 index 4ed529a..0000000 --- a/Dockerfile.armhf +++ /dev/null @@ -1,17 +0,0 @@ -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 - -WORKDIR /app - -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config - -VOLUME /config \ No newline at end of file diff --git a/deploy.sh b/deploy.sh index 830096c..d2feb82 100644 --- a/deploy.sh +++ b/deploy.sh @@ -32,9 +32,8 @@ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USER" --password-stdin # 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 +bash prebuild.sh +chmod +x qemu-aarch64-static qemu-arm-static # Set tag based off of branch if [[ "$BRANCH" == "latest" ]]; then @@ -63,22 +62,6 @@ for i in $(ls *arm*); do if [[ "$BRANCH" == "latest" ]]; then docker manifest create -a "${REPOSITORY}:${BRANCH}" "${REPOSITORY}:${TAG}-${ARCH}" fi - if [[ "$ARCH" == "arm64" ]]; then - docker manifest annotate "${REPOSITORY}:${TAG}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v8 --arch arm64 - if [[ "$BRANCH" == "latest" ]]; then - docker manifest annotate "${REPOSITORY}:${BRANCH}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v8 --arch arm64 - fi - elif [[ "$ARCH" == "armhf" ]]; then - docker manifest annotate "${REPOSITORY}:${TAG}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v7 --arch arm - if [[ "$BRANCH" == "latest" ]]; then - docker manifest annotate "${REPOSITORY}:${BRANCH}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v7 --arch arm - fi - elif [[ "$ARCH" == "arm" ]]; then - docker manifest annotate "${REPOSITORY}:${TAG}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v6 --arch arm - if [[ "$BRANCH" == "latest" ]]; then - docker manifest annotate "${REPOSITORY}:${BRANCH}" "${REPOSITORY}:${TAG}-${ARCH}" --variant v6 --arch arm - fi - fi done docker manifest inspect "${REPOSITORY}:${TAG}" && \ diff --git a/manifest_generator.py b/manifest_generator.py deleted file mode 100644 index d429f50..0000000 --- a/manifest_generator.py +++ /dev/null @@ -1,37 +0,0 @@ -import yaml - -from varken import VERSION - -org = 'boerderij' -project = 'varken' -namespace = "{}/{}".format(org, project) - -yaml_arr = [] -tags = ['latest', VERSION] - -# Docker image, arch, variant, os -arch_list = [('arm', 'arm', 'v6', 'linux'), - ('armhf', 'arm', 'v7', 'linux'), - ('arm64', 'arm64', 'v8', 'linux'), - ('amd64', 'amd64', None, 'linux')] - -for tag in tags: - yaml_doc = { - 'image': '{}:{}'.format(namespace, tag), - 'manifests': [] - } - for arch in arch_list: - info = { - 'image': "{}:{}-{}".format(namespace, tag, arch[0]), - 'platform': { - 'architecture': arch[1], - 'os': arch[3] - } - } - if arch[2]: - info['platform']['variant'] = arch[2] - yaml_doc['manifests'].append(info) - yaml_arr.append(yaml_doc) - -with open(f".manifest.yaml", 'w') as file: - yaml.dump_all(yaml_arr, file, default_flow_style=False) diff --git a/prebuild.sh b/prebuild.sh new file mode 100644 index 0000000..8d12fd7 --- /dev/null +++ b/prebuild.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +wget -q "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-aarch64-static" +wget -q "https://github.com/multiarch/qemu-user-static/releases/download/v3.1.0-2/qemu-arm-static" \ No newline at end of file diff --git a/varken/__init__.py b/varken/__init__.py index 4847e96..9ec9472 100644 --- a/varken/__init__.py +++ b/varken/__init__.py @@ -1,2 +1,2 @@ VERSION = "1.6.4" -BRANCH = 'nightly' +BRANCH = 'develop'