forked from opencrvs/opencrvs-farajaland
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTiltfile
More file actions
101 lines (86 loc) · 4.15 KB
/
Tiltfile
File metadata and controls
101 lines (86 loc) · 4.15 KB
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
############################################################
# Please check readme at: https://github.com/opencrvs/infrastructure/tree/develop
############################################################
# Variables declaration:
# Core images tag: usually "develop" or one of release name:
# - v1.7.0
# - v1.7.1
# NOTE: It could take any value from https://github.com/orgs/opencrvs/packages
# If you are under opencrvs-core repository, please use "local" tag
# Tilt will build new image every time when changes are made to repository
core_images_tag="develop"
# Countryconfig/Farajaland image repository and tag
# Usually image repository value is to your repository on DockerHub
# If for some reason you don't have DockerHub account yet, please create
# you local registry
# (see: https://medium.com/@ankitkumargupta/quick-start-local-docker-registry-35107038242e)
countryconfig_image_name="opencrvs/ocrvs-countryconfig"
# If you are under opencrvs-countryconfig or your own repository, please use "local" tag,
# Tilt will build new image every time when changes are made to repository
countryconfig_image_tag="local"
# Namespaces:
opencrvs_namespace = 'opencrvs-dev'
dependencies_namespace = 'opencrvs-deps-dev'
# Checkout infrastructure directory if not exists
if not os.path.exists('../infrastructure'):
local("git clone git@github.com:opencrvs/infrastructure.git ../infrastructure")
local_resource('README.md', cmd='awk "/For OpenCRVS Country Config Developers/{flag=1; next} /Seed data/{flag=0} flag" ../infrastructure/README.md', labels=['0.Readme'])
############################################################
# What common Tiltfile does?
# - Group resources by label on UI: http://localhost:10350/
include('../infrastructure/tilt/Tiltfile.common')
# Load extensions for namespace and helm operations
load('ext://namespace', 'namespace_create', 'namespace_inject')
load('ext://helm_resource', 'helm_resource', 'helm_repo')
# If your machine is powerful feel free to change parallel updates from default 3
# update_settings(max_parallel_updates=3)
# Build countryconfig image
docker_build(countryconfig_image_name, ".",
dockerfile="Dockerfile",
network="host")
# Create namespaces:
# - traefik, ingress controller (https://opencrvs.localhost)
# - opencrvs-deps-dev, dependencies namespace
# - opencrvs-dev, main namespace
namespace_create('traefik')
namespace_create(dependencies_namespace)
namespace_create(opencrvs_namespace)
# Install Traefik GW
helm_repo('traefik-repo', 'https://traefik.github.io/charts', labels=['Dependencies'])
helm_resource(
'traefik', 'traefik-repo/traefik', namespace='traefik', resource_deps=['traefik-repo'],
flags=['--values=../infrastructure/infrastructure/localhost/traefik/values.yaml'])
######################################################
# OpenCRVS Dependencies Deployment
# NOTE: This helm chart can be deployed as helm release
k8s_yaml(helm('../infrastructure/charts/dependencies',
namespace=dependencies_namespace,
values=['../infrastructure/infrastructure/localhost/dependencies/values-dev.yaml']))
######################################################
# OpenCRVS Deployment
k8s_yaml(
helm('../infrastructure/charts/opencrvs-services',
namespace=opencrvs_namespace,
values=['../infrastructure/infrastructure/localhost/opencrvs-services/values-dev.yaml'],
set=[
"image.tag={}".format(core_images_tag),
"countryconfig.image.name={}".format(countryconfig_image_name),
"countryconfig.image.tag={}".format(countryconfig_image_tag)
]
)
)
######################################################
# Data management tasks:
# - Reset database: This task is not part of helm deployment to avoid accidental data loss
# - Seed data: is part of helm install post-deploy hook, but it is a manual task as well
# - Run migration job, is part of helm install/upgrade post-deploy hook
cleanup_command = "../infrastructure/infrastructure/clear-all-data.k8s.sh --dependencies-namespace {1} -o {0}".format(
opencrvs_namespace, dependencies_namespace
)
local_resource(
'Reset database',
labels=['2.Data-tasks'],
auto_init=False,
cmd=cleanup_command,
trigger_mode=TRIGGER_MODE_MANUAL,
)