diff options
author | Geir Storli <geirst@yahoo-inc.com> | 2017-06-20 14:17:56 +0200 |
---|---|---|
committer | Geir Storli <geirst@yahoo-inc.com> | 2017-06-20 14:17:56 +0200 |
commit | fb811b95237823ed4be3413231dda817999e6ccb (patch) | |
tree | efb6285dabdedebd3b23b9e5f976cdefc5937ef7 /docker | |
parent | 86e346744713ce715b94ae70a0233f46c4ab61c4 (diff) |
Move building of docker image to separate script and tag it with version number.
Diffstat (limited to 'docker')
-rw-r--r-- | docker/Dockerfile.run | 4 | ||||
-rw-r--r-- | docker/README.md | 17 | ||||
-rwxr-xr-x | docker/build-vespa-image.sh | 16 | ||||
-rwxr-xr-x | docker/run-vespa-internal.sh | 9 | ||||
-rwxr-xr-x | docker/run-vespa.sh | 6 |
5 files changed, 36 insertions, 16 deletions
diff --git a/docker/Dockerfile.run b/docker/Dockerfile.run index 77e737279dd..962ec7a07e2 100644 --- a/docker/Dockerfile.run +++ b/docker/Dockerfile.run @@ -1,10 +1,14 @@ FROM centos:7 +ARG VESPA_VERSION # Needed to run vespa RUN yum-config-manager --add-repo https://copr.fedorainfracloud.org/coprs/g/vespa/vespa/repo/epel-7/group_vespa-vespa-epel-7.repo && \ yum -y install epel-release && \ yum -y install centos-release-scl +COPY vespa*-${VESPA_VERSION}-*.rpm /tmp/ +RUN yum localinstall -y $(ls /tmp/vespa*-${VESPA_VERSION}-*.rpm | xargs) + ENV VESPA_HOME=/opt/vespa ENV PATH="${PATH}:${VESPA_HOME}/bin" diff --git a/docker/README.md b/docker/README.md index e3105b9263a..a89405ad80d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -7,20 +7,27 @@ *On Linux, the default storage device is devicemapper with loopback device and max 10GB container size. This size is too small for a full build. Please see [here](http://www.projectatomic.io/blog/2016/03/daemon_option_basedevicesize/) and [here](http://www.projectatomic.io/blog/2015/06/notes-on-fedora-centos-and-docker-storage-drivers/) to overcome this limitation.* -## Building the Vespa RPM +## Building Vespa RPM Execute ```./build-vespa.sh <Vespa version number>``` to build Vespa from this source code. -The produced rpms will be available in this folder after compiliation. The version number will be compiled into binaries, but has no other meaning than that. +The produced rpms will be available in this folder after compilation. +The version number will be compiled into binaries, but has no other meaning than that. ## Building and testing Vespa Execute ```./vespa-ci.sh <git commit>``` to build and test a specific branch/tag/commit. -## Running Vespa +## Building Vespa Docker image +Execute ```./build-vespa-image.sh <Vespa version number>``` to build a Docker image (*vesparun*) which has the rpms +from the build step (or downloaded rpms into this folder) installed. + + +## Running Vespa inside Docker container Execute ```./run-vespa.sh <Vespa version number>``` to start Vespa. -This will create a Docker image which has the rpms from the build step (or downloaded rpms to this folder) installed. Vespa will be started inside the container. +This starts a Docker container using the Docker image (*vesparun*) from the previous step. +Vespa will be started inside the container. *On OS X, the container runs inside the Docker VM. Execute ```docker-machine ssh vespa-docker-machine``` to enter the VM. The services can also be reached directly from the host on the IP given by ```docker-machine ip vespa-docker-machine```* @@ -32,7 +39,7 @@ The container is entered at the root of the Vespa source repository. Follow the ## Troubleshooting -- Use ```docker logs CONTAINER``` for output - useful if the commands above fail +- Use ```docker logs CONTAINER``` for output - useful if the commands above fail. - If the build fails, start from scratch: ```docker rmi -f vesparun vespabuild``` - then build again. Clean local docker if docker image disk full: - ```docker rm -v $(docker ps -a -q -f status=exited)``` diff --git a/docker/build-vespa-image.sh b/docker/build-vespa-image.sh new file mode 100755 index 00000000000..d039e7dcabc --- /dev/null +++ b/docker/build-vespa-image.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +set -e + +if [ $# -ne 1 ]; then + echo "Usage: $0 <vespa version>" + exit 1 +fi + +DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) +cd $DIR + +VESPA_VERSION=$1 +DOCKER_IMAGE=vesparun + +docker build -t "$DOCKER_IMAGE":"$VESPA_VERSION" --build-arg VESPA_VERSION="$VESPA_VERSION" -f Dockerfile.run . diff --git a/docker/run-vespa-internal.sh b/docker/run-vespa-internal.sh index 5242cbf7cf4..b4fbacaf381 100755 --- a/docker/run-vespa-internal.sh +++ b/docker/run-vespa-internal.sh @@ -2,8 +2,8 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. set -e -if [ $# -ne 1 ]; then - echo "Usage: $0 <vespa version>" +if [ $# -ne 0 ]; then + echo "Usage: $0" echo "This script should not be called manually." exit 1 fi @@ -11,17 +11,12 @@ fi DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) cd $DIR -VESPA_VERSION=$1 - -yum localinstall -y $(ls vespa*-${VESPA_VERSION}-*.rpm | xargs) - # Workaround until we figure out why rpm does not set the ownership. chown -R vespa:vespa /opt/vespa export VESPA_CONFIG_SERVERS=$(hostname) /opt/vespa/bin/vespa-start-configserver -/opt/vespa/bin/vespa-start-services # Print log forever while true; do diff --git a/docker/run-vespa.sh b/docker/run-vespa.sh index 4f05c995156..6321f279bdd 100755 --- a/docker/run-vespa.sh +++ b/docker/run-vespa.sh @@ -13,11 +13,9 @@ cd $DIR VESPA_VERSION=$1 DOCKER_IMAGE=vesparun -docker build -t "$DOCKER_IMAGE" -f Dockerfile.run . - if [ "$(uname)" != "Darwin" ]; then - docker run -d -v $(pwd)/..:/vespa --net=host --privileged --entrypoint /vespa/docker/run-vespa-internal.sh "$DOCKER_IMAGE" "$VESPA_VERSION" + docker run -d -v $(pwd)/..:/vespa --net=host --privileged --entrypoint /vespa/docker/run-vespa-internal.sh "$DOCKER_IMAGE":"$VESPA_VERSION" else # On OS X, net=host does not work. Need to explicitly expose ports from localhost into container. - docker run -d -p 8080:8080 -p 19071:19071 -v $(pwd)/..:/vespa --privileged --entrypoint /vespa/docker/run-vespa-internal.sh "$DOCKER_IMAGE" "$VESPA_VERSION" + docker run -d -p 8080:8080 -p 19071:19071 -v $(pwd)/..:/vespa --privileged --entrypoint /vespa/docker/run-vespa-internal.sh "$DOCKER_IMAGE":"$VESPA_VERSION" fi |