Tiltfile 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. load('ext://restart_process', 'docker_build_with_restart')
  2. secret_settings(disable_scrub=True)
  3. if not os.path.exists("vendor"):
  4. local(command="go mod vendor")
  5. if config.tilt_subcommand == "up":
  6. local(command="cd dashboard; npm i --legacy-peer-deps")
  7. if config.tilt_subcommand == "down":
  8. local(command="rm -rf vendor")
  9. local(command="rm -rf dashboard/node_modules")
  10. ## Build binary locally for faster devexp
  11. local_resource(
  12. 'porter',
  13. '''GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -mod vendor -gcflags '-N -l' -o ./porter ./cmd/app/main.go''',
  14. deps=[
  15. "api",
  16. "build",
  17. "cli",
  18. "ee",
  19. "internal",
  20. "pkg",
  21. ],
  22. resource_deps=["postgresql"],
  23. labels=["porter"]
  24. )
  25. docker_build_with_restart(
  26. ref="porter1/porter-server",
  27. context=".",
  28. dockerfile="zarf/docker/Dockerfile.server.tilt",
  29. # entrypoint='dlv --listen=:40000 --api-version=2 --headless=true --log=true exec /porter/bin/app',
  30. entrypoint='/app/porter',
  31. build_args={},
  32. only=[
  33. "porter",
  34. ],
  35. live_update=[
  36. sync('./porter', '/app/'),
  37. ]
  38. )
  39. # Frontend
  40. local_resource(
  41. name="porter-dashboard",
  42. serve_cmd="npm start",
  43. serve_dir="dashboard",
  44. serve_env={
  45. "NODE_ENV": "development",
  46. "DEV_SERVER_PORT": "8081",
  47. "ENABLE_PROXY": "true",
  48. "API_SERVER": "http://localhost:8080"
  49. },
  50. resource_deps=["postgresql"],
  51. labels=["porter"]
  52. )
  53. allow_k8s_contexts('kind-porter')
  54. cluster = str(local('kubectl config current-context')).strip()
  55. if (cluster.startswith("kind-")):
  56. install = kustomize('zarf/helm', flags=["--enable-helm"])
  57. decoded = decode_yaml_stream(install)
  58. for d in decoded:
  59. if d.get('kind') == 'Deployment':
  60. if "securityContext" in d['spec']['template']['spec']:
  61. d['spec']['template']['spec'].pop('securityContext')
  62. for c in d['spec']['template']['spec']['containers']:
  63. if "securityContext" in c:
  64. c.pop('securityContext')
  65. updated_install = encode_yaml_stream(decoded)
  66. k8s_yaml(updated_install)
  67. k8s_resource(workload='porter-server-web', port_forwards="8080:8080", labels=["porter"])
  68. else:
  69. local("echo 'Be careful that you aren't connected to a staging or prod cluster' && exit 1")
  70. exit()