forked from Tecnativa/docker-duplicity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
132 lines (112 loc) · 4.4 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
FROM python:2-alpine AS latest
ARG DUPLICITY_VERSION=0.8.04
ENV CRONTAB_15MIN='*/15 * * * *' \
CRONTAB_HOURLY='0 * * * *' \
CRONTAB_DAILY='0 2 * * MON-SAT' \
CRONTAB_WEEKLY='0 1 * * SUN' \
CRONTAB_MONTHLY='0 5 1 * *' \
DST='' \
EMAIL_FROM='' \
EMAIL_SUBJECT='Backup report: {hostname} - {periodicity} - {result}' \
EMAIL_TO='' \
JOB_300_WHAT='backup' \
JOB_300_WHEN='daily' \
OPTIONS='' \
OPTIONS_EXTRA='--metadata-sync-mode partial' \
SMTP_HOST='smtp' \
SMTP_PASS='' \
SMTP_PORT='25' \
SMTP_TLS='' \
SMTP_USER='' \
SRC='/mnt/backup/src'
ENTRYPOINT [ "/usr/local/bin/entrypoint" ]
CMD ["/usr/sbin/crond", "-fd8"]
# Link the job runner in all periodicities available
RUN ln -s /usr/local/bin/jobrunner /etc/periodic/15min/jobrunner
RUN ln -s /usr/local/bin/jobrunner /etc/periodic/hourly/jobrunner
RUN ln -s /usr/local/bin/jobrunner /etc/periodic/daily/jobrunner
RUN ln -s /usr/local/bin/jobrunner /etc/periodic/weekly/jobrunner
RUN ln -s /usr/local/bin/jobrunner /etc/periodic/monthly/jobrunner
# Runtime dependencies and database clients
RUN apk add --no-cache \
ca-certificates \
dbus \
gnupg \
krb5-libs \
lftp \
libffi \
librsync \
ncftp \
openssh \
openssl \
rsync \
py2-gobject3 \
tzdata \
&& sync
# Default backup source directory
RUN mkdir -p "$SRC"
# Preserve cache among containers
VOLUME [ "/root" ]
# Build dependencies
RUN apk add --no-cache --virtual .build \
build-base \
krb5-dev \
libffi-dev \
librsync-dev \
libxml2-dev \
libxslt-dev \
openssl-dev \
# Runtime dependencies, based on https://bazaar.launchpad.net/~duplicity-team/duplicity/0.8-series/view/head:/requirements.txt
&& pip install --no-cache-dir \
# Basic dependencies
fasteners \
future \
mock \
requests \
urllib3 \
# Backend libraries
azure \
b2 \
b2sdk \
boto \
dropbox==6.9.0 \
gdata \
jottalib \
mediafire \
paramiko \
pydrive \
python-swiftclient \
requests_oauthlib \
# Duplicity from source code
https://launchpad.net/duplicity/$(echo $DUPLICITY_VERSION | sed -r 's/^([0-9]+\.[0-9]+)([0-9\.]*)$/\1/')-series/$DUPLICITY_VERSION/+download/duplicity-$DUPLICITY_VERSION.tar.gz \
&& apk del .build
COPY bin/* /usr/local/bin/
RUN chmod a+rx /usr/local/bin/* && sync
# Metadata
ARG VCS_REF
ARG BUILD_DATE
LABEL org.label-schema.schema-version="1.0" \
org.label-schema.vendor=Tecnativa \
org.label-schema.license=Apache-2.0 \
org.label-schema.build-date="$BUILD_DATE" \
org.label-schema.vcs-ref="$VCS_REF" \
org.label-schema.vcs-url="https://github.com/Tecnativa/docker-duplicity"
FROM latest AS latest-s3
ENV JOB_500_WHAT='dup full $SRC $DST' \
JOB_500_WHEN='weekly' \
OPTIONS_EXTRA='--metadata-sync-mode partial --full-if-older-than 1W --file-prefix-archive archive-$(hostname -f)- --file-prefix-manifest manifest-$(hostname -f)- --file-prefix-signature signature-$(hostname -f)- --s3-european-buckets --s3-multipart-chunk-size 10 --s3-use-new-style'
FROM latest AS docker
RUN apk add --no-cache docker
FROM docker AS docker-s3
ENV JOB_500_WHAT='dup full $SRC $DST' \
JOB_500_WHEN='weekly' \
OPTIONS_EXTRA='--metadata-sync-mode partial --full-if-older-than 1W --file-prefix-archive archive-$(hostname -f)- --file-prefix-manifest manifest-$(hostname -f)- --file-prefix-signature signature-$(hostname -f)- --s3-european-buckets --s3-multipart-chunk-size 10 --s3-use-new-style'
FROM latest AS postgres
RUN apk add --no-cache postgresql --repository http://dl-cdn.alpinelinux.org/alpine/v3.9/main
ENV JOB_200_WHAT psql -0Atd postgres -c \"SELECT datname FROM pg_database WHERE NOT datistemplate AND datname != \'postgres\'\" | xargs -0tI DB pg_dump --dbname DB --no-owner --no-privileges --file \"\$SRC/DB.sql\"
ENV JOB_200_WHEN='daily weekly' \
PGHOST=db
FROM postgres AS postgres-s3
ENV JOB_500_WHAT='dup full $SRC $DST' \
JOB_500_WHEN='weekly' \
OPTIONS_EXTRA='--metadata-sync-mode partial --full-if-older-than 1W --file-prefix-archive archive-$(hostname -f)- --file-prefix-manifest manifest-$(hostname -f)- --file-prefix-signature signature-$(hostname -f)- --s3-european-buckets --s3-multipart-chunk-size 10 --s3-use-new-style'