Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ARG PG_VERSION=13.4
ARG VERSION=dev
FROM golang:1.16 as flyutil
ARG VERSION
WORKDIR /go/src/github.com/fly-examples/postgres-ha
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/flyadmin ./cmd/flyadmin
RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start ./cmd/start
FROM flyio/stolon:b6b9aaf as stolon
FROM wrouesnel/postgres_exporter:latest AS postgres_exporter
FROM postgres:${PG_VERSION}
ARG VERSION
ARG POSTGIS_MAJOR=3
LABEL fly.app_role=postgres_cluster
LABEL fly.version=${VERSION}
LABEL fly.pg-version=${PG_VERSION}
RUN apt-get update && apt-get install --no-install-recommends -y \
ca-certificates curl bash dnsutils vim-tiny procps jq haproxy \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR \
postgresql-$PG_MAJOR-postgis-$POSTGIS_MAJOR-scripts \
wget \
postgresql-common \
lsb-release \
&& apt autoremove -y
RUN sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
RUN sh -c "echo 'deb [signed-by=/usr/share/keyrings/timescale.keyring] https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main' > /etc/apt/sources.list.d/timescaledb.list"
RUN wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey 2>&1 | gpg --dearmor -o /usr/share/keyrings/timescale.keyring
RUN apt-get update && apt-get install --no-install-recommends -y \
timescaledb-2-postgresql-$PG_MAJOR \
timescaledb-tools
COPY --from=stolon /go/src/app/bin/* /usr/local/bin/
COPY --from=postgres_exporter /postgres_exporter /usr/local/bin/
ADD /scripts/* /fly/
ADD /config/* /fly/
RUN useradd -ms /bin/bash stolon
RUN mkdir -p /run/haproxy/
COPY --from=flyutil /fly/bin/* /usr/local/bin/
EXPOSE 5432
CMD ["start"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment