diff --git a/app/docker-compose.yml b/app/docker-compose.yml index 123c99d..a44e932 100644 --- a/app/docker-compose.yml +++ b/app/docker-compose.yml @@ -94,7 +94,7 @@ services: build: args: # https://github.com/sorintlab/stolon/releases - STOLON_VERSION: v0.16.0 + STOLON_VERSION: 2d0b8e516a4eaec01f3a9509cdc50a1d4ce8709c # https://packages.debian.org/fr/stretch/postgresql-all PG_VERSION: 9.6+181+deb9u3 context: ./postgres/build/postgres diff --git a/app/postgres/build/postgres/Dockerfile b/app/postgres/build/postgres/Dockerfile index 23243aa..5217bc5 100644 --- a/app/postgres/build/postgres/Dockerfile +++ b/app/postgres/build/postgres/Dockerfile @@ -1,25 +1,16 @@ -FROM amd64/debian:stretch +FROM golang:1.13-buster AS builder ARG STOLON_VERSION +WORKDIR /stolon +RUN git clone https://github.com/sorintlab/stolon . +RUN git pull && git checkout ${STOLON_VERSION} +RUN go mod download +RUN make && chmod +x /stolon/bin/* + +FROM amd64/debian:stretch ARG PG_VERSION - -RUN echo "deb http://deb.debian.org/debian stretch-backports main contrib non-free # available after stretch release" > /etc/apt/sources.list.d/stretch-backports.list && \ - apt-get update && \ - apt-get -qq -y full-upgrade && \ - apt-get install -y \ - postgresql-all=${PG_VERSION} \ - golang-1.11 \ - git && \ - export GOPATH=/usr/local/go && \ - mkdir -p /usr/local/go/src/github.com/sorintlab && \ - cd /usr/local/go/src/github.com/sorintlab && \ - git clone --depth 1 --branch ${STOLON_VERSION} https://github.com/sorintlab/stolon && \ - ln -s /usr/lib/go-1.11/bin/go /usr/bin/go && \ - ln -s /usr/lib/go-1.11/bin/gofmt /usr/bin/gofmt && \ - cd ./stolon && \ - ./build && \ - mv /usr/local/go/src/github.com/sorintlab/stolon/bin/* /usr/local/bin/ && \ - rm -rf /usr/local/go - +RUN apt-get update && \ + apt-get install -y postgresql-all=${PG_VERSION} +COPY --from=builder /stolon/bin /usr/local/bin USER postgres diff --git a/app/postgres/build/postgres/start.sh b/app/postgres/build/postgres/start.sh deleted file mode 100755 index f1d493f..0000000 --- a/app/postgres/build/postgres/start.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -if [ -f /local/pg_hba.conf ]; then - echo "Copying Nomad configuration..." - cp /local/pg_hba.conf /etc/postgresql/9.6/main/ - echo "Done" -fi - - -if [ -z "$(ls -A /var/lib/postgresql/9.6/main)" ]; then - echo "Copying base" - cp -r /var/lib/postgresql/9.6/base/* /var/lib/postgresql/9.6/main - echo "Done" -fi - -chmod -R 700 /var/lib/postgresql/9.6/main -chown -R postgres /var/lib/postgresql/9.6/main - -echo "Starting postgres..." -. /usr/share/postgresql-common/init.d-functions -start 9.6 -tail -f /var/log/postgresql/postgresql-9.6-main.log