Refactor stolon Dockerfile
This commit is contained in:
parent
4d7470b2fd
commit
4f296808e8
3 changed files with 12 additions and 43 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
Reference in a new issue