|
| 1 | +ARG PG_VERSION=15.1 |
| 2 | +ARG PG_MAJOR_VERSION=15 |
| 3 | +ARG VERSION=custom |
| 4 | + |
| 5 | +FROM golang:1.19 as flyutil |
| 6 | + |
| 7 | +WORKDIR /go/src/github.com/fly-examples/fly-postgres |
| 8 | +COPY . . |
| 9 | + |
| 10 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/event_handler ./cmd/event_handler |
| 11 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/failover_validation ./cmd/failover_validation |
| 12 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/pg_unregister ./cmd/pg_unregister |
| 13 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start_monitor ./cmd/monitor |
| 14 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start_admin_server ./cmd/admin_server |
| 15 | +RUN CGO_ENABLED=0 GOOS=linux go build -v -o /fly/bin/start ./cmd/start |
| 16 | + |
| 17 | +COPY ./bin/* /fly/bin/ |
| 18 | + |
| 19 | +FROM wrouesnel/postgres_exporter:latest AS postgres_exporter |
| 20 | + |
| 21 | +FROM postgres:${PG_VERSION} |
| 22 | +ENV PGDATA=/data/postgresql |
| 23 | +ARG VERSION |
| 24 | +ARG PG_MAJOR_VERSION |
| 25 | +ARG POSTGIS_MAJOR=3 |
| 26 | + |
| 27 | + |
| 28 | +LABEL fly.app_role=postgres_cluster |
| 29 | +LABEL fly.version=${VERSION} |
| 30 | +LABEL fly.pg-version=${PG_VERSION} |
| 31 | +LABEL fly.pg-manager=repmgr |
| 32 | + |
| 33 | +RUN apt-get update && apt-get install --no-install-recommends -y \ |
| 34 | + ca-certificates iproute2 postgresql-$PG_MAJOR_VERSION-repmgr curl bash dnsutils vim procps jq pgbouncer ssh \ |
| 35 | + && apt autoremove -y |
| 36 | + |
| 37 | +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 \ |
| 38 | + && curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add - |
| 39 | + |
| 40 | +RUN apt-get update && apt-get install --no-install-recommends -y \ |
| 41 | + postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR \ |
| 42 | + postgresql-$PG_MAJOR_VERSION-postgis-$POSTGIS_MAJOR-scripts \ |
| 43 | + timescaledb-2-postgresql-$PG_MAJOR_VERSION \ |
| 44 | + timescaledb-toolkit-postgresql-$PG_MAJOR_VERSION \ |
| 45 | + && apt autoremove -y |
| 46 | + |
| 47 | +COPY --from=0 /fly/bin/* /usr/local/bin |
| 48 | +COPY --from=postgres_exporter /postgres_exporter /usr/local/bin/ |
| 49 | + |
| 50 | +ADD /config/* /fly/ |
| 51 | + |
| 52 | +RUN mkdir -p /run/haproxy/ |
| 53 | +RUN usermod -d /data postgres |
| 54 | + |
| 55 | +ENV TIMESCALEDB_ENABLED=true |
| 56 | + |
| 57 | +EXPOSE 5432 |
| 58 | + |
| 59 | + |
| 60 | +CMD ["start"] |
0 commit comments