-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.travis.yml
124 lines (113 loc) · 4.22 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
dist: xenial
language: node_js
node_js:
- 13
os: linux
# easy way to get your local config: cat ${HOME}/.kube/config | base64 | pbcopy
env:
global:
# Docker variables
- DOCKER_PUBLIC_USERNAME=${DOCKER_PUBLIC_USERNAME:-openstad}
- DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-frontend}
# Gitops variables
- HELM_REPO_NAME=${HELM_REPO_NAME:-openstad-kubernetes}
- HELM_CHART_FOLDER=${HELM_CHART_FOLDER:-k8s/openstad}
- GITOPS_RELEASE_BRANCH=${GITOPS_RELEASE_BRANCH:-master}
- GITOPS_DEV_VALUES_FILE=${GITOPS_DEV_VALUES_FILE:-k8s/openstad/environments/dev.values.yaml}
- GITOPS_ACC_VALUES_FILE=${GITOPS_ACC_VALUES_FILE:-k8s/openstad/environments/acc.values.yaml}
- GITOPS_PROD_VALUES_FILE=${GITOPS_PROD_VALUES_FILE:-k8s/openstad/environments/prod.values.yaml}
# Kube deploy variables
- K8S_DEPLOYMENT_NAME=openstad-frontend
- K8S_NAMESPACE=openstad
# Application variables
- FRONTED_PORT=4444
- FRONTEND_MONGO_SCHEME=mongodb://mongo
- FRONTEND_MONGO_DB_HOST=mongo
- FRONTEND_MONGO_PORT=27017
- FRONTEND_MINIFY_JS=ON
- COOKIE_SECURE_OFF=yes
- API=http://localhost:8111
- IMAGE_API_URL=http://localhost:3333
- IMAGE_API_ACCESS_TOKEN=xxxx
- IMAGE_API_ACCESS_TOKEN=xxxx
- SITE_API_KEY=xxxx
- DEFAULT_DB=localhost2
- DEFAULT_HOST=localhost:4444
- APP_URL=http://localhost:4444
- APOS_BUNDLE=assets
- APOS_MINIFY=1
- NODE_ENV=production
- IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${TRAVIS_BUILD_ID}
services:
- docker
- mongodb
addons:
snaps:
- name: yq
confinement: classic
channel: v3/stable
before_install:
- sleep 15
- mongo default --eval 'db.createUser({user:"travis",pwd:"test",roles:["readWrite"]});'
- echo 'start'
- echo '${TRAVIS_PULL_REQUEST_BRANCH:-TRAVIS_BRANCH}'
- echo '${TRAVIS_PULL_REQUEST_BRANCH:-TRAVIS_BRANCH}' > branch.txt
- npm install --production
- npm run test -- --coverage
- mkdir assets
- NODE_ENV=production APOS_MINIFY=1 APOS_WORKFLOW=ON APOS_BUNDLE=assets node apostrophe.js apostrophe:generation --create-bundle assets
- docker build -t ${IMAGE_TAG} .
stages:
- name: docker_publish
if: branch = master
- name: docker_push_tag
if: tag IS present
- name: kubectl_deploy_dev
if: env(KUBE_CONFIG) IS present AND branch = development
- name: kubectl_deploy_acc
if: env(KUBE_CONFIG) IS present AND branch = release
- name: kubectl_deploy_prod
if: env(KUBE_CONFIG) IS present AND branch = master
- name: gitops_dev
if: env(GITOPS) IS present AND branch =~ /development|feature\/.*/
- name: gitops_acc
if: env(GITOPS) IS present AND branch =~ /staging|release|release\/.*/
- name: gitops_prod
if: env(GITOPS) IS present AND tag IS present
jobs:
include:
- stage: docker_push
name: 'Publish new docker image'
script: bash docker_publish_latest
- stage: docker_push_tag
name: 'Push new image with tag to docker'
env:
- IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${TRAVIS_BUILD_ID}
script: bash docker_publish_tag
- stage: kubectl_deploy_dev
name: "Deploy: Kubectl set image to DEV environment"
script: bash docker_deploy
- stage: kubectl_deploy_acc
name: "Deploy: Kubectl set image to ACC environment"
script: bash docker_deploy
- stage: kubectl_deploy_prod
name: "Deploy: Kubectl set image to PROD environment"
script: bash docker_deploy
- stage: gitops_dev
name: "Release and commit new image tag to DEV environment"
env:
- IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${TRAVIS_BUILD_ID}
- GITOPS_VALUES_FILE=${GITOPS_DEV_VALUES_FILE}
script: bash gitops_push
- stage: gitops_acc
name: "Release and commit new image tag to ACC environment"
env:
- IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${TRAVIS_BUILD_ID}
- GITOPS_VALUES_FILE=${GITOPS_ACC_VALUES_FILE}
script: bash gitops_push
- stage: gitops_prod
name: "Release and commit new image tag to PROD environment"
env:
- IMAGE_TAG=${DOCKER_PUBLIC_USERNAME}/${DOCKER_IMAGE_NAME}:${TRAVIS_TAG}
- GITOPS_VALUES_FILE=${GITOPS_PROD_VALUES_FILE}
script: bash gitops_push