Skip to content

Instantly share code, notes, and snippets.

@RagingSeabass
Created November 22, 2021 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RagingSeabass/a19d5971cc16092576c030a9ab7e073d to your computer and use it in GitHub Desktop.
Save RagingSeabass/a19d5971cc16092576c030a9ab7e073d to your computer and use it in GitHub Desktop.
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