diff --git a/Makefile b/Makefile index 15cffad9e49..80c9ac6d674 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,18 @@ install: build mkdir -p "$${PREFIX}/bin" cp "$${VTROOT}/bin/"{mysqlctld,vtctld,vtctlclient,vtgate,vttablet,vtworker,vtbackup} "$${PREFIX}/bin/" +# install copies the files needed to run test Vitess using vtcombo into the given directory tree. +# Usage: make install PREFIX=/path/to/install/root +install-testing: build + # binaries + mkdir -p "$${PREFIX}/bin" + cp "$${VTROOT}/bin/"{mysqlctld,mysqlctl,vtcombo,vttestserver} "$${PREFIX}/bin/" + # config files + cp -R config "$${PREFIX}/" + # vtctld web UI files + mkdir -p "$${PREFIX}/web/vtctld2" + cp -R web/vtctld2/app "$${PREFIX}/web/vtctld2" + parser: make -C go/vt/sqlparser @@ -256,6 +268,10 @@ docker_lite_alpine: chmod -R o=g * docker build -f docker/lite/Dockerfile.alpine -t vitess/lite:alpine . +docker_lite_testing: + chmod -R o=g * + docker build -f docker/lite/Dockerfile.testing -t vitess/lite:testing . + # This rule loads the working copy of the code into a bootstrap image, # and then runs the tests inside Docker. # Example: $ make docker_test flavor=mariadb diff --git a/docker/lite/Dockerfile.testing b/docker/lite/Dockerfile.testing new file mode 100644 index 00000000000..5bcad5bcfbf --- /dev/null +++ b/docker/lite/Dockerfile.testing @@ -0,0 +1,53 @@ +# Copyright 2019 The Vitess Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# NOTE: We have to build the Vitess binaries from scratch instead of sharing +# a base image because Docker Hub dropped the feature we relied upon to +# ensure images contain the right binaries. + +# Use a temporary layer for the build stage. +FROM vitess/bootstrap:mysql57 AS builder + +# Allows some docker builds to disable CGO +ARG CGO_ENABLED=0 + +# Re-copy sources from working tree. +COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess + +# Build and install Vitess in a temporary output directory. +USER vitess +RUN make install-testing PREFIX=/vt/install + +# Start over and build the final image. +FROM debian:stretch-slim + +# Install dependencies +COPY docker/lite/install_dependencies.sh /vt/dist/install_dependencies.sh +RUN /vt/dist/install_dependencies.sh mysql57 + +# Set up Vitess user and directory tree. +RUN groupadd -r vitess && useradd -r -g vitess vitess +RUN mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt + +# Set up Vitess environment (just enough to run pre-built Go binaries) +ENV VTROOT /vt +ENV VTDATAROOT /vt/vtdataroot +ENV PATH $VTROOT/bin:$PATH + +# Copy artifacts from builder layer. +COPY --from=builder --chown=vitess:vitess /vt/install /vt + +# Create mount point for actual data (e.g. MySQL data dir) +VOLUME /vt/vtdataroot +USER vitess