forked from astrolox/ubuntu-16-apache-php-7.0-zend-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (50 loc) · 1.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
PWD = $(shell pwd)
IMAGE_NAME = $(shell basename ${PWD})
BASE_IMAGE = $(shell grep Dockerfile -e FROM | cut -d ' ' -f 2)
RSPEC_IMAGE = 1and1internet/ubuntu-16-rspec
TESTS_REPO = https://github.com/1and1internet/drone-tests.git
DOCKER_SOCKET = /var/run/docker.sock
BUILD_ARGS = --rm
RSPEC_ARGS =
# To use a locally modified copy of the tests repository set the TESTS_LOCAL variable to the absolute path of where it is located.
TESTS_LOCAL =
all: pull build test
pull:
##
## Pulling image updates from registry
##
for IMAGE in ${BASE_IMAGE} ${RSPEC_IMAGE}; \
do docker pull $${IMAGE}; \
done
build:
##
## Starting build of image ${IMAGE_NAME}
##
docker build ${BUILD_ARGS} --tag ${IMAGE_NAME} .
test:
##
## Starting tests inside a new container running ${RSPEC_IMAGE}
ifdef TESTS_LOCAL
## with tests from ${TESTS_LOCAL}
##
docker run --rm -i -t -v ${DOCKER_SOCKET}:/var/run/docker.sock -v ${PWD}/:/mnt/ -v ${TESTS_LOCAL}/:/drone-tests/ ${RSPEC_IMAGE} make run-rspec IMAGE_NAME=${IMAGE_NAME}
else
## with tests from ${TESTS_REPO}
##
docker run --rm -i -t -v ${DOCKER_SOCKET}:/var/run/docker.sock -v ${PWD}/:/mnt/ ${RSPEC_IMAGE} make do-test IMAGE_NAME=${IMAGE_NAME}
endif
do-test: checkout-drone-tests run-rspec
checkout-drone-tests:
mkdir ../drone-tests
git clone ${TESTS_REPO} ../drone-tests
run-rspec:
## Testing image ${IMAGE_NAME}
IMAGE=${IMAGE_NAME} rspec ${RSPEC_ARGS}
clean:
##
## Removing docker images .. most errors during this stage are ok, ignore them
##
for IMAGE in ${BASE_IMAGE} ${RSPEC_IMAGE}; \
do docker pull $${IMAGE}; \
done
.PHONY: all pull build test do-test checkout-drone-tests run-rspec clean