提交 3183577d 编写于 作者: J Joao Pereira

Update GreenPlum Docker image:

 .Smaller image size
 .Change the role from gp to gpadmin
 .Remove libraries that are not needed
上级 a02dd9d0
# currently published as pivotaldata/pgadmin:gpdb-5
# currently published as pivotaldata/gpdb5:latest
FROM ubuntu:16.04
......@@ -6,53 +6,41 @@ EXPOSE 5432
# explicitly set user/group IDs
RUN groupadd -r postgres --gid=999 && useradd -m -r -g postgres --uid=999 postgres
RUN apt-get update && apt-get install -y dirmngr
# 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 | apt-key add -
RUN apt update
RUN apt install -y software-properties-common python-software-properties less
RUN add-apt-repository ppa:greenplum/db
RUN apt update
RUN apt install -y greenplum-db-oss
RUN . /opt/gpdb/greenplum_path.sh
RUN locale-gen en_US.utf8
RUN mkdir /gpdata
RUN mkdir /gpdata/gpdata1
RUN mkdir /gpdata/gpdata2
RUN mkdir /gpdata/gpmaster
RUN . /opt/gpdb/greenplum_path.sh && cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_singlenode /gpdata/
RUN sed -i 's/gpdata1/gpdata\/gpdata1/g' /gpdata/gpinitsystem_singlenode
RUN sed -i 's/gpdata2/gpdata\/gpdata2/g' /gpdata/gpinitsystem_singlenode
RUN sed -i 's/gpmaster/gpdata\/gpmaster/g' /gpdata/gpinitsystem_singlenode
RUN apt install -y ssh
RUN useradd -md /home/gp/ gp
RUN chown gp -R /gpdata
RUN echo "source /opt/gpdb/greenplum_path.sh" > /home/gp/.bash_profile && chown gp:gp /home/gp/.bash_profile
RUN 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
RUN chmod a+x /home/gp/install_and_start_gpdb.sh
RUN apt-get install -y sudo
RUN echo "gp ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
RUN echo "root ALL=NOPASSWD: ALL" >> /etc/sudoers
CMD sudo su - gp bash -c /home/gp/install_and_start_gpdb.sh && tail -f /dev/null
# Install initial dependencies
RUN apt-get update \
&& apt-get install -y dirmngr software-properties-common python-software-properties less ssh sudo
# Install GreenPlum
RUN wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& add-apt-repository ppa:greenplum/db \
&& apt update \
&& apt install -y greenplum-db-oss \
&& locale-gen en_US.utf8
# Create GreenPlum data folders and copy/edit configuration to use a single node
RUN mkdir /data \
&& mkdir /data/data1 \
&& mkdir /data/data2 \
&& mkdir /data/master \
&& . /opt/gpdb/greenplum_path.sh && cp $GPHOME/docs/cli_help/gpconfigs/gpinitsystem_singlenode /data/ \
&& sed -i 's/gpdata1/data\/data1/g' /data/gpinitsystem_singlenode \
&& sed -i 's/gpdata2/data\/data2/g' /data/gpinitsystem_singlenode \
&& sed -i 's/gpmaster/data\/master/g' /data/gpinitsystem_singlenode
# Create gpadmin user and add the user to the sudoers
RUN useradd -md /home/gpadmin/ gpadmin \
&& chown gpadmin -R /data \
&& echo "source /opt/gpdb/greenplum_path.sh" > /home/gpadmin/.bash_profile && chown gpadmin:gpadmin /home/gpadmin/.bash_profile \
&& su - gpadmin bash -c 'mkdir /home/gpadmin/.ssh' \
&& echo "gpadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers \
&& echo "root ALL=NOPASSWD: ALL" >> /etc/sudoers
## Add setup and start script to run when the container starts
ADD install_and_start_gpdb.sh /home/gpadmin/install_and_start_gpdb.sh
RUN chown gpadmin:gpadmin /home/gpadmin/install_and_start_gpdb.sh \
&& chmod a+x /home/gpadmin/install_and_start_gpdb.sh
CMD sudo su - gpadmin bash -c /home/gpadmin/install_and_start_gpdb.sh && tail -f /dev/null
# Docker container with Version 5.4 of GPDB running
# Docker container running the latest GPDB version available for ubuntu
## Build your own container
```
docker build -t pivotaldata/gpdb:5.4 ubuntu-16.04
docker build -t pivotaldata/gpdb5:latest ubuntu-16.04
```
## Run the container
......@@ -12,7 +12,7 @@ The container will keep running forever until it is stopped and the GreenPlum da
will be listenning in the port `localhost:5433`
```
docker run -dp 127.0.0.1:5433:5432 pivotaldata/gpdb:5.4
docker run -dp 127.0.0.1:5433:5432 pivotaldata/gpdb5:latest
```
_The container takes around 30 seconds to instantiate and start the new GP Instance_
......
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
source /home/gpadmin/.bash_profile
ssh-keygen -f /home/gpadmin/.ssh/id_rsa -t rsa -N ""
echo `hostname` > /data/hostlist_singlenode
sed -i 's/hostname_of_machine/`hostname`/g' /data/gpinitsystem_singlenode
gpssh-exkeys -f /gpdata/hostlist_singlenode
gpssh-exkeys -f /data/hostlist_singlenode
pushd /gpdata
pushd /data
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
echo "host all all 0.0.0.0/0 trust" >> /data/master/gpsne-1/pg_hba.conf
MASTER_DATA_DIRECTORY=/data/master/gpsne-1/ gpstop -a
MASTER_DATA_DIRECTORY=/data/master/gpsne-1/ gpstart -a
popd
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册