Skip to content

Commit e8cdd30

Browse files
committed
Change the way to build containers
1 parent 9b2e24b commit e8cdd30

File tree

6 files changed

+71
-137
lines changed

6 files changed

+71
-137
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.git
33
.vscode
44
*.yml
5-
*/*/*.yml
5+
*/*/*.yml
6+
Dockerfile

Dockerfile

Lines changed: 9 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,19 @@
1-
# vim:set ft=dockerfile:
2-
FROM debian:jessie
1+
FROM alpine:latest
32

4-
# explicitly set user/group IDs
5-
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
3+
RUN apk add --update gcc libc-dev bison flex readline-dev zlib-dev perl make
64

7-
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
8-
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
9-
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
10-
ENV LANG en_US.utf8
5+
# there is already accidental postgres user in alpine, so call ours pg =/
6+
# RUN addgroup pg && adduser -h /pg -D -G pg pg
7+
RUN mkdir /pg && chown postgres:postgres pg
118

12-
# postgres build deps
13-
RUN apt-get update && apt-get install -y \
14-
git \
15-
make \
16-
gcc \
17-
gdb \
18-
libreadline-dev \
19-
bison \
20-
flex \
21-
zlib1g-dev \
22-
sudo \
23-
&& rm -rf /var/lib/apt/lists/*
9+
USER postgres
2410

25-
RUN mkdir /pg && chown postgres:postgres /pg
26-
# We need that to allow editing of /proc/sys/kernel/core_pattern
27-
# from docker-entrypoint.sh
28-
RUN echo "postgres ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
11+
ENV LANG en_US.utf8
12+
ENV CFLAGS -O0
13+
ENV PATH /pg/install/bin:$PATH
2914

3015
COPY ./ /pg/src
31-
RUN chown -R postgres:postgres /pg/src
32-
33-
USER postgres
34-
ENV CFLAGS -O0
35-
WORKDIR /pg
3616

3717
RUN cd /pg/src && \
38-
ls -la && \
39-
whoami && \
4018
./configure --enable-cassert --enable-debug --prefix=/pg/install && \
4119
make -j 4 install
42-
43-
ENV PATH /pg/install/bin:$PATH
44-
ENV PGDATA /pg/data
45-
46-
RUN cd /pg/src/contrib/raftable && make clean && make install
47-
RUN cd /pg/src/contrib/mmts && make clean && make install
48-
49-
ENTRYPOINT ["/pg/src/contrib/mmts/tests2/docker-entrypoint.sh"]
50-
51-
EXPOSE 5432
52-
CMD ["postgres"]

contrib/mmts/Dockerfile

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,20 @@
1-
# vim:set ft=dockerfile:
2-
FROM debian:jessie
3-
4-
# explicitly set user/group IDs
5-
RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
6-
7-
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
8-
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
9-
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
10-
ENV LANG en_US.utf8
11-
12-
# postgres build deps
13-
RUN apt-get update && apt-get install -y \
14-
git \
15-
make \
16-
gcc \
17-
gdb \
18-
libreadline-dev \
19-
bison \
20-
flex \
21-
zlib1g-dev \
22-
sudo \
23-
&& rm -rf /var/lib/apt/lists/*
24-
25-
RUN mkdir /pg && chown postgres:postgres /pg
26-
# We need that to allow editing of /proc/sys/kernel/core_pattern
27-
# from docker-entrypoint.sh
28-
RUN echo "postgres ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers
1+
FROM kelvich/postgres_cluster
292

303
USER postgres
31-
ENV CFLAGS -O0
32-
WORKDIR /pg
334

34-
ENV REBUILD 1
35-
36-
RUN cd /pg && \
37-
git clone https://github.com/postgrespro/postgres_cluster.git --depth 1 && \
38-
cd /pg/postgres_cluster && \
39-
./configure --enable-cassert --enable-debug --prefix=/pg/install && \
40-
make -j 4 install
41-
42-
ENV PATH /pg/install/bin:$PATH
43-
ENV PGDATA /pg/data
44-
45-
ENV REBUILD 1
46-
47-
RUN cd /pg/postgres_cluster/contrib/raftable && make install
5+
RUN cd /pg/src/contrib/raftable && make clean && make install
486

497
RUN mkdir /pg/mmts
508
COPY ./ /pg/mmts/
51-
ENV RAFTABLE_PATH /pg/postgres_cluster/contrib/raftable
9+
10+
ENV RAFTABLE_PATH /pg/src/contrib/raftable
5211
ENV USE_PGXS 1
12+
ENV PGDATA /pg/data
13+
5314
RUN cd /pg/mmts && make clean && make install
5415

16+
# RUN cd /pg/src/src/test/regress && make && ./pg_regress || true
17+
5518
ENTRYPOINT ["/pg/mmts/tests2/docker-entrypoint.sh"]
5619

5720
EXPOSE 5432
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
version: '2'
2+
3+
services:
4+
5+
node1:
6+
container_name: node1
7+
build: ..
8+
privileged: true
9+
environment:
10+
POSTGRES_USER: 'pg'
11+
POSTGRES_DB: 'regression'
12+
NODE_ID: 1
13+
ports:
14+
- "5432:5432"
15+
16+
node2:
17+
container_name: node2
18+
build: ..
19+
privileged: true
20+
environment:
21+
POSTGRES_USER: 'pg'
22+
POSTGRES_DB: 'regression'
23+
NODE_ID: 2
24+
ports:
25+
- "5433:5432"
26+
27+
node3:
28+
container_name: node3
29+
build: ..
30+
privileged: true
31+
environment:
32+
POSTGRES_USER: 'pg'
33+
POSTGRES_DB: 'regression'
34+
NODE_ID: 3
35+
ports:
36+
- "5434:5432"
37+
Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,62 @@
1-
#!/bin/bash
2-
set -e
3-
4-
# wtf is that?
5-
if [ "${1:0:1}" = '-' ]; then
6-
set -- postgres "$@"
7-
fi
8-
9-
echo "/pg/%p.%s.%c.%P.core" | sudo tee /proc/sys/kernel/core_pattern
1+
#!/bin/sh
102

113
if [ "$1" = 'postgres' ]; then
124
mkdir -p "$PGDATA"
13-
chmod 700 "$PGDATA"
14-
chown -R postgres "$PGDATA"
155

166
# look specifically for PG_VERSION, as it is expected in the DB dir
177
if [ ! -s "$PGDATA/PG_VERSION" ]; then
188
initdb --nosync
199

20-
if [ "$POSTGRES_PASSWORD" ]; then
21-
pass="PASSWORD '$POSTGRES_PASSWORD'"
22-
authMethod=md5
23-
else
24-
pass=
25-
authMethod=trust
26-
fi
27-
28-
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
29-
{ echo; echo "host replication all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
30-
31-
############################################################################
10+
{ echo; echo "host all all 0.0.0.0/0 trust"; } >> "$PGDATA/pg_hba.conf"
11+
{ echo; echo "host replication all 0.0.0.0/0 trust"; } >> "$PGDATA/pg_hba.conf"
3212

33-
# internal start of server in order to allow set-up using psql-client
13+
# internal start of server in order to allow set-up using psql-client
3414
# does not listen on TCP/IP and waits until start finishes
3515
pg_ctl -D "$PGDATA" \
3616
-o "-c listen_addresses=''" \
3717
-w start
3818

39-
: ${POSTGRES_USER:=postgres}
40-
: ${POSTGRES_DB:=$POSTGRES_USER}
41-
export POSTGRES_USER POSTGRES_DB
42-
43-
psql=( psql -v ON_ERROR_STOP=1 )
19+
# : ${POSTGRES_USER:=postgres}
20+
# : ${POSTGRES_DB:=$POSTGRES_USER}
21+
# export POSTGRES_USER POSTGRES_DB
4422

4523
if [ "$POSTGRES_DB" != 'postgres' ]; then
46-
"${psql[@]}" --username postgres <<-EOSQL
24+
psql -U `whoami` postgres <<-EOSQL
4725
CREATE DATABASE "$POSTGRES_DB" ;
4826
EOSQL
4927
echo
5028
fi
5129

52-
if [ "$POSTGRES_USER" = 'postgres' ]; then
30+
if [ "$POSTGRES_USER" = `whoami` ]; then
5331
op='ALTER'
5432
else
5533
op='CREATE'
5634
fi
57-
"${psql[@]}" --username postgres <<-EOSQL
58-
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
35+
36+
psql -U `whoami` postgres <<-EOSQL
37+
$op USER "$POSTGRES_USER" WITH SUPERUSER PASSWORD '';
5938
EOSQL
6039
echo
6140

6241
############################################################################
63-
64-
CONNSTRS='dbname=postgres user=postgres host=node1, dbname=postgres user=postgres host=node2, dbname=postgres user=postgres host=node3'
65-
RAFT_PEERS='1:node1:6666, 2:node2:6666, 3:node3:6666'
42+
43+
CONNSTRS="dbname=$POSTGRES_DB user=$POSTGRES_USER host=node1, dbname=$POSTGRES_DB user=$POSTGRES_USER host=node2, dbname=$POSTGRES_DB user=$POSTGRES_USER host=node3"
6644

6745
cat <<-EOF >> $PGDATA/postgresql.conf
6846
listen_addresses='*'
6947
max_prepared_transactions = 100
7048
synchronous_commit = on
7149
fsync = off
72-
log_line_prefix = '%t: '
7350
wal_level = logical
7451
max_worker_processes = 30
7552
max_replication_slots = 10
7653
max_wal_senders = 10
7754
shared_preload_libraries = 'raftable,multimaster'
7855
default_transaction_isolation = 'repeatable read'
79-
log_checkpoints = on
80-
checkpoint_timeout = 30
81-
log_autovacuum_min_duration = 0
8256
8357
multimaster.workers = 4
84-
multimaster.use_raftable = false
8558
multimaster.max_nodes = 3
86-
multimaster.use_raftable = true
59+
multimaster.use_raftable = false
8760
multimaster.queue_size=52857600
8861
multimaster.ignore_tables_without_pk = 1
8962
multimaster.node_id = $NODE_ID
@@ -93,15 +66,8 @@ if [ "$1" = 'postgres' ]; then
9366
multimaster.twopc_min_timeout = 2000
9467
EOF
9568

96-
tail -n 20 $PGDATA/postgresql.conf
97-
9869
pg_ctl -D "$PGDATA" -m fast -w stop
99-
100-
echo
101-
echo 'PostgreSQL init process complete; ready for start up.'
102-
echo
10370
fi
10471
fi
10572

10673
exec "$@"
107-
File renamed without changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy