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

v1.2.0 support test, build and deploy in gocd

- added make ci-build and make deploy
- added app.yaml for k8s based deploy
- after-install.sh no longer run make install
- utils/build-deb grep add -q option
- Dockerfile.template apt use -qq option
parent 60a98f47
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
* COMMENT -*- mode: org -*-
#+Date: 2014-05-09
Time-stamp: <2016-09-08>
Time-stamp: <2018-05-02>
#+STARTUP: content
* notes								      :entry:
** 2018-05-02 support test, build and deploy in gocd
- stage 1: testAndBuild
  make ci-build

  required env var:
  DOCKER_USER
  DOCKER_PASSWORD
  docker login info for private registry.

- stage 2: deploy
  make deploy

  required env var:
  KUBECTL_API
  KUBECTL_TOKEN
  kubectl auth info for running kubectl apply.

- implemented in v1.2.0

  in gocd, use the python-app pipeline template to automate stages and jobs.

* current							      :entry:
** 
** 2016-09-08 support updating site file, deb scripts etc after project is generated.
@@ -26,9 +48,6 @@ unit tests against defined python in tox.ini.

** 2016-08-07 in python project template, add a project wide pylintrc file.
see example ~/.pylintrc
** 2016-07-27 package name should not have -, auto convert it to _.
- package name is part of module name, - is not valid there.

** 2016-06-30 update it for use with default debian config. (non-yy env)
- update nginx config file
- add support for systemd
@@ -39,6 +58,9 @@ see example ~/.pylintrc
** 2014-05-09 add sphinx support
* later								      :entry:
* done								      :entry:
** 2016-07-27 package name should not have -, auto convert it to _.
- package name is part of module name, - is not valid there.

** 2016-09-08 when bootstrap, create /var/log/{{name}} dir using sudo and chown to current user.
this makes it easier when developing.

+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "1.1.0"
(defproject python/lein-template "1.2.0"
  :description "lein template for a python project"
  :repositories [["snapshots"
                  {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots"
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
                        "requirements-dev.txt"
                        "setup.py"
                        "Dockerfile.template"
                        "app.yaml"
                        "README.rst"
                        "utils/versionutils.py"
                        "utils/build-deb"
+2 −2
Original line number Diff line number Diff line
@@ -3,8 +3,8 @@ FROM sylecn/debian:stretch-slim-cn
#LABEL description="TODO add image description and uncomment this"

RUN set -x \
    && apt-get update \
    && apt-get install -y --no-install-recommends --no-install-suggests \
    && apt-get update -qq \
    && apt-get install -qq -y --no-install-recommends --no-install-suggests \
       DEPENDS \
    && rm -rf /var/lib/apt/lists/*

+14 −1
Original line number Diff line number Diff line
@@ -15,7 +15,9 @@ DEV_REQUIREMENTS := -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 := sylecn
DOCKER_IMAGE_PREFIX := de02-reg.emacsos.com/sylecn

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

default: check-coding-style
build:
@@ -77,6 +79,17 @@ test: check-coding-style
just-test:
	$(PYTEST) $(PYTHON_MODULES)

# 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 $(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

install-dev-no-wheel:
	$(PIP) install -q -i https://pypi.tuna.tsinghua.edu.cn/simple $(DEV_REQUIREMENTS)
test-prod: install-dev-no-wheel test
Loading