Commit 6ca40380 authored by Yuanle Song's avatar Yuanle Song
Browse files

v1.8.0 allow set some k8s config via env variable;

- allow set DOCKER_IMAGE_PREFIX and KUBECTL_CA_PATH via env variable
- bugfix: properly escape DOCKER_PASSWORD when running docker login
- bugfix: properly config cache for pip when running "make ci-build"
  it needs a dir at /.cache that the current user can write into, inside
  the "docker run" docker container.
parent cf77a77a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "1.7.0"
(defproject python/lein-template "1.8.0"
  :description "lein template for a python project"
  :url "https://gitlab.emacsos.com/sylecn/python-project-template"
  :license {:name "Apache License 2.0"
+7 −5
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@ REQUIREMENTS := -r requirements.txt
REQUIREMENTS_DEV := -r requirements-dev.txt

VERSION := $(shell grep '__version__' {{python-pkg-name}}/__init__.py |cut -d'"' -f 2)
# docker hub user name or private registry URL with username.
DOCKER_IMAGE_PREFIX := de02-reg.emacsos.com/sylecn
# docker hub user name or private registry URL with username. do not end with /.
DOCKER_IMAGE_PREFIX ?= de02-reg.emacsos.com/sylecn
KUBECTL_CA_PATH ?= /etc/kubernetes/pki/ca.crt

BUILD_DOCKER_IMAGE := de02-reg.emacsos.com/sylecn/python-build-image:1.0.0

@@ -98,13 +99,14 @@ just-test:
# run test, build deb in python build image container, then create docker
# image and push image on host.
ci-build:
	docker login -u $(DOCKER_USER) -p $(DOCKER_PASSWORD) $(BUILD_DOCKER_IMAGE)
	docker run --rm --name {{ name }}-test -v "$(CURDIR)":/app -u $(shell id -u):$(shell id -g) $(BUILD_DOCKER_IMAGE) make test deb -C /app
	echo '$(value DOCKER_PASSWORD)' | docker login -u $(DOCKER_USER) --password-stdin $(BUILD_DOCKER_IMAGE)
	mkdir -p .cache
	docker run --rm --name {{ name }}-test -v "$(CURDIR)":/app -v "$(CURDIR)/.cache":/.cache -u $(shell id -u):$(shell id -g) $(BUILD_DOCKER_IMAGE) make test deb -C /app
	docker build -t $(DOCKER_IMAGE_PREFIX)/{{ name }}:$(VERSION) .
	docker push $(DOCKER_IMAGE_PREFIX)/{{ name }}:$(VERSION)
deploy:
	sed "s/IMAGE_TAG/$(VERSION)/" app.yaml > $(VERSION).yaml
	kubectl --certificate-authority=/etc/kubernetes/pki/ca.crt -s $(KUBECTL_API) --token=$(KUBECTL_TOKEN) apply -f $(VERSION).yaml
	kubectl --certificate-authority='$(KUBECTL_CA_PATH)' -s $(KUBECTL_API) --token=$(KUBECTL_TOKEN) apply -f $(VERSION).yaml

test-prod: requirements-dev test