Skip to content

Commit

Permalink
Add Docker images for Percona Server.
Browse files Browse the repository at this point in the history
  • Loading branch information
enisoc committed Mar 4, 2016
1 parent 2ee9530 commit a87a423
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 4 deletions.
15 changes: 15 additions & 0 deletions Dockerfile.percona
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
21 changes: 21 additions & 0 deletions docker/bootstrap/Dockerfile.percona
Original file line number Diff line number Diff line change
@@ -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
38 changes: 38 additions & 0 deletions docker/lite/Dockerfile.percona
Original file line number Diff line number Diff line change
@@ -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
18 changes: 16 additions & 2 deletions docker/lite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit a87a423

Please sign in to comment.