Makefile 1.69 KB
Newer Older
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
1
PYVERSIONS=3.4 2.7
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
2
PYMAIN=$(firstword $(PYVERSIONS))
3
4
5
6
7
8
9
10
11
12
13
14
NAME=senpy
REPO=gsiupm
VERSION=$(shell cat $(NAME)/VERSION)


all: build run

dockerfiles: $(addprefix Dockerfile-,$(PYVERSIONS))

Dockerfile-%: Dockerfile.template
	sed "s/{{PYVERSION}}/$*/" Dockerfile.template > Dockerfile-$*

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
15
16
17
build: $(addprefix build-, $(PYMAIN))

buildall: $(addprefix build-, $(PYVERSIONS))
18
19
20
21

build-%: Dockerfile-%
	docker build -t '$(REPO)/$(NAME):$(VERSION)-python$*' -f Dockerfile-$* .;

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
22
23
24
test: $(addprefix test-,$(PYMAIN))

testall: $(addprefix test-,$(PYVERSIONS))
25
26

test-%: build-%
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
27
28
29
30
31
32
33
	docker run --rm -w /usr/src/app/ --entrypoint=/usr/local/bin/python -ti '$(REPO)/$(NAME):$(VERSION)-python$*' setup.py test --addopts "-vvv -s --pdb" ;

pip_test-%:
	docker run --rm -ti python:$* pip install senpy ;

upload-%: test-%
	docker push '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)'
34

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
35
36
upload: testall $(addprefix upload-,$(PYVERSIONS))
	docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME):$(VERSION)'
37
38
39
40
41
42
43
	docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME)'
	docker push '$(REPO)/$(NAME):$(VERSION)'

clean:
	@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1;}}' | xargs docker rm 2>/dev/null|| true
	@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[1] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
44
45
46
47
upload_git:
	git commit -a
	git tag ${VERSION}
	git push --tags origin master
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
48

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
49
50
pip_upload:
	python setup.py sdist upload ;
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
51

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
52
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
53

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
54
55
run: build
	docker run --rm -p 5000:5000 -ti '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)'
56

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
57
.PHONY: test test-% build-% build test test_pip run