-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
52 lines (40 loc) · 1.55 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
FROM golang:1.20-alpine AS builder
ENV WALG_VERSION=v1.1
ENV _build_deps="wget cmake git build-base bash"
RUN set -ex \
&& apk add --no-cache $_build_deps \
&& git clone https://github.com/wal-g/wal-g/ $GOPATH/src/wal-g \
&& cd $GOPATH/src/wal-g/ \
&& git checkout $WALG_VERSION \
&& make install \
&& make deps \
&& make pg_build \
&& install main/pg/wal-g / \
&& /wal-g --help
FROM postgres:14.12-alpine3.18
RUN apk add --update iputils htop curl busybox-suid jq \
&& curl -sOL https://cronitor.io/dl/linux_amd64.tar.gz \
&& tar xvf linux_amd64.tar.gz -C /usr/bin/ \
&& apk upgrade
# Copy compiled wal-g binary from builder
COPY --from=builder /wal-g /usr/local/bin
# Add replication and WAL-G backup scripts
RUN mkdir -p /usr/local/scripts
COPY scripts/setup-master.sh /docker-entrypoint-initdb.d/
COPY scripts/setup-slave.sh /docker-entrypoint-initdb.d/
RUN chown -R root:postgres /docker-entrypoint-initdb.d/
RUN chmod -R 775 /docker-entrypoint-initdb.d
# Add WAL-G backup script
COPY scripts/walg_caller.sh /usr/local/scripts/
COPY scripts/base_backup.sh /usr/local/scripts/
RUN chown -R root:postgres /usr/local/scripts
RUN chmod -R 775 /usr/local/scripts
# Add custom entrypoint
COPY scripts/entrypoint.sh /
RUN chmod +x /entrypoint.sh
# Add cron permissions to postgres user
RUN chown -R root:postgres /etc/crontabs/root
RUN chmod g+rw /etc/crontabs/root
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
CMD ["postgres"]
VOLUME ["/var/run/postgresql", "/usr/share/postgresql/", "/var/lib/postgresql/data", "/tmp"]