mirror of
https://github.com/gsi-upm/senpy
synced 2025-09-17 12:02:21 +00:00
Compare commits
8 Commits
0.8.8
...
0.8.8-fix3
Author | SHA1 | Date | |
---|---|---|---|
|
2ea01aef42 | ||
|
147fd4a333 | ||
|
e31bca7016 | ||
|
7956d54c35 | ||
|
0f8d1dff69 | ||
|
236183593c | ||
|
7637498517 | ||
|
ce83fb3981 |
@@ -1,18 +1,19 @@
|
|||||||
image: gsiupm/dockermake:latest
|
# Uncomment if you want to use docker-in-docker
|
||||||
|
# image: gsiupm/dockermake:latest
|
||||||
|
# services:
|
||||||
|
# - docker:dind
|
||||||
# When using dind, it's wise to use the overlayfs driver for
|
# When using dind, it's wise to use the overlayfs driver for
|
||||||
# improved performance.
|
# improved performance.
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay
|
|
||||||
DOCKERFILE: Dockerfile
|
|
||||||
IMAGENAME: $CI_REGISTRY_IMAGE
|
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- push
|
- push
|
||||||
|
- deploy
|
||||||
- clean
|
- clean
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- docker login -u $HUB_USER -p $HUB_PASSWORD
|
||||||
|
|
||||||
.test: &test_definition
|
.test: &test_definition
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
@@ -28,11 +29,8 @@ test-2.7:
|
|||||||
variables:
|
variables:
|
||||||
PYTHON_VERSION: "2.7"
|
PYTHON_VERSION: "2.7"
|
||||||
|
|
||||||
|
|
||||||
.image: &image_definition
|
.image: &image_definition
|
||||||
stage: push
|
stage: push
|
||||||
before_script:
|
|
||||||
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
|
|
||||||
script:
|
script:
|
||||||
- make -e push-$PYTHON_VERSION
|
- make -e push-$PYTHON_VERSION
|
||||||
only:
|
only:
|
||||||
@@ -57,9 +55,44 @@ push-latest:
|
|||||||
- master
|
- master
|
||||||
- triggers
|
- triggers
|
||||||
|
|
||||||
clean :
|
push-github:
|
||||||
|
stage: deploy
|
||||||
|
script:
|
||||||
|
- make -e push-github
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
- triggers
|
||||||
|
|
||||||
|
deploy_pypi:
|
||||||
|
stage: deploy
|
||||||
|
script: # Configure the PyPI credentials, then push the package, and cleanup the creds.
|
||||||
|
- echo "[server-login]" >> ~/.pypirc
|
||||||
|
- echo "username=" ${PYPI_USER} >> ~/.pypirc
|
||||||
|
- echo "password=" ${PYPI_PASSWORD} >> ~/.pypirc
|
||||||
|
- make pip_upload
|
||||||
|
- echo "" > ~/.pypirc && rm ~/.pypirc # If the above fails, this won't run.
|
||||||
|
only:
|
||||||
|
- /^v\d+\.\d+\.\d+([abc]\d*)?$/ # PEP-440 compliant version (tags)
|
||||||
|
except:
|
||||||
|
- branches
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
environment: test
|
||||||
|
script:
|
||||||
|
- make -e deploy
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|
||||||
|
clean_docker :
|
||||||
stage: clean
|
stage: clean
|
||||||
script:
|
script:
|
||||||
- make -e clean
|
- make -e clean
|
||||||
only:
|
when: manual
|
||||||
- master
|
|
||||||
|
cleanup_pypirc:
|
||||||
|
stage: clean
|
||||||
|
when: always # this is important; run even if preceding stages failed.
|
||||||
|
script:
|
||||||
|
- rm -vf ~/.pypirc # we don't want to leave these around, but GitLab may clean up anyway.
|
||||||
|
- docker logout
|
||||||
|
69
Makefile
69
Makefile
@@ -1,14 +1,30 @@
|
|||||||
|
NAME=senpy
|
||||||
|
VERSION=$(shell git describe --tags --dirty 2>/dev/null)
|
||||||
|
GITHUB_REPO=git@github.com:gsi-upm/senpy.git
|
||||||
|
|
||||||
|
IMAGENAME=gsiupm/senpy
|
||||||
|
IMAGEWTAG=$(IMAGENAME):$(VERSION)
|
||||||
|
|
||||||
PYVERSIONS=3.5 2.7
|
PYVERSIONS=3.5 2.7
|
||||||
PYMAIN=$(firstword $(PYVERSIONS))
|
PYMAIN=$(firstword $(PYVERSIONS))
|
||||||
NAME=senpy
|
|
||||||
REPO=gsiupm
|
|
||||||
VERSION=$(shell git describe --tags --dirty 2>/dev/null)
|
|
||||||
TARNAME=$(NAME)-$(VERSION).tar.gz
|
|
||||||
IMAGENAME=$(REPO)/$(NAME)
|
|
||||||
IMAGEWTAG=$(IMAGENAME):$(VERSION)
|
|
||||||
DEVPORT=5000
|
DEVPORT=5000
|
||||||
|
|
||||||
|
TARNAME=$(NAME)-$(VERSION).tar.gz
|
||||||
action="test-${PYMAIN}"
|
action="test-${PYMAIN}"
|
||||||
|
|
||||||
|
KUBE_CA_PEM_FILE=""
|
||||||
|
KUBE_URL=""
|
||||||
|
KUBE_TOKEN=""
|
||||||
|
KUBE_NAMESPACE=$(NAME)
|
||||||
|
KUBECTL=docker run --rm -v $(KUBE_CA_PEM_FILE):/tmp/ca.pem -v $$PWD:/tmp/cwd/ -i lachlanevenson/k8s-kubectl --server="$(KUBE_URL)" --token="$(KUBE_TOKEN)" --certificate-authority="/tmp/ca.pem" -n $(KUBE_NAMESPACE)
|
||||||
|
CI_REGISTRY=docker.io
|
||||||
|
CI_REGISTRY_USER=gitlab
|
||||||
|
CI_BUILD_TOKEN=""
|
||||||
|
CI_COMMIT_REF_NAME=master
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: build run
|
all: build run
|
||||||
|
|
||||||
.FORCE:
|
.FORCE:
|
||||||
@@ -18,7 +34,7 @@ version: .FORCE
|
|||||||
@echo $(VERSION)
|
@echo $(VERSION)
|
||||||
|
|
||||||
yapf:
|
yapf:
|
||||||
yapf -i -r senpy
|
yapf -i -r $(NAME)
|
||||||
yapf -i -r tests
|
yapf -i -r tests
|
||||||
|
|
||||||
init:
|
init:
|
||||||
@@ -37,7 +53,7 @@ quick_build: $(addprefix build-, $(PYMAIN))
|
|||||||
build: $(addprefix build-, $(PYVERSIONS))
|
build: $(addprefix build-, $(PYVERSIONS))
|
||||||
|
|
||||||
build-%: version Dockerfile-%
|
build-%: version Dockerfile-%
|
||||||
docker build -t '$(IMAGEWTAG)-python$*' -f Dockerfile-$* .;
|
docker build -t '$(IMAGEWTAG)-python$*' --cache-from $(IMAGENAME):python$* -f Dockerfile-$* .;
|
||||||
|
|
||||||
quick_test: $(addprefix test-,$(PYMAIN))
|
quick_test: $(addprefix test-,$(PYMAIN))
|
||||||
|
|
||||||
@@ -53,8 +69,8 @@ dev: dev-$(PYMAIN)
|
|||||||
|
|
||||||
test-all: $(addprefix test-,$(PYVERSIONS))
|
test-all: $(addprefix test-,$(PYVERSIONS))
|
||||||
|
|
||||||
test-%: build-%
|
test-%:
|
||||||
docker run --rm --entrypoint /usr/local/bin/python -w /usr/src/app $(IMAGEWTAG)-python$* setup.py test
|
docker run --rm --entrypoint /usr/local/bin/python -w /usr/src/app $(IMAGENAME):python$* setup.py test
|
||||||
|
|
||||||
test: test-$(PYMAIN)
|
test: test-$(PYMAIN)
|
||||||
|
|
||||||
@@ -70,9 +86,12 @@ pip_test-%: sdist
|
|||||||
|
|
||||||
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
|
pip_test: $(addprefix pip_test-,$(PYVERSIONS))
|
||||||
|
|
||||||
|
pip_upload: pip_test
|
||||||
|
python setup.py sdist upload ;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@docker ps -a | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true
|
@docker ps -a | grep $(IMAGENAME) | awk '{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1;}}' | xargs docker rm -v 2>/dev/null|| true
|
||||||
@docker images | awk '/$(REPO)\/$(NAME)/{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
@docker images | grep $(IMAGENAME) | awk '{ split($$2, vers, "-"); if(vers[0] != "${VERSION}"){ print $$1":"$$2;}}' | xargs docker rmi 2>/dev/null|| true
|
||||||
@docker stop $(addprefix $(NAME)-dev,$(PYVERSIONS)) 2>/dev/null || true
|
@docker stop $(addprefix $(NAME)-dev,$(PYVERSIONS)) 2>/dev/null || true
|
||||||
@docker rm $(addprefix $(NAME)-dev,$(PYVERSIONS)) 2>/dev/null || true
|
@docker rm $(addprefix $(NAME)-dev,$(PYVERSIONS)) 2>/dev/null || true
|
||||||
|
|
||||||
@@ -85,20 +104,22 @@ git_tag:
|
|||||||
git_push:
|
git_push:
|
||||||
git push --tags origin master
|
git push --tags origin master
|
||||||
|
|
||||||
pip_upload: pip_test
|
|
||||||
python setup.py sdist upload ;
|
|
||||||
|
|
||||||
run-%: build-%
|
run-%: build-%
|
||||||
docker run --rm -p $(DEVPORT):5000 -ti '$(IMAGEWTAG)-python$(PYMAIN)' --default-plugins
|
docker run --rm -p $(DEVPORT):5000 -ti '$(IMAGEWTAG)-python$(PYMAIN)' --default-plugins
|
||||||
|
|
||||||
run: run-$(PYMAIN)
|
run: run-$(PYMAIN)
|
||||||
|
|
||||||
push-latest: build-$(PYMAIN)
|
push-latest: $(addprefix push-latest-,$(PYVERSIONS))
|
||||||
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
||||||
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGENAME)'
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGENAME)'
|
||||||
docker push '$(IMAGENAME):latest'
|
docker push '$(IMAGENAME):latest'
|
||||||
docker push '$(IMAGEWTAG)'
|
docker push '$(IMAGEWTAG)'
|
||||||
|
|
||||||
|
push-latest-%: build-%
|
||||||
|
docker tag $(IMAGENAME):$(VERSION)-python$* $(IMAGENAME):python$*
|
||||||
|
docker push $(IMAGENAME):$(VERSION)-python$*
|
||||||
|
docker push $(IMAGENAME):python$*
|
||||||
|
|
||||||
push-%: build-%
|
push-%: build-%
|
||||||
docker push $(IMAGENAME):$(VERSION)-python$*
|
docker push $(IMAGENAME):$(VERSION)-python$*
|
||||||
|
|
||||||
@@ -106,7 +127,21 @@ push: $(addprefix push-,$(PYVERSIONS))
|
|||||||
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
docker tag '$(IMAGEWTAG)-python$(PYMAIN)' '$(IMAGEWTAG)'
|
||||||
docker push $(IMAGENAME):$(VERSION)
|
docker push $(IMAGENAME):$(VERSION)
|
||||||
|
|
||||||
|
push-github:
|
||||||
|
$(eval KEY_FILE := $(shell mktemp))
|
||||||
|
@echo "$$GITHUB_DEPLOY_KEY" > $(KEY_FILE)
|
||||||
|
@git remote rm github-deploy || true
|
||||||
|
git remote add github-deploy $(GITHUB_REPO)
|
||||||
|
@GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git push github-deploy $(CI_COMMIT_REF_NAME)
|
||||||
|
rm $(KEY_FILE)
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
gitlab-runner exec docker --docker-volumes /var/run/docker.sock:/var/run/docker.sock --env CI_PROJECT_NAME=$(NAME) ${action}
|
gitlab-runner exec docker --docker-volumes /var/run/docker.sock:/var/run/docker.sock --env CI_PROJECT_NAME=$(NAME) ${action}
|
||||||
|
|
||||||
.PHONY: test test-% test-all build-% build test pip_test run yapf push-main push-% dev ci version .FORCE
|
deploy:
|
||||||
|
@$(KUBECTL) delete secret $(CI_REGISTRY) || true
|
||||||
|
@$(KUBECTL) create secret docker-registry $(CI_REGISTRY) --docker-server=$(CI_REGISTRY) --docker-username=$(CI_REGISTRY_USER) --docker-email=$(CI_REGISTRY_USER) --docker-password=$(CI_BUILD_TOKEN)
|
||||||
|
@$(KUBECTL) apply -f /tmp/cwd/k8s/
|
||||||
|
|
||||||
|
|
||||||
|
.PHONY: test test-% test-all build-% build test pip_test run yapf push-main push-% dev ci version .FORCE deploy
|
||||||
|
7
k8s/README.md
Normal file
7
k8s/README.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Deploy senpy to a kubernetes cluster.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
```
|
||||||
|
kubectl apply -f . -n senpy
|
||||||
|
```
|
25
k8s/senpy-deployment.yaml
Normal file
25
k8s/senpy-deployment.yaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: senpy-latest
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
role: senpy-latest
|
||||||
|
app: test
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: senpy-latest
|
||||||
|
image: gsiupm/senpy:latest
|
||||||
|
args:
|
||||||
|
- "--default-plugins"
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "512Mi"
|
||||||
|
cpu: "1000m"
|
||||||
|
ports:
|
||||||
|
- name: web
|
||||||
|
containerPort: 5000
|
14
k8s/senpy-ingress.yaml
Normal file
14
k8s/senpy-ingress.yaml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: senpy-ingress
|
||||||
|
spec:
|
||||||
|
rules:
|
||||||
|
- host: latest.senpy.cluster.gsi.dit.upm.es
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- path: /
|
||||||
|
backend:
|
||||||
|
serviceName: senpy-latest
|
||||||
|
servicePort: 5000
|
12
k8s/senpy-svc.yaml
Normal file
12
k8s/senpy-svc.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: senpy-latest
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 5000
|
||||||
|
protocol: TCP
|
||||||
|
selector:
|
||||||
|
role: senpy-latest
|
Reference in New Issue
Block a user