-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (59 loc) · 2.49 KB
/
Dockerfile
File metadata and controls
77 lines (59 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
FROM debian:stretch
RUN apt-get update &&\
apt-get install -y wget gnupg2 apt-utils curl
COPY *.asc /tmp/
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" >> /etc/apt/sources.list.d/pgdg.list &&\
cat /tmp/*.asc | apt-key add - &&\
apt-cache search postgresql-9.6 &&\
apt-get update &&\
apt-get install -y postgresql-9.6
ENV PATH $PATH:/usr/lib/postgresql/9.6/bin
ENV PGDATA /var/lib/postgresql/9.6/application
# ADD debezium
ENV PLUGIN_VERSION=v0.6.1
ENV WAL2JSON_COMMIT_ID=645ab69aae268a81c900671b5dfab7029384e9ff
# Install the packages which will be required to get everything to compile
RUN apt-get update \
&& apt-get install -f -y --no-install-recommends \
software-properties-common \
build-essential \
pkg-config \
git \
postgresql-server-dev-9.6 \
libproj-dev \
&& apt-get clean && apt-get update && apt-get install -f -y --no-install-recommends \
liblwgeom-dev \
&& add-apt-repository "deb http://ftp.debian.org/debian testing main contrib" \
&& apt-get update && apt-get install -f -y --no-install-recommends \
libprotobuf-c-dev=1.2.* \
&& rm -rf /var/lib/apt/lists/*
# Compile the plugin from sources and install it
RUN git clone https://github.com/debezium/postgres-decoderbufs -b $PLUGIN_VERSION --single-branch \
&& cd /postgres-decoderbufs \
&& make && make install \
&& cd / \
&& rm -rf postgres-decoderbufs
RUN git clone https://github.com/eulerto/wal2json -b master --single-branch \
&& cd /wal2json \
&& git checkout $WAL2JSON_COMMIT_ID \
&& make && make install \
&& cd / \
&& rm -rf wal2json
RUN cat /etc/postgresql/9.6/main/pg_hba.conf
USER postgres
RUN /usr/lib/postgresql/9.6/bin/initdb -D $PGDATA -E UTF8
RUN cat $PGDATA/postgresql.conf
COPY config/postgresql.conf $PGDATA/postgresql.conf
COPY config/pg_hba.conf $PGDATA/pg_hba.conf
RUN echo "preinit" > /tmp/build.log &&\
pg_ctl start -D $PGDATA -l /tmp/build.log &&\
sleep 3 &&\
createuser app_user &&\
psql -c "CREATE ROLE replication_user REPLICATION LOGIN;" &&\
psql -c "ALTER USER app_user WITH PASSWORD 'app_user_pwd'" &&\
psql -c "ALTER USER replication_user WITH PASSWORD 'replication_user_pwd'" &&\
createdb -E UTF8 -T template0 app_db &&\
psql -c "GRANT ALL PRIVILEGES ON DATABASE app_db to app_user" &&\
psql -c "GRANT ALL ON DATABASE app_db to replication_user" &&\
pg_ctl stop
CMD /usr/lib/postgresql/9.6/bin/postgres -D $PGDATA