Skip to content

Commit 5a4ba5a

Browse files
committed
Add Postgres 17/TimescaleDB images
1 parent 31c3a48 commit 5a4ba5a

File tree

3 files changed

+232
-0
lines changed

3 files changed

+232
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,38 @@ jobs:
9191
tags: |
9292
flyio/postgres-flex-timescaledb:16
9393
flyio/postgres-flex-timescaledb:16.4
94+
95+
-
96+
name: Build and push Postgres 17
97+
id: docker_build_17
98+
uses: docker/build-push-action@v3
99+
with:
100+
build-args: |
101+
PG_VERSION=17.2
102+
PG_MAJOR_VERSION=17
103+
VERSION=${{ steps.get-latest-tag.outputs.tag }}
104+
context: .
105+
file: ./pg17/Dockerfile
106+
push: true
107+
tags: |
108+
flyio/postgres-flex:17
109+
flyio/postgres-flex:17.2
110+
-
111+
name: Build and push Postgres 17 Timescale DB
112+
id: docker_build_17_timescaledb
113+
uses: docker/build-push-action@v3
114+
with:
115+
build-args: |
116+
PG_VERSION=17.2
117+
PG_MAJOR_VERSION=17
118+
VERSION=${{ steps.get-latest-tag.outputs.tag }}
119+
context: .
120+
file: ./pg17/Dockerfile-timescaledb
121+
push: true
122+
tags: |
123+
flyio/postgres-flex-timescaledb:17
124+
flyio/postgres-flex-timescaledb:17.2
125+
94126
-
95127
name: Postgres 15 Image digest
96128
run: echo ${{ steps.docker_build_15.outputs.digest }}
@@ -103,4 +135,10 @@ jobs:
103135
-
104136
name: Postgres 16 TimescaleDB Image digest
105137
run: echo ${{ steps.docker_build_16_timescaledb.outputs.digest }}
138+
-
139+
name: Postgres 17 Image digest
140+
run: echo ${{ steps.docker_build_17.outputs.digest }}
141+
-
142+
name: Postgres 17 TimescaleDB Image digest
143+
run: echo ${{ steps.docker_build_17_timescaledb.outputs.digest }}
106144

