|
| 1 | +# -*- mode: Python -* |
| 2 | + |
| 3 | +k8s_yaml('kubernetes.yaml') |
| 4 | + |
| 5 | +k8s_resource('example-nodejs', port_forwards=[ |
| 6 | + 8000, # app itself |
| 7 | + 9229 # debugger |
| 8 | + ], resource_deps=['deploy'] |
| 9 | +) |
| 10 | + |
| 11 | +# Records the current time, then kicks off a server update. |
| 12 | +# Normally, you would let Tilt do deploys automatically, but this |
| 13 | +# shows you how to set up a custom workflow that measures it. |
| 14 | +local_resource( |
| 15 | + 'deploy', |
| 16 | + 'python now.py > start-time.txt', |
| 17 | +) |
| 18 | + |
| 19 | +# Add a live_update rule to our docker_build |
| 20 | +congrats = "🎉 Congrats, you ran a live_update! 🎉" |
| 21 | +docker_build('example-nodejs-image', '.', |
| 22 | + build_args={'node_env': 'development'}, |
| 23 | + entrypoint='yarn run nodemon --inspect=0.0.0.0:9229 /app/index.js', |
| 24 | + live_update=[ |
| 25 | + sync('.', '/app'), |
| 26 | + run('cd /app && yarn install', trigger=['./package.json', './yarn.lock']), |
| 27 | + |
| 28 | + # if all that changed was start-time.txt, make sure the server |
| 29 | + # reloads so that it will reflect the new startup time |
| 30 | + run('touch /app/index.js', trigger='./start-time.txt'), |
| 31 | + |
| 32 | + # add a congrats message! |
| 33 | + run('sed -i "s/Hello cats!/{}/g" /app/views/index.mustache'. |
| 34 | + format(congrats)), |
| 35 | +]) |
0 commit comments