summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorn.christian@seime.no>2017-06-20 17:29:34 +0200
committerGitHub <noreply@github.com>2017-06-20 17:29:34 +0200
commit800ce4c3006363b3b307c745bee2ce7ee37c2d8b (patch)
treef5407c5360147e820cdcb0a45d415921469936c7 /docker
parent8b2657c5aac077f2e64e76d5af840307c37b38fa (diff)
parent8f1bb3bd3300bdc1b1d379dc414275fc834ac2fc (diff)
Merge pull request #2845 from yahoo/geirst/separate-script-for-docker-image-building
Move building of docker image to separate script and tag it with vers…
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile.run4
-rw-r--r--docker/README.md17
-rwxr-xr-xdocker/build-vespa-image.sh16
-rwxr-xr-xdocker/run-vespa-internal.sh8
-rwxr-xr-xdocker/run-vespa.sh6
5 files changed, 36 insertions, 15 deletions
diff --git a/docker/Dockerfile.run b/docker/Dockerfile.run
index 19d0fd345c3..4116b12a00d 100644
--- a/docker/Dockerfile.run
+++ b/docker/Dockerfile.run
@@ -1,11 +1,15 @@
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
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..e8c8c0d4d0e 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,10 +11,6 @@ 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
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