Simplify multi-arch building

Rather than having multiple Dockerfiles, switch to a single Dockerfile
and a build arg.
This commit is contained in:
ViViDboarder 2020-02-11 13:28:19 -08:00
parent cb86cd531f
commit 5794cd86e1
8 changed files with 48 additions and 95 deletions

View File

@ -1,7 +1,10 @@
---
sudo: required sudo: required
services: docker services: docker
script: script:
# - make build-all - docker run --rm --privileged multiarch/qemu-user-static:register --reset
- make test-x86 - make build-all
- make test-all
# test-s3-arm has issues, but the image works in the wild
- make test-s3-x86 - make test-s3-x86

View File

@ -1,5 +1,6 @@
FROM ubuntu:xenial ARG REPO=library
MAINTAINER ViViDboarder <vividboarder@gmail.com> FROM ${REPO}/ubuntu:xenial
LABEL maintainer="ViViDboarder <vividboarder@gmail.com>"
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
@ -23,8 +24,8 @@ RUN apt-get update \
python-urllib3 \ python-urllib3 \
rsync \ rsync \
tahoe-lafs \ tahoe-lafs \
&& pip install -U --no-cache-dir boto b2 \ && pip install -U --no-cache-dir boto==2.49.0 b2==1.4.2 \
&& apt-get autoremove -y python-pip \ && apt-get autoremove -y python-pip python-setuptools \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/apt/lists/* && rm -rf /var/apt/lists/*

View File

@ -1,57 +0,0 @@
FROM raspbian/jessie
MAINTAINER ViViDboarder <vividboarder@gmail.com>
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
cron \
duplicity \
lftp \
ncftp \
openssh-client \
python-cloudfiles \
python-gdata \
python-oauthlib \
python-paramiko \
python-pexpect \
python-pip \
python-urllib3 \
rsync \
tahoe-lafs \
&& pip install --no-cache-dir -U setuptools \
&& pip install --no-cache-dir -U boto b2 \
&& apt-get remove -y python-pip \
&& apt-get install -y --no-install-recommends \
python-swiftclient \
&& rm -rf /var/apt/lists/*
VOLUME /root/.cache/duplicity
VOLUME /backups
VOLUME /var/lock/duplicity
ENV BACKUP_DEST="file:///backups"
ENV BACKUP_NAME="backup"
ENV PATH_TO_BACKUP="/data"
ENV PASSPHRASE="Correct.Horse.Battery.Staple"
ENV FLOCK_WAIT=60
# Cron schedules
ENV CRON_SCHEDULE=""
ENV FULL_CRON_SCHEDULE=""
ENV VERIFY_CRON_SCHEDULE=""
# Create script dirs
RUN mkdir -p /scripts/backup/before
RUN mkdir -p /scripts/backup/after
RUN mkdir -p /scripts/restore/before
RUN mkdir -p /scripts/restore/after
COPY backup.sh /
COPY restore.sh /
COPY start.sh /
COPY verify.sh /
COPY healthcheck.sh /
COPY cron-exec.sh /
HEALTHCHECK CMD /healthcheck.sh
CMD [ "/start.sh" ]

View File

@ -1,48 +1,51 @@
DOCKER_TAG ?= docker-duplicity-cron DOCKER_TAG ?= docker-duplicity-cron
.PHONY: default .PHONY: default
default: build-x86 default: build-amd64
.PHONY: all
all: build-all test-all test-s3-all
.PHONY: test .PHONY: test
test: test-x86 test: test-amd64
.PHONY: build-x86 .PHONY: build-amd64
build-x86: build-amd64:
docker build -f ./Dockerfile -t $(DOCKER_TAG):ubuntu . docker build --build-arg REPO=library -f ./Dockerfile -t $(DOCKER_TAG):amd64 .
.PHONY: build-arm .PHONY: build-arm
build-arm: build-arm:
docker build -f ./Dockerfile.armhf -t $(DOCKER_TAG):raspbian . docker build --build-arg REPO=arm32v7 -f ./Dockerfile -t $(DOCKER_TAG):arm .
.PHONY: build-all .PHONY: build-all
build-all: build-x86 build-arm build-all: build-amd64 build-arm
.PHONY: test-x86 .PHONY: test-amd64
test-x86: build-x86 test-amd64: build-amd64
cd tests && ./test.sh $(DOCKER_TAG):ubuntu cd tests && ./test.sh $(DOCKER_TAG):amd64
cd tests && ./test-pre-scripts.sh $(DOCKER_TAG):ubuntu cd tests && ./test-pre-scripts.sh $(DOCKER_TAG):amd64
.PHONY: test-arm .PHONY: test-arm
test-arm: build-arm test-arm: build-arm
cd tests && ./test.sh $(DOCKER_TAG):raspbian cd tests && ./test.sh $(DOCKER_TAG):arm
cd tests && ./test-pre-scripts.sh $(DOCKER_TAG):raspbian cd tests && ./test-pre-scripts.sh $(DOCKER_TAG):arm
.PHONY: test-all .PHONY: test-all
test-all: test-x86 test-arm test-all: test-amd64 test-arm
.PHONY: test-s3-x86 .PHONY: test-s3-amd64
test-s3-x86: test-s3-amd64: build-amd64
cd tests && ./test-s3.sh Dockerfile cd tests && ./test-s3.sh $(DOCKER_TAG):amd64
.PHONY: test-s3-arm .PHONY: test-s3-arm
test-s3-arm: test-s3-arm: build-arm
cd tests && ./test-s3.sh Dockerfile.armhf cd tests && ./test-s3.sh $(DOCKER_TAG):arm
.PHONY: test-s3-all .PHONY: test-s3-all
test-s3-all: test-s3-x86 test-s3-arm test-s3-all: test-s3-amd64 test-s3-arm
.PHONY: shell-x86 .PHONY: shell-amd64
shell-x86: build-x86 shell-amd64: build-amd64
docker run --rm -it $(DOCKER_TAG):ubuntu bash docker run --rm -it $(DOCKER_TAG):ubuntu bash
.PHONY: shell-arm .PHONY: shell-arm
@ -50,7 +53,7 @@ shell-arm: build-arm
docker run --rm -it $(DOCKER_TAG):raspbian bash docker run --rm -it $(DOCKER_TAG):raspbian bash
.PHONY: shell .PHONY: shell
shell: shell-x86 shell: shell-amd64
.PHONY: clean .PHONY: clean
clean: clean:

View File

@ -1,9 +1,13 @@
---
version: '2' version: '2'
services: services:
duplicity: duplicity:
build: image: "$DOCKER_IMAGE"
context: .. # build:
dockerfile: ${DOCKERFILE} # context: ..
# dockerfile: Dockerfile
# args:
# REPO: "${BUILD_ARG_REPO}"
entrypoint: "bash" entrypoint: "bash"
command: ["/test.sh"] command: ["/test.sh"]
hostname: itest hostname: itest

View File

@ -1,7 +1,7 @@
#! /bin/bash #! /bin/bash
set -e set -e
image=$1 image="$1"
if [ "$IN_CONTAINER" != "true" ] ; then if [ "$IN_CONTAINER" != "true" ] ; then
# Run the test script within the container # Run the test script within the container
@ -10,7 +10,7 @@ if [ "$IN_CONTAINER" != "true" ] ; then
-e SKIP_ON_START=true \ -e SKIP_ON_START=true \
-v "$(pwd)/test-pre-scripts.sh:/test.sh" \ -v "$(pwd)/test-pre-scripts.sh:/test.sh" \
-v "$(pwd)/test-pre-scripts:/scripts" \ -v "$(pwd)/test-pre-scripts:/scripts" \
$image \ "$image" \
bash -c "/test.sh" bash -c "/test.sh"
else else
echo "Performing backup tests" echo "Performing backup tests"

View File

@ -1,6 +1,5 @@
#! /bin/bash #! /bin/bash
export DOCKERFILE=$1 export DOCKER_IMAGE="$1"
docker-compose -f docker-compose-test-s3.yml up \ docker-compose -f docker-compose-test-s3.yml up \
--build --abort-on-container-exit --force-recreate --build --abort-on-container-exit --force-recreate

View File

@ -1,7 +1,7 @@
#! /bin/bash #! /bin/bash
set -e set -e
image=$1 image="$1"
if [ "$IN_CONTAINER" != "true" ] ; then if [ "$IN_CONTAINER" != "true" ] ; then
# Run the test script within the container # Run the test script within the container
@ -9,7 +9,7 @@ if [ "$IN_CONTAINER" != "true" ] ; then
-e IN_CONTAINER=true \ -e IN_CONTAINER=true \
-e SKIP_ON_START=true \ -e SKIP_ON_START=true \
-v "$(pwd)/test.sh:/test.sh" \ -v "$(pwd)/test.sh:/test.sh" \
$image \ "$image" \
bash -c "/test.sh" bash -c "/test.sh"
else else
echo "Performing backup tests" echo "Performing backup tests"