From 9a2459af06b99d72791942b95aafa0e475d9c834 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 9 May 2016 17:03:02 +0800 Subject: [PATCH 1/3] add random image name. Signed-off-by: Bo-Yi Wu --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d559524..7eed148 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,10 @@ DEPS := $(wildcard *.go) BUILD_IMAGE := "gorush-build" -TEST_IMAGE := "gorush-testing" PRODUCTION_IMAGE := "gorush" DEPLOY_ACCOUNT := "appleboy" VERSION := $(shell git describe --tags) +TIMENAME := $(shell date '+%Y%m%d%H%M%S%s') all: build @@ -38,11 +38,11 @@ docker_build: clean docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist . docker_test: - -docker rm -f gorush-redis - @docker build --rm -t $(TEST_IMAGE) -f docker/Dockerfile.testing . - @docker run --name gorush-redis -d redis - @docker run --rm --link gorush-redis:redis -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TEST_IMAGE) sh -c "make test" - @docker rm -f gorush-redis + @docker build --rm -t $(TIMENAME)-test -f docker/Dockerfile.testing . + @docker run --name $(TIMENAME)-redis -d redis + @docker run --rm --link $(TIMENAME)-redis:redis -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TIMENAME)-test sh -c "make test" + @docker rm -f $(TIMENAME)-redis + @docker rmi -f $(TIMENAME)-test deploy: ifeq ($(tag),) From d97ed3457f90278c146ae6ab6ff7444660fe9aad Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 11 May 2016 17:00:17 +0800 Subject: [PATCH 2/3] support docker compose testing. Signed-off-by: Bo-Yi Wu --- Makefile | 11 ++++------- docker/Dockerfile.testing | 7 +++++-- docker/docker-compose.testing.yml | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 docker/docker-compose.testing.yml diff --git a/Makefile b/Makefile index 7eed148..fd14831 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ BUILD_IMAGE := "gorush-build" PRODUCTION_IMAGE := "gorush" DEPLOY_ACCOUNT := "appleboy" VERSION := $(shell git describe --tags) -TIMENAME := $(shell date '+%Y%m%d%H%M%S%s') +PROJECT := $(shell date '+%Y%m%d%H%M%S%s') all: build @@ -38,11 +38,8 @@ docker_build: clean docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist . docker_test: - @docker build --rm -t $(TIMENAME)-test -f docker/Dockerfile.testing . - @docker run --name $(TIMENAME)-redis -d redis - @docker run --rm --link $(TIMENAME)-redis:redis -e ANDROID_TEST_TOKEN=$(ANDROID_TEST_TOKEN) -e ANDROID_API_KEY=$(ANDROID_API_KEY) $(TIMENAME)-test sh -c "make test" - @docker rm -f $(TIMENAME)-redis - @docker rmi -f $(TIMENAME)-test + docker-compose -p ${PROJECT} -f docker/docker-compose.testing.yml run --rm gorush + docker-compose -p ${PROJECT} -f docker/docker-compose.testing.yml down deploy: ifeq ($(tag),) @@ -62,4 +59,4 @@ lint: golint gorush clean: - -rm -rf build.tar.gz gorush.tar.gz bin/* + -rm -rf build.tar.gz gorush.tar.gz bin/* coverage.out gorush.tar.gz diff --git a/docker/Dockerfile.testing b/docker/Dockerfile.testing index 6dd511c..4e90628 100644 --- a/docker/Dockerfile.testing +++ b/docker/Dockerfile.testing @@ -1,11 +1,14 @@ -FROM golang:1.6 +FROM golang:1.6.2-alpine MAINTAINER Bo-Yi Wu +RUN apk update \ + && apk add git make && rm -rf /var/cache/apk/* + # install glide package management. RUN go get github.com/Masterminds/glide && cd $GOPATH/src/github.com/Masterminds/glide && make install RUN mkdir -p $GOPATH/src/github.com/appleboy/gorush -Add . $GOPATH/src/github.com/appleboy/gorush/ +RUN git clone https://github.com/appleboy/gorush.git $GOPATH/src/github.com/appleboy/gorush/ WORKDIR $GOPATH/src/github.com/appleboy/gorush RUN sed -i"" -e "s/localhost/redis/g" config/config.yml RUN sed -i"" -e "s/localhost/redis/g" gorush/status_test.go diff --git a/docker/docker-compose.testing.yml b/docker/docker-compose.testing.yml new file mode 100644 index 0000000..13bf5ac --- /dev/null +++ b/docker/docker-compose.testing.yml @@ -0,0 +1,14 @@ +gorush: + build: "." + dockerfile: Dockerfile.testing + links: + - redis + privileged: true + environment: + - ANDROID_API_KEY + - ANDROID_TEST_TOKEN + command: /bin/sh -c "make test" + +redis: + image: redis:alpine + privileged: true From c499d407b1273e548d69bd61848c619529d6cd4d Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 11 May 2016 17:11:21 +0800 Subject: [PATCH 3/3] do not cache gorush images. Signed-off-by: Bo-Yi Wu --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index fd14831..9cfcecc 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ docker_build: clean docker build --rm -t $(PRODUCTION_IMAGE) -f docker/Dockerfile.dist . docker_test: + docker-compose -p ${PROJECT} -f docker/docker-compose.testing.yml build --no-cache gorush docker-compose -p ${PROJECT} -f docker/docker-compose.testing.yml run --rm gorush docker-compose -p ${PROJECT} -f docker/docker-compose.testing.yml down