forked from fly-apps/postgres-flex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-timescaledb
81 lines (59 loc) · 2.87 KB
/
Dockerfile-timescaledb
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
ARG PG_VERSION=15.6
ARG PG_MAJOR_VERSION=15
ARG VERSION=custom
FROM golang:1.20
WORKDIR /go/src/github.com/fly-apps/fly-postgres
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/event_handler ./cmd/event_handler
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/failover_validation ./cmd/failover_validation
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/pg_unregister ./cmd/pg_unregister
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start_monitor ./cmd/monitor
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start_admin_server ./cmd/admin_server
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start ./cmd/start
COPY ./bin/* /fly/bin/
FROM wrouesnel/postgres_exporter:latest AS postgres_exporter
FROM postgres:${PG_VERSION}
ENV PGDATA=/data/postgresql
ENV PGPASSFILE=/data/.pgpass
ARG VERSION
ARG PG_MAJOR_VERSION
ARG POSTGIS_MAJOR=3
ARG HAPROXY_VERSION=2.8
LABEL fly.app_role=postgres_cluster
LABEL fly.version=${VERSION}
LABEL fly.pg-version=${PG_VERSION}
LABEL fly.pg-manager=repmgr
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates iproute2 curl bash dnsutils vim haproxy socat procps ssh gnupg rsync barman-cli barman barman-cli-cloud cron \
&& apt autoremove -y
# Repmgr
RUN curl -L https://launchpad.net/ubuntu/+archive/primary/+files/postgresql-${PG_MAJOR_VERSION}-repmgr_5.3.3-2_amd64.deb -o postgresql-${PG_MAJOR_VERSION}-repmgr_5.3.3-2_amd64.deb
RUN apt-get update && \
apt-get install -y ./postgresql-${PG_MAJOR_VERSION}-repmgr_5.3.3-2_amd64.deb \
&& rm ./postgresql-${PG_MAJOR_VERSION}-repmgr_5.3.3-2_amd64.deb
RUN echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(cat /etc/os-release | grep VERSION_CODENAME | cut -d'=' -f2) main" > /etc/apt/sources.list.d/timescaledb.list \
&& curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
# TimescaleDB and PostGIS
RUN apt-get update && apt-get install --no-install-recommends -y \
postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR \
postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR-scripts \
timescaledb-2-postgresql-$PG_MAJOR_VERSION \
timescaledb-toolkit-postgresql-$PG_MAJOR_VERSION \
&& apt autoremove -y
# Haproxy
RUN curl https://haproxy.debian.net/bernat.debian.org.gpg \
| gpg --dearmor > /usr/share/keyrings/haproxy.debian.net.gpg
RUN echo deb "[signed-by=/usr/share/keyrings/haproxy.debian.net.gpg]" \
http://haproxy.debian.net bookworm-backports-${HAPROXY_VERSION} main \
> /etc/apt/sources.list.d/haproxy.list
RUN apt-get update && apt-get install --no-install-recommends -y \
haproxy=$HAPROXY_VERSION.\* \
&& apt autoremove -y
COPY --from=0 /fly/bin/* /usr/local/bin
COPY --from=postgres_exporter /postgres_exporter /usr/local/bin/
ADD /config/* /fly/
RUN mkdir -p /run/haproxy/
RUN usermod -d /data postgres
ENV TIMESCALEDB_ENABLED=true
EXPOSE 5432
CMD ["start"]