Makefile 2.12 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
NAME=senpy
REPO=gsiupm
VERSION=$(shell cat $(NAME)/VERSION)


all: build run

dockerfiles: $(addprefix Dockerfile-,$(PYVERSIONS))
11
	ln -s Dockerfile-$(PYMAIN) Dockerfile
12
13
14
15

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

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

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

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

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

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

27
28
29
debug-%: build-%
	docker run --rm -w /usr/src/app/ -v $$PWD:/usr/src/app --entrypoint=/bin/bash -ti '$(REPO)/$(NAME):$(VERSION)-python$*' ;

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

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
33
34
35
36
37
38
39
40
41
dist/$(NAME)-$(VERSION).tar.gz:
	docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) python setup.py sdist;

sdist: dist/$(NAME)-$(VERSION).tar.gz

pip_test-%: sdist
	docker run --rm -v $$PWD/dist:/dist/ -ti python:$* pip install /dist/$(NAME)-$(VERSION).tar.gz ;

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

upload-%: test-%
44
	docker push '$(REPO)/$(NAME):$(VERSION)-python$*'
45

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
46
47
upload: testall $(addprefix upload-,$(PYVERSIONS))
	docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME):$(VERSION)'
48
49
50
51
52
53
54
	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
55
56
57
58
upload_git:
	git commit -a
	git tag ${VERSION}
	git push --tags origin master
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
59

J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
60
61
pip_upload:
	python setup.py sdist upload ;
J. Fernando Sánchez's avatar
J. Fernando Sánchez committed
62

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

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

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