2016-09-21 08:10:49 +00:00
|
|
|
PYVERSIONS=3.4 2.7
|
2016-09-21 16:59:28 +00:00
|
|
|
PYMAIN=$(firstword $(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
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-$*
|
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
build: $(addprefix build-, $(PYMAIN))
|
|
|
|
|
|
|
|
buildall: $(addprefix build-, $(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
build-%: Dockerfile-%
|
|
|
|
docker build -t '$(REPO)/$(NAME):$(VERSION)-python$*' -f Dockerfile-$* .;
|
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
test: $(addprefix test-,$(PYMAIN))
|
|
|
|
|
|
|
|
testall: $(addprefix test-,$(PYVERSIONS))
|
2016-09-20 18:55:59 +00:00
|
|
|
|
|
|
|
test-%: build-%
|
2016-09-21 16:59:28 +00:00
|
|
|
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)'
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
upload: testall $(addprefix upload-,$(PYVERSIONS))
|
|
|
|
docker tag '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)' '$(REPO)/$(NAME):$(VERSION)'
|
2016-09-21 18:27:30 +00:00
|
|
|
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
|
|
|
|
|
2016-09-21 18:29:16 +00:00
|
|
|
upload_git:
|
|
|
|
git commit -a
|
|
|
|
git tag ${VERSION}
|
|
|
|
git push --tags origin master
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
pip_upload:
|
|
|
|
python setup.py sdist upload ;
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
|
2016-09-21 08:10:49 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
run: build
|
|
|
|
docker run --rm -p 5000:5000 -ti '$(REPO)/$(NAME):$(VERSION)-python$(PYMAIN)'
|
2016-09-20 18:55:59 +00:00
|
|
|
|
2016-09-21 16:59:28 +00:00
|
|
|
.PHONY: test test-% build-% build test test_pip run
|