Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

- Restricted filesystem usage for journal service and file rotation strategy [#10518](https://github.com/opencrvs/opencrvs-core/issues/10518))

- Tiltfile: Improved Kubernetes support for development environment [#10672](https://github.com/opencrvs/opencrvs-core/issues/10672)

### Bug fixes

Expand Down
96 changes: 17 additions & 79 deletions Tiltfile
Original file line number Diff line number Diff line change
@@ -1,93 +1,31 @@
############################################################
# 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"
##########################################################################
# Tiltfile: OpenCRVS Country config developer
# For more information about variables, please check:
# https://github.com/opencrvs/infrastructure/blob/develop/Tiltfile

# 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)
core_images_tag = "develop"
# Build countryconfig image in local registry (use any name and tag you want)
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
load('ext://git_resource', 'git_checkout')
if not os.path.exists('../infrastructure'):
local("git clone [email protected]: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'])


# Load extensions for namespace and helm operations
load('ext://helm_resource', 'helm_resource', 'helm_repo')
load('ext://namespace', 'namespace_create', 'namespace_inject')
load("../infrastructure/tilt/lib.tilt", "copy_secrets", "reset_environment", "seed_data")

include('../infrastructure/tilt/common.tilt')

# If your machine is powerful feel free to change parallel updates from default 3
# update_settings(max_parallel_updates=3)
# FIXME: Replace ocrvs-10672 to develop after testing
git_checkout('[email protected]:opencrvs/infrastructure.git#ocrvs-10672', '../infrastructure')
if not os.path.exists('../infrastructure/tilt/opencrvs.tilt'):
fail('Something went wrong while cloning infrastructure repository!')
load('../infrastructure/tilt/opencrvs.tilt', 'setup_opencrvs')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this local path? I assume that I would not have the file in place

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not os.path.exists('../infrastructure'):
    local("git clone [email protected]:opencrvs/infrastructure.git ../infrastructure")

load('../infrastructure/tilt/opencrvs.tilt', 'setup_opencrvs')

Ah, I see. As long we have it somewhere written down that these repos need to live side by side.

Other way would be to introduce INFRA_REPOSITORY_PATH to allow ay config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish to parametrise repository path, but tiltfile has limitations:

# ✅ Correct - string literal
load('../infrastructure/tilt/opencrvs.tilt', 'setup_opencrvs')

# ❌ Wrong - variable
lib_path = '../infrastructure/tilt/opencrvs.tilt'
load(lib_path, 'setup_opencrvs')

load doesn't support variables. In next iteration I will try to publish opencrvs.tilt as external module


# Build countryconfig image
docker_build(countryconfig_image_name, ".",
dockerfile="Dockerfile",
network="host")

# Create namespaces:
# - opencrvs-deps-dev, dependencies namespace
# - opencrvs-dev, main namespace
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)
]
)
setup_opencrvs(
infrastructure_path='../infrastructure',
core_images_tag=core_images_tag,
countryconfig_image_name=countryconfig_image_name,
countryconfig_image_tag=countryconfig_image_tag,
)

#######################################################
# Add Data Tasks to Tilt Dashboard
reset_environment(opencrvs_namespace, opencrvs_configuration_file)

seed_data(opencrvs_namespace, opencrvs_configuration_file)

if security_enabled:
copy_secrets(dependencies_namespace, opencrvs_namespace)

print("✅ Tiltfile configuration loaded successfully.")
Loading