pg17/Dockerfile

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
ARG PG_VERSION=17.2
2+
ARG PG_MAJOR_VERSION=17
3+
ARG VERSION=custom
4+
5+
FROM golang:1.20 AS builder
6+
7+
WORKDIR /go/src/github.com/fly-apps/fly-postgres
8+
COPY . .
9+
10+
RUN CGO_ENABLED=0 GOOS=linux \
11+
go build -v -o /fly/bin/event_handler ./cmd/event_handler && \
12+
go build -v -o /fly/bin/failover_validation ./cmd/failover_validation && \
13+
go build -v -o /fly/bin/pg_unregister ./cmd/pg_unregister && \
14+
go build -v -o /fly/bin/start_monitor ./cmd/monitor && \
15+
go build -v -o /fly/bin/start_admin_server ./cmd/admin_server && \
16+
go build -v -o /fly/bin/start ./cmd/start && \
17+
go build -v -o /fly/bin/flexctl ./cmd/flexctl
18+
19+
20+
COPY ./bin/* /fly/bin/
21+
22+
FROM ubuntu:24.04
23+
24+
ARG VERSION
25+
ARG PG_MAJOR_VERSION
26+
ARG POSTGIS_MAJOR=3
27+
ARG HAPROXY_VERSION=2.8
28+
29+
ENV PGDATA=/data/postgresql
30+
ENV PGPASSFILE=/data/.pgpass
31+
ENV AWS_SHARED_CREDENTIALS_FILE=/data/.aws/credentials
32+
ENV PG_MAJOR_VERSION=${PG_MAJOR_VERSION}
33+
ENV PATH="/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin:$PATH"
34+
35+
36+
LABEL fly.app_role=postgres_cluster
37+
LABEL fly.version=${VERSION}
38+
LABEL fly.pg-version=${PG_VERSION}
39+
LABEL fly.pg-manager=repmgr
40+
41+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
42+
RUN set -eux; \
43+
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
44+
# if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
45+
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
46+
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
47+
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
48+
fi; \
49+
apt-get update; apt-get install -y --no-install-recommends locales; rm -rf /var/lib/apt/lists/*; \
50+
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen; \
51+
locale-gen; \
52+
locale -a | grep 'en_US.utf8'
53+
ENV LANG en_US.utf8
54+
55+
RUN apt-get update && apt-get install --no-install-recommends -y \
56+
ca-certificates iproute2 curl bash dnsutils vim socat procps ssh gnupg rsync barman-cli barman barman-cli-cloud python3-setuptools cron gosu \
57+
&& apt autoremove -y && apt clean && \
58+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
59+
60+
# Install PostgreSQL
61+
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
62+
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
63+
apt-get update && apt-get install --no-install-recommends -y \
64+
postgresql-${PG_MAJOR_VERSION} \
65+
postgresql-client-${PG_MAJOR_VERSION} \
66+
postgresql-contrib-${PG_MAJOR_VERSION} \
67+
postgresql-${PG_MAJOR_VERSION}-repmgr
68+
69+
# PostGIS
70+
RUN apt-get update && apt-get install --no-install-recommends -y \
71+
postgresql-${PG_MAJOR_VERSION}-postgis-$POSTGIS_MAJOR \
72+
postgresql-${PG_MAJOR_VERSION}-postgis-$POSTGIS_MAJOR-scripts
73+
74+
# Haproxy
75+
RUN apt-get update && apt-get install --no-install-recommends -y \
76+
haproxy=$HAPROXY_VERSION.\* \
77+
&& apt autoremove -y && apt clean
78+
79+
# Copy Go binaries from the builder stage
80+
COPY --from=builder /fly/bin/* /usr/local/bin
81+
82+
# Copy Postgres exporter
83+
COPY --from=wrouesnel/postgres_exporter:latest /postgres_exporter /usr/local/bin/
84+
85+
# Move pg_rewind into path.
86+
RUN ln -s /usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_rewind /usr/bin/pg_rewind
87+
88+
ADD /config/* /fly/
89+
RUN mkdir -p /run/haproxy/
90+
RUN usermod -d /data postgres
91+
92+
EXPOSE 5432
93+
94+
CMD ["start"]

pg17/Dockerfile-timescaledb

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
ARG PG_VERSION=17.2
2+
ARG PG_MAJOR_VERSION=17
3+
ARG VERSION=custom
4+
5+
FROM golang:1.20 AS builder
6+
7+
WORKDIR /go/src/github.com/fly-apps/fly-postgres
8+
COPY . .
9+
10+
RUN CGO_ENABLED=0 GOOS=linux \
11+
go build -v -o /fly/bin/event_handler ./cmd/event_handler && \
12+
go build -v -o /fly/bin/failover_validation ./cmd/failover_validation && \
13+
go build -v -o /fly/bin/pg_unregister ./cmd/pg_unregister && \
14+
go build -v -o /fly/bin/start_monitor ./cmd/monitor && \
15+
go build -v -o /fly/bin/start_admin_server ./cmd/admin_server && \
16+
go build -v -o /fly/bin/start ./cmd/start && \
17+
go build -v -o /fly/bin/flexctl ./cmd/flexctl
18+
19+
20+
COPY ./bin/* /fly/bin/
21+
22+
FROM ubuntu:24.04
23+
24+
ARG VERSION
25+
ARG PG_MAJOR_VERSION
26+
ARG POSTGIS_MAJOR=3
27+
ARG HAPROXY_VERSION=2.8
28+
29+
ENV PGDATA=/data/postgresql
30+
ENV PGPASSFILE=/data/.pgpass
31+
ENV AWS_SHARED_CREDENTIALS_FILE=/data/.aws/credentials
32+
ENV PG_MAJOR_VERSION=${PG_MAJOR_VERSION}
33+
ENV PATH="/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin:$PATH"
34+
35+
LABEL fly.app_role=postgres_cluster
36+
LABEL fly.version=${VERSION}
37+
LABEL fly.pg-version=${PG_VERSION}
38+
LABEL fly.pg-manager=repmgr
39+
40+
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
41+
RUN set -eux; \
42+
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
43+
# if this file exists, we're likely in "debian:xxx-slim", and locales are thus being excluded so we need to remove that exclusion (since we need locales)
44+
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
45+
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
46+
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
47+
fi; \
48+
apt-get update; apt-get install -y --no-install-recommends locales; rm -rf /var/lib/apt/lists/*; \
49+
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen; \
50+
locale-gen; \
51+
locale -a | grep 'en_US.utf8'
52+
ENV LANG en_US.utf8
53+
54+
RUN apt-get update && apt-get install --no-install-recommends -y \
55+
ca-certificates iproute2 curl bash dnsutils vim socat procps ssh gnupg rsync barman-cli barman barman-cli-cloud python3-setuptools cron gosu \
56+
&& apt autoremove -y && apt clean && \
57+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
58+
59+
# Install PostgreSQL
60+
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
61+
echo "deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] http://apt.postgresql.org/pub/repos/apt/ noble-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \
62+
apt-get update && apt-get install --no-install-recommends -y \
63+
postgresql-${PG_MAJOR_VERSION} \
64+
postgresql-client-${PG_MAJOR_VERSION} \
65+
postgresql-contrib-${PG_MAJOR_VERSION} \
66+
postgresql-${PG_MAJOR_VERSION}-repmgr
67+
68+
# TimescaleDB and PostGIS
69+
RUN echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ jammy main" > /etc/apt/sources.list.d/timescaledb.list \
70+
&& curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
71+
72+
RUN apt-get update && apt-get install --no-install-recommends -y \
73+
postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR \
74+
postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR-scripts \
75+
timescaledb-2-postgresql-$PG_MAJOR_VERSION \
76+
&& apt autoremove -y && apt clean
77+
78+
# Haproxy
79+
RUN apt-get update && apt-get install --no-install-recommends -y \
80+
haproxy=$HAPROXY_VERSION.\* \
81+
&& apt autoremove -y && apt clean
82+
83+
# Copy Go binaries from the builder stage
84+
COPY --from=builder /fly/bin/* /usr/local/bin
85+
86+
# Copy Postgres exporter
87+
COPY --from=wrouesnel/postgres_exporter:latest /postgres_exporter /usr/local/bin/
88+
89+
# Move pg_rewind into path.
90+
RUN ln -s /usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_rewind /usr/bin/pg_rewind
91+
92+
ADD /config/* /fly/
93+
RUN mkdir -p /run/haproxy/
94+
RUN usermod -d /data postgres
95+
96+
ENV TIMESCALEDB_ENABLED=true
97+
98+
EXPOSE 5432
99+
100+
CMD ["start"]

0 commit comments

Comments
 (0)