Add x86 and arm builds and tests

This commit is contained in:
ViViDboarder 2017-06-28 18:12:49 -07:00
parent c5d673885e
commit e42eef8fcd
7 changed files with 74 additions and 1 deletions

View File

@ -1,2 +1,5 @@
Dockerfile.*
Makefile
Readme.md Readme.md
docker-compose.yaml docker-compose.yaml
test.sh

29
Dockerfile.raspbian Normal file
View File

@ -0,0 +1,29 @@
FROM resin/rpi-raspbian:jessie
MAINTAINER ViViDboarder <vividboarder@gmail.com>
RUN [ "cross-build-start" ]
RUN apt-get update \
&& apt-get install -y duplicity python-setuptools \
python-boto python-swiftclient python-pexpect openssh-client \
&& rm -rf /var/apt/lists/*
RUN [ "cross-build-end" ]
VOLUME "/root/.cache/duplicity"
VOLUME "/backups"
ENV BACKUP_DEST="file:///backups"
ENV BACKUP_NAME="backup"
ENV PATH_TO_BACKUP="/data"
ENV PASSPHRASE="Correct.Horse.Battery.Staple"
# Cron schedules
ENV CRON_SCHEDULE=""
ENV VERIFY_CRON_SCHEDULE=""
ADD entrypoint.sh /
ADD backup.sh /
ADD verify.sh /
ENTRYPOINT [ "/entrypoint.sh" ]

View File

@ -23,5 +23,6 @@ ENV VERIFY_CRON_SCHEDULE=""
ADD entrypoint.sh / ADD entrypoint.sh /
ADD backup.sh / ADD backup.sh /
ADD verify.sh /
ENTRYPOINT [ "/entrypoint.sh" ] ENTRYPOINT [ "/entrypoint.sh" ]

21
Makefile Normal file
View File

@ -0,0 +1,21 @@
.PHONY: build-x86 build-arm build-all
DOCKER_TAG ?= docker-duplicity-cron
default: build-x86
build-x86:
docker build -f ./Dockerfile.ubuntu -t $(DOCKER_TAG):ubuntu .
build-arm:
docker build -f ./Dockerfile.raspbian -t $(DOCKER_TAG):raspbian .
build-all: build-x86 build-arm
test-x86: build-x86
./test.sh $(DOCKER_TAG) ubuntu
test-arm: build-arm
./test.sh $(DOCKER_TAG) raspbian
test-all: test-x86 test-arm

View File

@ -25,7 +25,7 @@ if [ -n "$CRON_SCHEDULE" ]; then
echo "Backups scheduled as $CRON_SCHEDULE" echo "Backups scheduled as $CRON_SCHEDULE"
if [ -n "$VERIFY_CRON_SCHEDULE" ]; then if [ -n "$VERIFY_CRON_SCHEDULE" ]; then
echo "$VERIFY_CRON_SCHEDULE source /env.sh && duplicity verify $BACKUP_DEST $PATH_TO_BACKUP" >> /crontab.conf echo "$VERIFY_CRON_SCHEDULE source /env.sh && /verify.sh 2>> /cron.log" >> /crontab.conf
echo "Verify scheduled as $VERIFY_CRON_SCHEDULE" echo "Verify scheduled as $VERIFY_CRON_SCHEDULE"
fi fi

15
test.sh Executable file
View File

@ -0,0 +1,15 @@
#! /bin/bash
image_name=$1
tag=$2
full_image="${image_name}:${tag}"
container_name="${image_name}-${tag}"
docker run -d -e CRON_SCHEDULE="0 0 12 1 1 ? *" -e SKIP_ON_START=true --name $container_name $full_image
sleep 2
docker exec $container_name sh -c "mkdir -p /data && echo Test > /data/test.txt"
docker exec $container_name /backup.sh
docker exec $container_name /verify.sh
docker stop $container_name
docker rm $container_name

4
verify.sh Executable file
View File

@ -0,0 +1,4 @@
#! /bin/bash
set -e
duplicity verify $BACKUP_DEST $PATH_TO_BACKUP