tilt-dev / tilt

Define your dev environment as code. For microservice apps on Kubernetes.
https://tilt.dev/
Apache License 2.0
7.58k stars 298 forks source link

Should tilt up <service> also start depends_on services? #3223

Open nicks opened 4 years ago

nicks commented 4 years ago

Suppose you have a docker-compose.yml file where backend has a depends_on: postgres.

If you start tilt as

tilt up backend

Tilt will not start postgres.

However, if you add dc_resource('backend', resource_deps=['postgres']) to your Tiltfile, it will start postgres.

I'm not sure if these behaviors should be consistent or not. I think there are a couple subtle mismatches between docker-compose depends_on and Tilt's resource_deps.

For now, you can workaround this by adding the dc_resource config

nicks commented 4 years ago

This repro case is helpful: https://github.com/Yolk-HQ/tilt-demo/tree/a9c969fe1c27c975ae5fcd73c627b29dc26e5446

crhayes commented 4 years ago

A simple workaround for now is to read in the docker compose file, loop over the services and manually specify dc_resource with resource_deps.

docker_compose('./docker-compose.yml')

# Read the docker compose yaml file and convert into Starlark object
yml = read_yaml('./docker-compose.yml')

# Get the services dict
services = yml.get('services')

# Loop over each service and manually configure the service with `dc_resource`,
# specifying the same name from the compose file, and using the `depends_on`
# key for the service in the compose file to configure the `resource_deps`
for name in services:
  dc_resource(name, resource_deps=services.get(name).get('depends_on', []))
nicks commented 4 years ago

it also might make sense to have tilt automatically configure the resource_deps when it sees a depend_on...there's been more interest recently in formally specifying the docker-compose config format, which might help us iron out the mismatches between the two deps models.