diff options
author | drebs <drebs@leap.se> | 2016-06-06 20:34:03 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2016-06-06 21:40:44 -0300 |
commit | 7ee12a38d6e8230525f3401abdbd3def4d81502b (patch) | |
tree | 47d843c1081e71f14df4a2129e8a560c3e4d0fe9 /scripts/docker/Makefile | |
parent | f25dc033f9456ea82be5330fe9a3e5145a78f361 (diff) |
[test] add rule and script to run soledad connection test
Diffstat (limited to 'scripts/docker/Makefile')
-rw-r--r-- | scripts/docker/Makefile | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/scripts/docker/Makefile b/scripts/docker/Makefile index 5e5b345e..9b9ab8f7 100644 --- a/scripts/docker/Makefile +++ b/scripts/docker/Makefile @@ -1,31 +1,57 @@ #/usr/bin/env -IMAGE_NAME = "leap/soledad:1.0" +# This makefile is intended to aid on running soledad docker images for +# specific purposes, as running a server, a client or tests. +# +# In order to communicate the IP address of one container to another, we make +# use of a file containing the container id. You have to explicitelly pass the +# CONTAINER_ID_FILE variable when invoking some of the targets below. +# +# Example usage: +# +# make run-server CONTAINER_ID_FILE=/tmp/container-id.txt +# make run-client-test CONTAINER_ID_FILE=/tmp/container-id.txt + + +IMAGE_NAME ?= "leap/soledad:1.0" +SOLEDAD_REMOTE ?= "https://0xacab.org/leap/soledad.git" +SOLEDAD_BRANCH ?= "develop" + all: image image: docker build -t $(IMAGE_NAME) . -run-server: image - rm -f $(CONTAINER_ID_FILE) +run-server: + @if [ -z "$(CONTAINER_ID_FILE)" ]; then \ + echo "Error: you have to pass a value to CONTAINER_ID_FILE."; \ + exit 2; \ + fi docker run \ - --env="SOLEDAD_REMOTE=https://0xacab.org/leap/soledad.git" \ - --env="SOLEDAD_BRANCH=develop" \ + --env="SOLEDAD_REMOTE=$(SOLEDAD_REMOTE)" \ + --env="SOLEDAD_BRANCH=$(SOLEDAD_BRANCH)" \ --cidfile=$(CONTAINER_ID_FILE) \ --detach \ $(IMAGE_NAME) \ /usr/local/soledad/start-server.sh -run-client-test: image +run-client-test: + @if [ -z "$(CONTAINER_ID_FILE)" ]; then \ + echo "Error: you have to pass a value to CONTAINER_ID_FILE."; \ + exit 2; \ + fi container_id=`cat $(CONTAINER_ID_FILE)`; \ server_ip=`./helper/get-container-ip.sh $${container_id}`; \ docker run -t -i \ - --env="SOLEDAD_REMOTE=https://0xacab.org/leap/soledad.git" \ - --env="SOLEDAD_BRANCH=develop" \ + --env="SOLEDAD_REMOTE=$(SOLEDAD_REMOTE)" \ + --env="SOLEDAD_BRANCH=$(SOLEDAD_BRANCH)" \ --env="SOLEDAD_SERVER_URL=http://$${server_ip}:2424" \ $(IMAGE_NAME) \ /usr/local/soledad/start-client-test.sh +run-shell: image + docker run -t -i $(IMAGE_NAME) /bin/bash + rm-all-containers: docker ps -a | cut -d" " -f 1 | tail -n +2 | xargs docker rm -f |