From a87a423e1e489b0c2a8e32389d3bc48006ffcb82 Mon Sep 17 00:00:00 2001 From: Anthony Yeh Date: Fri, 4 Mar 2016 15:48:34 -0800 Subject: [PATCH] Add Docker images for Percona Server. --- Dockerfile.percona | 15 ++++++++++++ Makefile | 15 ++++++++++++ bootstrap.sh | 5 ++-- docker/bootstrap/Dockerfile.percona | 21 ++++++++++++++++ docker/lite/Dockerfile.percona | 38 +++++++++++++++++++++++++++++ docker/lite/build.sh | 18 ++++++++++++-- 6 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 Dockerfile.percona create mode 100644 docker/bootstrap/Dockerfile.percona create mode 100644 docker/lite/Dockerfile.percona diff --git a/Dockerfile.percona b/Dockerfile.percona new file mode 100644 index 00000000000..c0959bdf7e8 --- /dev/null +++ b/Dockerfile.percona @@ -0,0 +1,15 @@ +FROM vitess/bootstrap:percona + +# Clear out old tree from bootstrap image. +USER root +RUN rm -rf /vt/src/github.com/youtube/vitess + +# Re-copy sources from working tree +COPY . /vt/src/github.com/youtube/vitess + +# Fix permissions +RUN chown -R vitess:vitess /vt +USER vitess + +# Build Vitess +RUN make build diff --git a/Makefile b/Makefile index 2b6803ce76d..6d98248511c 100644 --- a/Makefile +++ b/Makefile @@ -105,15 +105,30 @@ docker_bootstrap: docker/bootstrap/build.sh common docker/bootstrap/build.sh mariadb docker/bootstrap/build.sh mysql56 + docker/bootstrap/build.sh percona docker_base: # Fix permissions before copying files, to avoid AUFS bug. chmod -R o=g * docker build -t vitess/base . +docker_base_percona: + chmod -R o=g * + docker build -f Dockerfile.percona -t vitess/base:percona . + +docker_base_mariadb: + chmod -R o=g * + docker build -f Dockerfile.mariadb -t vitess/base:mariadb . + docker_lite: cd docker/lite && ./build.sh +docker_lite_mariadb: + cd docker/lite && ./build.sh mariadb + +docker_lite_percona: + cd docker/lite && ./build.sh percona + docker_guestbook: cd examples/kubernetes/guestbook && ./build.sh diff --git a/bootstrap.sh b/bootstrap.sh index 82828a445b4..13d34ca29da 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -137,9 +137,10 @@ ln -snf $VTTOP/py $VTROOT/py-vtdb ln -snf $VTTOP/go/zk/zkctl/zksrv.sh $VTROOT/bin/zksrv.sh ln -snf $VTTOP/test/vthook-test.sh $VTROOT/vthook/test.sh -# install mysql +# find mysql and prepare to use libmysqlclient if [ -z "$MYSQL_FLAVOR" ]; then - export MYSQL_FLAVOR=MariaDB + export MYSQL_FLAVOR=MySQL56 + echo "MYSQL_FLAVOR environment variable not set. Using default: $MYSQL_FLAVOR" fi case "$MYSQL_FLAVOR" in "MySQL56") diff --git a/docker/bootstrap/Dockerfile.percona b/docker/bootstrap/Dockerfile.percona new file mode 100644 index 00000000000..f611cb9012b --- /dev/null +++ b/docker/bootstrap/Dockerfile.percona @@ -0,0 +1,21 @@ +FROM vitess/bootstrap:common + +# Install Percona 5.6 +RUN apt-key adv --keyserver ha.pool.sks-keyservers.net \ + --recv-keys 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A && \ + add-apt-repository 'deb http://repo.percona.com/apt jessie main' && \ + { \ + echo debconf debconf/frontend select Noninteractive; \ + echo percona-server-server-5.6 percona-server-server/root_password password 'unused'; \ + echo percona-server-server-5.6 percona-server-server/root_password_again password 'unused'; \ + } | debconf-set-selections && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + percona-server-server-5.6 libperconaserverclient18.1-dev && \ + rm -rf /var/lib/apt/lists/* + +# Bootstrap Vitess +WORKDIR /vt/src/github.com/youtube/vitess +USER vitess +ENV MYSQL_FLAVOR MySQL56 +RUN ./bootstrap.sh --skip_root_installs diff --git a/docker/lite/Dockerfile.percona b/docker/lite/Dockerfile.percona new file mode 100644 index 00000000000..32e63f1392e --- /dev/null +++ b/docker/lite/Dockerfile.percona @@ -0,0 +1,38 @@ +# This image is only meant to be built from within the build.sh script. +FROM debian:jessie + +# Install dependencies +RUN apt-key adv --keyserver ha.pool.sks-keyservers.net \ + --recv-keys 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A && \ + echo 'deb http://repo.percona.com/apt jessie main' > /etc/apt/sources.list.d/mysql.list && \ + { \ + echo debconf debconf/frontend select Noninteractive; \ + echo percona-server-server-5.6 percona-server-server/root_password password 'unused'; \ + echo percona-server-server-5.6 percona-server-server/root_password_again password 'unused'; \ + } | debconf-set-selections && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + percona-server-server-5.6 bzip2 memcached && \ + rm -rf /var/lib/apt/lists/* + +# Set up Vitess environment (just enough to run pre-built Go binaries) +ENV VTTOP /vt/src/github.com/youtube/vitess +ENV VTROOT /vt +ENV GOTOP $VTTOP/go +ENV VTDATAROOT $VTROOT/vtdataroot +ENV GOBIN $VTROOT/bin +ENV GOPATH $VTROOT +ENV PATH $VTROOT/bin:$PATH +ENV VT_MYSQL_ROOT /usr +ENV PKG_CONFIG_PATH $VTROOT/lib +ENV LD_LIBRARY_PATH $VTROOT/dist/vt-zookeeper-3.4.6/lib + +# Copy binaries (placed by build.sh) +COPY lite/vt /vt + +# Create vitess user +RUN groupadd -r vitess && useradd -r -g vitess vitess && \ + mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt + +# Create mount point for actual data (e.g. MySQL data dir) +VOLUME /vt/vtdataroot diff --git a/docker/lite/build.sh b/docker/lite/build.sh index d7a1ceb97ce..431ef5201bc 100755 --- a/docker/lite/build.sh +++ b/docker/lite/build.sh @@ -3,9 +3,18 @@ # This is the script to build the vitess/lite Docker image by extracting # the pre-built binaries from a vitess/base image. +flavor=$1 + +if [[ -n "$flavor" ]]; then + base_image=vitess/base:$flavor +else + echo "Flavor not specified as first argument. Building default image." + base_image=vitess/base +fi + # Extract files from vitess/base image mkdir base -sudo docker run -ti --rm -v $PWD/base:/base -u root vitess/base bash -c 'cp -R /vt /base/' +sudo docker run -ti --rm -v $PWD/base:/base -u root $base_image bash -c 'cp -R /vt /base/' # Grab only what we need lite=$PWD/lite @@ -31,7 +40,12 @@ sudo rm -rf base chmod -R o=g lite # Build vitess/lite image -sudo docker build -t vitess/lite . + +if [[ -n "$flavor" ]]; then + sudo docker build -f Dockerfile.$flavor -t vitess/lite:$flavor . +else + sudo docker build -t vitess/lite . +fi # Clean up temporary files rm -rf lite