forked from paunin/PostDock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarman-2.3.part.Dockerfile
71 lines (58 loc) · 2.83 KB
/
Barman-2.3.part.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
FROM golang:1.8-jessie
# grab gosu for easy step-down from root
ARG GOSU_VERSION=1.7
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN wget -q https://www.postgresql.org/media/keys/ACCC4CF8.asc -O - | apt-key add - && \
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' && \
apt-get update && \
apt-get install -y libffi-dev libssl-dev openssh-server
{{ #PG_CLIENT_LATEST }}
RUN apt-get install -y postgresql-client-{{ PG_CLIENT_VERSION }}={{ PG_CLIENT_PACKAGE_VERSION }}\*
{{ /PG_CLIENT_LATEST }}{{ ^PG_CLIENT_LATEST }}
RUN TEMP_DEB="$(mktemp)" && \
wget -O "$TEMP_DEB" "http://atalia.postgresql.org/morgue/p/postgresql-{{ PG_CLIENT_VERSION }}/postgresql-client-{{ PG_CLIENT_VERSION }}_{{ PG_CLIENT_PACKAGE_VERSION }}_amd64.deb" && \
(dpkg -i "$TEMP_DEB" || apt-get install -y -f) && rm -f "$TEMP_DEB"
{{ /PG_CLIENT_LATEST }}
RUN apt-get install -y barman={{ BARMAN_PACKAGE_VERSION }}
RUN apt-get -y install cron
ADD barman/crontab /etc/cron.d/barman
RUN rm -f /etc/cron.daily/*
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres -d /home/postgres --uid=999 postgres
ENV UPSTREAM_NAME pg_cluster
ENV UPSTREAM_CONFIG_FILE /etc/barman.d/upstream.conf
ENV REPLICATION_USER replication_user
ENV REPLICATION_PASSWORD replication_pass
ENV REPLICATION_PORT 5432
ENV POSTGRES_CONNECTION_TIMEOUT 20
ENV REPLICATION_SLOT_NAME barman_the_backupper
ENV WAIT_UPSTREAM_TIMEOUT 60
ENV SSH_ENABLE 0
ENV NOTVISIBLE "in users profile"
ENV BACKUP_SCHEDULE "0 0 * * *"
ENV BACKUP_RETENTION_DAYS "30"
ENV BACKUP_DIR /var/backups
# REQUIRED ENV VARS:
# ENV REPLICATION_HOST localhost
# ENV POSTGRES_USER postgres
# ENV POSTGRES_PASSWORD password
# ENV POSTGRES_DB monkey_db
EXPOSE 22
COPY ./ssh /home/postgres/.ssh
RUN chown -R postgres:postgres /home/postgres
COPY ./barman/configs/barman.conf /etc/barman.conf
COPY ./barman/configs/upstream.conf $UPSTREAM_CONFIG_FILE
COPY ./barman/bin /usr/local/bin/barman_docker
RUN chmod +x /usr/local/bin/barman_docker/* && ls /usr/local/bin/barman_docker
COPY ./barman/metrics /go
RUN cd /go && go build /go/main.go
VOLUME $BACKUP_DIR
CMD /usr/local/bin/barman_docker/entrypoint.sh