Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: fly-apps/postgres-flex
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.0.63
Choose a base ref
...
head repository: fly-apps/postgres-flex
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 8 files changed
  • 1 contributor

Commits on Jan 23, 2025

  1. Works to bump PG 15 and PG 16 to the latest patch version (15.10 and …

    …16.6) (#270)
    davissp14 authored Jan 23, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bb46120 View commit details

Commits on Feb 6, 2025

  1. Move to bufio reader to support larger tokens (#273)

    * Move to bufio reader to support larger tokens
    
    * Cleanup
    
    * Only write non-empty lines
    davissp14 authored Feb 6, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5a04d2b View commit details

Commits on Feb 13, 2025

  1. PG17 release (#277)

    davissp14 authored Feb 13, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    3f253f2 View commit details
Showing with 270 additions and 24 deletions.
  1. +45 −9 .github/workflows/ci.yaml
  2. +23 −11 internal/supervisor/output.go
  3. +1 −1 pg15/Dockerfile
  4. +1 −1 pg15/Dockerfile-timescaledb
  5. +1 −1 pg16/Dockerfile
  6. +1 −1 pg16/Dockerfile-timescaledb
  7. +96 −0 pg17/Dockerfile
  8. +102 −0 pg17/Dockerfile-timescaledb
54 changes: 45 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -36,61 +36,92 @@ jobs:
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=15.8
PG_VERSION=15.10
PG_MAJOR_VERSION=15
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg15/Dockerfile
push: true
tags: |
flyio/postgres-flex:15
flyio/postgres-flex:15.8
flyio/postgres-flex:15.10
-
name: Build and push Postgres 15 Timescale DB
id: docker_build_15_timescaledb
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=15.8
PG_VERSION=15.10
PG_MAJOR_VERSION=15
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg15/Dockerfile-timescaledb
push: true
tags: |
flyio/postgres-flex-timescaledb:15
flyio/postgres-flex-timescaledb:15.8
flyio/postgres-flex-timescaledb:15.10
-
name: Build and push Postgres 16
id: docker_build_16
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=16.4
PG_VERSION=16.6
PG_MAJOR_VERSION=16
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg16/Dockerfile
push: true
tags: |
flyio/postgres-flex:16
flyio/postgres-flex:16.4
flyio/postgres-flex:16.6
-
name: Build and push Postgres 16 Timescale DB
id: docker_build_16_timescaledb
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=16.4
PG_VERSION=16.6
PG_MAJOR_VERSION=16
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg16/Dockerfile-timescaledb
push: true
tags: |
flyio/postgres-flex-timescaledb:16
flyio/postgres-flex-timescaledb:16.4
flyio/postgres-flex-timescaledb:16.6
-
name: Build and push Postgres 17
id: docker_build_17
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=17.2
PG_MAJOR_VERSION=17
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg17/Dockerfile
push: true
tags: |
flyio/postgres-flex:17
flyio/postgres-flex:17.2
-
name: Build and push Postgres 17 Timescale DB
id: docker_build_17_timescaledb
uses: docker/build-push-action@v3
with:
build-args: |
PG_VERSION=17.2
PG_MAJOR_VERSION=17
VERSION=${{ steps.get-latest-tag.outputs.tag }}
context: .
file: ./pg17/Dockerfile-timescaledb
push: true
tags: |
flyio/postgres-flex-timescaledb:17
flyio/postgres-flex-timescaledb:17.2
-
name: Postgres 15 Image digest
run: echo ${{ steps.docker_build_15.outputs.digest }}
@@ -103,4 +134,9 @@ jobs:
-
name: Postgres 16 TimescaleDB Image digest
run: echo ${{ steps.docker_build_16_timescaledb.outputs.digest }}

-
name: Postgres 17 Image digest
run: echo ${{ steps.docker_build_17.outputs.digest }}
-
name: Postgres 17 TimescaleDB Image digest
run: echo ${{ steps.docker_build_17_timescaledb.outputs.digest }}
34 changes: 23 additions & 11 deletions internal/supervisor/output.go
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"fmt"
"io"
"log"
"os"
"sync"
@@ -54,21 +55,23 @@ func (m *multiOutput) PipeOutput(proc *process) {
pipe := m.openPipe(proc)

go func(proc *process, pipe *ptyPipe) {
scanner := bufio.NewScanner(pipe.pty)

for scanner.Scan() {
m.WriteLine(proc, scanner.Bytes())
reader := bufio.NewReader(pipe.pty)
for {
line, err := reader.ReadBytes('\n')
// Only write non-empty lines.
if len(line) > 0 {
m.WriteLine(proc, line)
}
if err != nil {
if err != io.EOF {
log.Printf("reader error: %v", err)
}
break
}
}
}(proc, pipe)
}

func (m *multiOutput) ClosePipe(proc *process) {
if pipe := m.pipes[proc]; pipe != nil {
_ = pipe.pty.Close()
_ = pipe.tty.Close()
}
}

func (m *multiOutput) WriteLine(proc *process, p []byte) {
var buf bytes.Buffer

@@ -83,6 +86,8 @@ func (m *multiOutput) WriteLine(proc *process, p []byte) {

buf.WriteString("\033[0m | ")

// remove trailing newline if present.
p = bytes.TrimSuffix(p, []byte("\n"))
buf.Write(p)
buf.WriteByte('\n')

@@ -95,6 +100,13 @@ func (m *multiOutput) WriteLine(proc *process, p []byte) {
}
}

func (m *multiOutput) ClosePipe(proc *process) {
if pipe := m.pipes[proc]; pipe != nil {
_ = pipe.pty.Close()
_ = pipe.tty.Close()
}
}

func (m *multiOutput) WriteErr(proc *process, err error) {
m.WriteLine(proc, []byte(
fmt.Sprintf("\033[0;31m%v\033[0m", err),
2 changes: 1 addition & 1 deletion pg15/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PG_VERSION=15.8
ARG PG_VERSION=15.10
ARG PG_MAJOR_VERSION=15
ARG VERSION=custom

2 changes: 1 addition & 1 deletion pg15/Dockerfile-timescaledb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PG_VERSION=15.8
ARG PG_VERSION=15.10
ARG PG_MAJOR_VERSION=15
ARG VERSION=custom

2 changes: 1 addition & 1 deletion pg16/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PG_VERSION=16.4
ARG PG_VERSION=16.6
ARG PG_MAJOR_VERSION=16
ARG VERSION=custom

2 changes: 1 addition & 1 deletion pg16/Dockerfile-timescaledb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG PG_VERSION=16.4
ARG PG_VERSION=16.6
ARG PG_MAJOR_VERSION=16
ARG VERSION=custom

96 changes: 96 additions & 0 deletions pg17/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
ARG PG_VERSION=17.2
ARG PG_MAJOR_VERSION=17
ARG VERSION=custom

FROM golang:1.23 AS builder

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 && \
go build -v -o /fly/bin/failover_validation ./cmd/failover_validation && \
go build -v -o /fly/bin/pg_unregister ./cmd/pg_unregister && \
go build -v -o /fly/bin/start_monitor ./cmd/monitor && \
go build -v -o /fly/bin/start_admin_server ./cmd/admin_server && \
go build -v -o /fly/bin/start ./cmd/start && \
go build -v -o /fly/bin/flexctl ./cmd/flexctl


COPY ./bin/* /fly/bin/

FROM ubuntu:24.04

ARG VERSION
ARG PG_MAJOR_VERSION
ARG PG_VERSION
ARG POSTGIS_MAJOR=3
ARG HAPROXY_VERSION=2.8
ARG REPMGR_VERSION=5.5.0+debpgdg-1.pgdg24.04+1

ENV PGDATA=/data/postgresql
ENV PGPASSFILE=/data/.pgpass
ENV AWS_SHARED_CREDENTIALS_FILE=/data/.aws/credentials
ENV PG_MAJOR_VERSION=${PG_MAJOR_VERSION}
ENV PATH="/usr/lib/postgresql/${PG_MAJOR_VERSION}/bin:$PATH"


LABEL fly.app_role=postgres_cluster
LABEL fly.version=${VERSION}
LABEL fly.pg-version=${PG_VERSION}
LABEL fly.pg-manager=repmgr

# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
RUN set -eux; \
if [ -f /etc/dpkg/dpkg.cfg.d/docker ]; then \
# 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)
grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
sed -ri '/\/usr\/share\/locale/d' /etc/dpkg/dpkg.cfg.d/docker; \
! grep -q '/usr/share/locale' /etc/dpkg/dpkg.cfg.d/docker; \
fi; \
apt-get update; apt-get install -y --no-install-recommends locales; rm -rf /var/lib/apt/lists/*; \
echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen; \
locale-gen; \
locale -a | grep 'en_US.utf8'
ENV LANG en_US.utf8

RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates iproute2 curl bash dnsutils vim socat procps ssh gnupg rsync barman-cli barman barman-cli-cloud python3-setuptools cron gosu \
&& apt autoremove -y && apt clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install PostgreSQL
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg && \
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 && \
apt-get update && apt-get install --no-install-recommends -y \
postgresql-${PG_MAJOR_VERSION} \
postgresql-client-${PG_MAJOR_VERSION} \
postgresql-contrib-${PG_MAJOR_VERSION} \
postgresql-${PG_MAJOR_VERSION}-repmgr=${REPMGR_VERSION}

# 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

# Haproxy
RUN apt-get update && apt-get install --no-install-recommends -y \
haproxy=$HAPROXY_VERSION.\* \
&& apt autoremove -y && apt clean

# Copy Go binaries from the builder stage
COPY --from=builder /fly/bin/* /usr/local/bin

# Copy Postgres exporter
COPY --from=wrouesnel/postgres_exporter:latest /postgres_exporter /usr/local/bin/

# Move pg_rewind into path.
RUN ln -s /usr/lib/postgresql/${PG_MAJOR_VERSION}/bin/pg_rewind /usr/bin/pg_rewind

ADD /config/* /fly/
RUN mkdir -p /run/haproxy/
RUN usermod -d /data postgres

EXPOSE 5432

CMD ["start"]
Loading