fp/Tiltfile

510 lines
15 KiB
Plaintext
Raw Normal View History

2024-07-10 02:34:23 +00:00
## Tiltfile for working with Futureporn cluster locally
secret_settings(
disable_scrub=True
)
2024-05-27 22:20:58 +00:00
## cert-manager slows down Tilt updates so I prefer to keep it commented unless I specifically need to test certs
2024-06-28 23:23:04 +00:00
load('ext://cert_manager', 'deploy_cert_manager')
deploy_cert_manager(
load_to_kind=True,
version='v1.15.1',
)
2024-06-04 23:06:47 +00:00
load('ext://helm_remote', 'helm_remote')
2024-06-12 04:28:36 +00:00
2024-07-10 02:34:23 +00:00
load('ext://dotenv', 'dotenv')
dotenv(fn='.env.development')
2024-06-04 23:06:47 +00:00
2024-06-18 02:21:08 +00:00
# helm_remote(
# 'velero',
# repo_name='velero',
# repo_url='https://vmware-tanzu.github.io/helm-charts',
# namespace='futureporn',
# version='6.6.0',
# set=[
# 'configuration.backupStorageLocation[0].name=dev',
# 'configuration.backupStorageLocation[0].provider=aws',
# 'configuration.backupStorageLocation[0].bucket=futureporn-db-backup-dev',
# 'configuration.backupStorageLocation[0].config.region=us-west-000',
# 'configuration.backupStorageLocation[0].config.s3ForcePathStyle=true',
# 'configuration.backupStorageLocation[0].config.s3Url=https://s3.us-west-000.backblazeb2.com',
# 'credentials.secretContents=cloud\n[default]\naws_access_key_id=AAAA\naws_secret_access_key=BBBB',
# 'snapshotsEnabled=false',
# # --set configuration.backupStorageLocation[0].name=<BACKUP STORAGE LOCATION NAME> \
# # --set configuration.backupStorageLocation[0].provider=<PROVIDER NAME> \
# # --set configuration.backupStorageLocation[0].bucket=<BUCKET NAME> \
# # --set configuration.backupStorageLocation[0].config.region=<REGION> \
# # --set configuration.volumeSnapshotLocation[0].name=<VOLUME SNAPSHOT LOCATION NAME> \
# # --set configuration.volumeSnapshotLocation[0].provider=<PROVIDER NAME> \
# # --set configuration.volumeSnapshotLocation[0].config.region=<REGION> \
# # --set initContainers[0].name=velero-plugin-for-<PROVIDER NAME> \
# # --set initContainers[0].image=velero/velero-plugin-for-<PROVIDER NAME>:<PROVIDER PLUGIN TAG> \
# # --set initContainers[0].volumeMounts[0].mountPath=/target \
# # --set initContainers[0].volumeMounts[0].name=plugins
# ]
# )
2024-06-28 23:23:04 +00:00
## this method results in the following error. Build Failed: Internal error occurred: failed calling webhook "webhook.cert-manager.io": failed to call webhook: Post "https://cert-manager-webhook.cert-manager.svc:443/validate?timeout=30s": service "cert-manager-webhook" not found
# helm_remote(
# 'cert-manager',
# repo_url='https://charts.jetstack.io',
# repo_name='cert-manager',
# namespace='cert-manager',
# version='1.15.1',
# set=[
# 'crds.enabled=true'
# ]
# )
2024-06-12 04:28:36 +00:00
helm_remote(
'traefik',
repo_name='traefik',
repo_url='https://traefik.github.io/charts',
2024-06-12 04:28:36 +00:00
namespace='futureporn',
version='28.3.0',
2024-06-12 04:28:36 +00:00
set=[
'globalArguments[0]=--global.sendanonymoususage=false',
2024-07-02 03:50:54 +00:00
'service.enabled=true',
2024-06-28 23:23:04 +00:00
'logs.access.enabled=true',
2024-07-02 03:50:54 +00:00
'logs.access.format=json',
'logs.general.level=DEBUG',
'logs.general.format=json',
'providers.kubernetesIngress.publishedService.enabled=true',
2024-06-12 04:28:36 +00:00
]
)
2024-06-04 23:06:47 +00:00
# helm_remote(
# 'nitter',
# repo_name='truecharts',
# repo_url='https://charts.truecharts.org',
# namespace='futureporn',
# version='7.1.4',
# )
2024-05-27 22:20:58 +00:00
# helm_remote(
# 'frp-operator',
# repo_name='frp-operator',
# repo_url='https://zufardhiyaulhaq.com/frp-operator/charts/releases/',
# namespace='futureporn',
# version='1.0.0'
# )
# helm_remote(
# 'kubernetes-ingress-controller',
# repo_name='kubernetes-ingress-controller',
# repo_url='https://ngrok.github.io/kubernetes-ingress-controller',
# namespace='futureporn',
# create_namespace='false',
# set=[
# 'credentials.apiKey=%s' % os.getenv('NGROK_API_KEY'),
# 'credentials.authtoken=%s' % os.getenv('NGROK_AUTHTOKEN')
# ]
# )
2024-05-29 23:43:47 +00:00
2024-06-04 23:06:47 +00:00
# k8s_yaml(helm(
# './charts/nitter',
# values=['./charts/nitter/values.yaml'],
# ))
2024-07-06 08:49:51 +00:00
2024-05-27 22:20:58 +00:00
k8s_yaml(helm(
'./charts/fp',
2024-07-10 02:34:23 +00:00
values=['./charts/fp/values.yaml'],
2024-05-27 22:20:58 +00:00
))
2024-07-10 02:34:23 +00:00
2024-05-27 22:20:58 +00:00
# docker_build('fp/link2cid', './packages/link2cid')
docker_build(
'fp/strapi',
'.',
2024-07-10 02:34:23 +00:00
only=['./packages/strapi', './packages/types'],
2024-07-04 21:20:29 +00:00
dockerfile='./d.strapi.dev.dockerfile',
2024-05-27 22:20:58 +00:00
live_update=[
sync('./packages/strapi', '/app')
]
)
2024-07-10 02:34:23 +00:00
docker_build(
'fp/bot',
'.',
only=['./pnpm-lock.yaml', './package.json', './packages/types', './packages/bot'],
dockerfile='./d.packages.dockerfile',
target='bot-dev',
live_update=[
sync('./packages/bot', '/app'),
run('cd /app && pnpm i', trigger=['./packages/bot/package.json', './packages/bot/pnpm-lock.yaml'])
]
)
2024-07-06 08:49:51 +00:00
2024-05-27 22:20:58 +00:00
2024-07-04 21:20:29 +00:00
2024-05-27 22:20:58 +00:00
load('ext://uibutton', 'cmd_button')
2024-06-12 04:28:36 +00:00
cmd_button('postgres:create',
2024-07-10 02:34:23 +00:00
argv=['./scripts/postgres-create.sh'],
2024-06-12 04:28:36 +00:00
resource='postgres',
icon_name='dataset',
text='create (empty) databases',
)
2024-05-27 22:20:58 +00:00
cmd_button('postgres:restore',
argv=['sh', './scripts/postgres-restore.sh'],
resource='postgres',
2024-06-12 04:28:36 +00:00
icon_name='upload',
2024-05-27 22:20:58 +00:00
text='restore db from backup',
)
cmd_button('postgres:drop',
argv=['sh', './scripts/postgres-drop.sh'],
resource='postgres',
icon_name='delete',
2024-06-12 04:28:36 +00:00
text='DROP futureporn_db'
)
cmd_button('postgres:drop_temporal',
argv=['sh', './scripts/postgres-drop-temporal.sh'],
resource='postgres',
icon_name='delete',
text='DROP temporal'
2024-05-27 22:20:58 +00:00
)
2024-05-29 23:43:47 +00:00
cmd_button('postgres:backup',
argv=['sh', './scripts/postgres-backup.sh'],
resource='postgres',
icon_name='download',
text='backup the database'
)
2024-06-12 04:28:36 +00:00
cmd_button('temporal-web:namespace',
argv=['sh', './scripts/temporal-namespaces.sh'],
resource='temporal-web',
icon_name='badge',
text='create futureporn namespace',
)
2024-05-27 22:20:58 +00:00
## Uncomment the following for fp/next in dev mode
## this is useful for changing the UI and seeing results
docker_build(
'fp/next',
'.',
2024-07-10 02:34:23 +00:00
# only=['./pnpm-lock.yaml', './package.json', './packages/next', './packages/types', './ca/letsencrypt-stg-root-x1.pem'],
2024-05-27 22:20:58 +00:00
dockerfile='d.next.dockerfile',
2024-07-10 02:34:23 +00:00
target='next',
2024-05-27 22:20:58 +00:00
build_args={
'NEXT_PUBLIC_STRAPI_URL': 'https://strapi.fp.sbtp.xyz'
2024-05-27 22:20:58 +00:00
},
live_update=[
sync('./packages/next', '/app')
]
)
docker_build(
2024-06-12 04:28:36 +00:00
'fp/scout-manager',
2024-05-27 22:20:58 +00:00
'.',
2024-07-10 02:34:23 +00:00
only=['./pnpm-lock.yaml', './package.json', './packages/scout', './packages/types', './ca/letsencrypt-stg-root-x1.pem'],
2024-07-06 08:49:51 +00:00
dockerfile='d.packages.dockerfile',
target='scout-manager',
2024-05-27 22:20:58 +00:00
live_update=[
2024-06-12 04:28:36 +00:00
sync('./packages/scout', '/app'),
run('cd /app && pnpm i', trigger=['./packages/scout/package.json', './packages/scout/pnpm-lock.yaml']),
],
entrypoint='pnpm nodemon --ext js,ts,json,yaml --exec node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/index.ts'
# entrypoint='pnpm tsx watch ./src/index.ts'
)
2024-07-10 02:34:23 +00:00
docker_build(
'fp/boop',
'.',
# only=['./pnpm-lock.yaml', './package.json', './packages/scout', './packages/types', './ca/letsencrypt-stg-root-x1.pem'],
dockerfile='d.packages.dockerfile',
target='boop',
live_update=[
sync('./packages/boop', '/app'),
# run('cd /app && pnpm i', trigger=['./packages/boop/package.json', './packages/boop/pnpm-lock.yaml']),
],
# entrypoint='pnpm nodemon --ext js,ts,json,yaml --exec node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/index.ts'
# entrypoint='pnpm tsx watch ./src/index.ts'
)
2024-06-12 04:28:36 +00:00
docker_build(
'fp/scout-worker',
'.',
2024-07-10 02:34:23 +00:00
only=['./pnpm-lock.yaml', './package.json', './packages/scout', './packages/types', './ca/letsencrypt-stg-root-x1.pem'],
2024-06-13 22:25:12 +00:00
# ignore=['./packages/next'], # I wish I could use this ignore to ignore file changes in this dir, but that's not how it works
2024-07-06 08:49:51 +00:00
dockerfile='d.packages.dockerfile',
2024-07-10 02:34:23 +00:00
target='scout-worker',
2024-06-12 04:28:36 +00:00
live_update=[
2024-06-13 22:25:12 +00:00
# idk if this run() is effective
# run('cd /app && pnpm i', trigger=['./packages/scout/package.json', './packages/scout/pnpm-lock.yaml']),
2024-06-12 04:28:36 +00:00
sync('./packages/scout', '/app'),
2024-06-13 05:17:44 +00:00
## this is a hack to avoid complete scout image rebuilds when src in ./packages/next is updated
## ./packages/next needs to be in the build context because scout depends on types exported from next module (a feature of pnpm workspaces)
## instead of a full rebuild, we put ./packages/next in the live_update spec so the changed files get shoved into /ignore-me
## ideally, I would like to include ./packages/next in the build context, but ignore file changes there for rebuilds.
## however, I don't think tilt has this capability.
sync('./packages/next', '/ignore-me'),
2024-06-12 04:28:36 +00:00
],
2024-06-13 22:51:25 +00:00
# this entrypoint is a godsend. It lets me restart the node app (fast) without having to rebuild the docker container (slow)
2024-06-12 04:28:36 +00:00
entrypoint='pnpm nodemon --ext js,ts,json,yaml --exec node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/temporal/worker.ts'
2024-05-27 22:20:58 +00:00
)
2024-07-10 02:34:23 +00:00
2024-05-27 22:20:58 +00:00
# k8s_resource(
# workload='kubernetes-ingress-controller-manager',
# links=[
# link(os.getenv('NGROK_URL'), 'Endpoint')
# ],
# labels='ngrok'
# )
# k8s_resource(
# workload='frp-operator-controller-manager',
# labels='tunnel'
# )
2024-07-06 08:49:51 +00:00
# k8s_resource(
# workload='echo',
# links=[
# link('https://echo.fp.sbtp.xyz'),
# link('http://echo.futureporn.svc.cluster.local:8001')
# ],
# labels='debug'
# )
k8s_resource(
2024-07-06 08:49:51 +00:00
workload='uppy',
links=[
2024-07-06 08:49:51 +00:00
link('https://uppy.fp.sbtp.xyz'),
],
2024-07-06 08:49:51 +00:00
resource_deps=['redis-master'],
labels=['backend'],
)
2024-05-27 22:20:58 +00:00
k8s_resource(
workload='next',
port_forwards=['3000'],
links=[
link('https://next.fp.sbtp.xyz'),
2024-06-12 04:28:36 +00:00
],
2024-07-04 21:20:29 +00:00
resource_deps=['strapi', 'postgres'],
labels=['frontend'],
2024-05-27 22:20:58 +00:00
)
k8s_resource(
workload='strapi',
port_forwards=['1339'],
links=[
2024-07-06 08:49:51 +00:00
link('https://strapi.fp.sbtp.xyz/admin'),
link('https://strapi.fp.sbtp.xyz'),
2024-06-12 04:28:36 +00:00
],
2024-07-04 21:20:29 +00:00
resource_deps=['postgres'],
labels=['backend'],
2024-05-27 22:20:58 +00:00
)
2024-06-01 02:43:44 +00:00
2024-05-27 22:20:58 +00:00
k8s_resource(
workload='postgres',
2024-07-02 03:50:54 +00:00
port_forwards=['5432'],
2024-07-04 21:20:29 +00:00
labels=['backend'],
2024-05-27 22:20:58 +00:00
)
2024-07-02 03:50:54 +00:00
k8s_resource(
workload='traefik',
port_forwards=['9000:9000'],
links=[
link('http://localhost:9000/dashboard')
],
2024-07-04 21:20:29 +00:00
labels=['networking'],
2024-07-02 03:50:54 +00:00
)
2024-07-04 21:20:29 +00:00
k8s_resource(
workload='scout-worker',
2024-07-06 08:49:51 +00:00
resource_deps=['postgres', 'strapi', 'temporal-frontend'],
2024-07-04 21:20:29 +00:00
labels=['backend'],
)
2024-06-12 04:28:36 +00:00
2024-07-04 21:20:29 +00:00
k8s_resource(
workload='scout-manager',
2024-07-06 08:49:51 +00:00
resource_deps=['postgres', 'strapi', 'temporal-frontend', 'scout-worker'],
2024-07-04 21:20:29 +00:00
labels=['backend'],
)
2024-06-12 04:28:36 +00:00
2024-07-10 02:34:23 +00:00
# k8s_resource(
# workload='',
# )
2024-06-04 23:06:47 +00:00
# k8s_resource(
# workload='pgadmin',
2024-06-12 04:28:36 +00:00
# port_forwards=['5050'],
# resource_deps=['postgres']
2024-06-04 23:06:47 +00:00
# )
2024-05-29 23:43:47 +00:00
2024-06-04 23:06:47 +00:00
# k8s_resource(
# workload='nitter',
# port_forwards=['6060:10606'],
2024-06-12 04:28:36 +00:00
# )
2024-07-04 21:20:29 +00:00
# temporarily disabled to save CPU resources
# helm_remote(
2024-07-04 21:20:29 +00:00
# 'kube-prometheus-stack',
# repo_name='kube-prometheus-stack',
# repo_url='https://prometheus-community.github.io/helm-charts',
# namespace='futureporn',
2024-07-04 21:20:29 +00:00
# version='61.1.1',
# set=[
2024-07-04 21:20:29 +00:00
# 'prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName=vultr-block-storage',
# 'admin.existingSecret=grafana',
# 'sidecar.dashboards.enabled=true',
# 'grafana.admin.existingSecret=grafana',
# 'grafana.sidecar.dashboards.enabled=true',
# 'grafana.sidecar.dashboards.defaultFolderName=balls',
# 'grafana.sidecar.dashboards.label=grafana_dashboard',
# 'grafana.sidecar.dashboards.provider.foldersFromFileStructure=true'
# ]
# )
2024-06-28 23:23:04 +00:00
2024-07-06 08:49:51 +00:00
helm_remote(
'redis',
repo_name='redis',
repo_url='https://charts.bitnami.com/bitnami',
namespace='futureporn',
version='19.6.1',
set=[
'auth.existingSecret=redis',
'auth.existingSecretPasswordKey=password',
'replica.persistence.enabled=false',
'architecture=standalone'
]
)
2024-07-04 21:20:29 +00:00
helm_remote(
'temporal',
repo_name='temporal',
repo_url='https://charts.lemontech.engineering',
namespace='futureporn',
version='0.37.0',
set=[
2024-07-10 02:34:23 +00:00
'admintools.image.tag=1.24.2-tctl-1.18.1-cli-0.13.0',
'web.image.tag=2.28.0',
2024-07-04 21:20:29 +00:00
'prometheus.enabled=false',
'grafana.enabled=false',
'elasticsearch.enabled=false',
'web.config.auth.enabled=true',
'cassandra.enabled=false',
'server.config.persistence.default.driver=sql',
'server.config.persistence.default.sql.driver=postgres12',
'server.config.persistence.default.sql.existingSecret=postgres',
'server.config.persistence.default.sql.secretName=postgres',
'server.config.persistence.default.sql.secretKey=password',
'server.config.persistence.default.sql.host=postgres.futureporn.svc.cluster.local',
'server.config.persistence.default.sql.port=5432',
'server.config.persistence.default.sql.user=postgres',
'server.config.persistence.visibility.driver=sql',
'server.config.persistence.visibility.sql.driver=postgres12',
'server.config.persistence.visibility.sql.host=postgres.futureporn.svc.cluster.local',
'server.config.persistence.visibility.sql.port=5432',
'server.config.persistence.visibility.sql.user=postgres',
'server.config.persistence.visibility.sql.existingSecret=postgres',
'server.config.persistence.visibility.sql.secretName=postgres',
'server.config.persistence.visibility.sql.secretKey=password',
]
)
k8s_resource(
workload='temporal-admintools',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-frontend',
2024-07-10 02:34:23 +00:00
labels='temporal',
2024-07-04 21:20:29 +00:00
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-history',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-worker',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-web',
labels='temporal', port_forwards=['8080'],
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-schema-setup',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-schema-update',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='temporal-matching',
labels='temporal',
resource_deps=[
'postgres',
'strapi'
])
k8s_resource(
workload='external-dns',
labels=['networking'],
)
k8s_resource(
workload='cert-manager-webhook-exoscale',
labels=['networking'],
)
2024-07-06 08:49:51 +00:00
k8s_resource(
workload='redis-master',
labels=['backend']
)
2024-07-10 02:34:23 +00:00
k8s_resource(
workload='bot',
labels=['backend'],
resource_deps=['strapi', 'temporal-web'],
)
2024-07-06 08:49:51 +00:00
2024-06-28 23:23:04 +00:00
# k8s_resource(
2024-07-10 02:34:23 +00:00
# workload='trigger',
# labels=['backend'],
# port_forwards=['3030:3000'],
# resource_deps=['postgres', 'redis-master'],
# links=[
# link('http://localhost:3030')
# ],
2024-07-04 21:20:29 +00:00
# )