Skip to content

Commit

Permalink
[dbe] introducing greenplum 5.17
Browse files Browse the repository at this point in the history
  • Loading branch information
tjlee committed Feb 28, 2019
1 parent 6735a5b commit 43907e1
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 0 deletions.
57 changes: 57 additions & 0 deletions greenplum/5.17/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# currently published as pivotaldata/pgadmin:gpdb-5

FROM pivotaldata/pgadmin:base-python-selenium-chrome

EXPOSE 5432

# explicitly set user/group IDs
RUN groupadd -r postgres --gid=999 && useradd -m -r -g postgres --uid=999 postgres

# grab gosu for easy step-down from root
ENV GOSU_VERSION 1.7
RUN set -x \
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \
&& export GNUPGHOME="$(mktemp -d)" \
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \
&& rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true

RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

RUN apt update \
&& apt install -y software-properties-common python-software-properties less \
&& add-apt-repository ppa:greenplum/db \
&& apt update \
&& apt install -y greenplum-db-oss \
&& . /opt/gpdb/greenplum_path.sh

RUN locale-gen en_US.utf8 \
&& mkdir /gpdata \
&& mkdir /gpdata/gpdata1 \
&& mkdir /gpdata/gpdata2 \
&& mkdir /gpdata/gpmaster \
&& . /opt/gpdb/greenplum_path.sh && cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_singlenode /gpdata/ \
&& sed -i 's/gpdata1/gpdata\/gpdata1/g' /gpdata/gpinitsystem_singlenode \
&& sed -i 's/gpdata2/gpdata\/gpdata2/g' /gpdata/gpinitsystem_singlenode \
&& sed -i 's/gpmaster/gpdata\/gpmaster/g' /gpdata/gpinitsystem_singlenode \
&& apt install -y ssh \
&& useradd -md /home/gp/ gp \
&& chown gp -R /gpdata \
&& echo "source /opt/gpdb/greenplum_path.sh" > /home/gp/.bash_profile && chown gp:gp /home/gp/.bash_profile \
&& su - gp bash -c 'mkdir /home/gp/.ssh'

ADD install_and_start_gpdb.sh /home/gp/install_and_start_gpdb.sh
RUN chown gp:gp /home/gp/install_and_start_gpdb.sh \
&& chmod a+x /home/gp/install_and_start_gpdb.sh \
&& echo "gp ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& echo "root ALL=NOPASSWD: ALL" >> /etc/sudoers

ADD entrypoint.sh /
RUN chmod +x /entrypoint.sh

# CMD sudo su - gp bash -c /home/gp/install_and_start_gpdb.sh && tail -f /dev/null
CMD sudo su - gp bash -c /home/gp/install_and_start_gpdb.sh && sudo su - gp bash -c /entrypoint.sh && tail -f /dev/null
14 changes: 14 additions & 0 deletions greenplum/5.17/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '2.1'

services:
greenplum_5.17:
# jdbc:postgresql://localhost:54303/gpadmin?user=gpadmin&password=pivotal
container_name: greenplum517
ports:
- "54303:5432"
image: datagrip/greenplum:5.17
privileged: true
security_opt:
- seccomp:unconfined
healthcheck:
test: grep -r -i --include \*.log "Database successfully started" || exit 1
55 changes: 55 additions & 0 deletions greenplum/5.17/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash
export STATUS=0
i=0
echo "STARTING... (about 30 sec)"
while [[ $STATUS -eq 0 ]] || [[ $i -lt 30 ]]; do
sleep 1
i=$((i+1))
STATUS=$(grep -r -i --include \*.log "Database successfully started" | wc -l)
done

echo "STARTED"

if [ ! -z $GP_USER ]; then
echo "GP_USER: $GP_USER"
else
GP_USER=tester
echo "GP_USER: $GP_USER"
fi

if [ ! -z $GP_PASSWORD ]; then
echo "GP_PASSWORD: $GP_PASSWORD"
else
GP_PASSWORD=pivotal
echo "GP_PASSWORD: $GP_PASSWORD"
fi

if [ ! -z $GP_DB ]; then
echo "GP_DB: $GP_DB"
else
GP_DB=testdb
echo "GP_DB: $GP_DB"
fi

sudo su - gp bash -c "/opt/gpdb/bin/psql -v ON_ERROR_STOP=1 --username gp --dbname postgres <<-EOSQL
CREATE USER $GP_USER WITH PASSWORD '$GP_PASSWORD' SUPERUSER;
CREATE DATABASE $GP_DB WITH OWNER $GP_USER;
EOSQL"

cat << EOF
+-------------------------------------------------
| CREATE USER $GP_USER WITH PASSWORD '$GP_PASSWORD' SUPERUSER;
+-------------------------------------------------
EOF

cat << EOF
+-------------------------------------------------
| CREATE DATABASE $GP_DB WITH OWNER $GP_USER;
+-------------------------------------------------
EOF

#trap
while [ "$END" == '' ]; do
sleep 1
trap "gpstop -M && END=1" INT TERM
done
15 changes: 15 additions & 0 deletions greenplum/5.17/install_and_start_gpdb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo /etc/init.d/ssh start
sleep 2
source /home/gp/.bash_profile
ssh-keygen -f /home/gp/.ssh/id_rsa -t rsa -N ""
echo `hostname` > /gpdata/hostlist_singlenode
sed -i 's/hostname_of_machine/`hostname`/g' /gpdata/gpinitsystem_singlenode

gpssh-exkeys -f /gpdata/hostlist_singlenode

pushd /gpdata
gpinitsystem -ac gpinitsystem_singlenode
echo "host all all 0.0.0.0/0 trust" >> /gpdata/gpmaster/gpsne-1/pg_hba.conf
MASTER_DATA_DIRECTORY=/gpdata/gpmaster/gpsne-1/ gpstop -a
MASTER_DATA_DIRECTORY=/gpdata/gpmaster/gpsne-1/ gpstart -a
popd

0 comments on commit 43907e1

Please sign in to comment.