Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to select services in docker_compose() #6423

Open
GiorgioBullo opened this issue Aug 6, 2024 · 6 comments
Open

Add possibility to select services in docker_compose() #6423

GiorgioBullo opened this issue Aug 6, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@GiorgioBullo
Copy link

GiorgioBullo commented Aug 6, 2024

Describe the Feature You Want

When using the function docker_compose() it would be good to select which services to deploy

Current Behavior

doker_compose('docker-compose.yml') deploys all the services defined in the docker-compose.yaml file and there is no easy way to select which service to deploy. However, if I am using only docker-compose, without Tilt, assuming the docker-compose.yml contains 3 services (svcs1, svcs2, svc3), I can easily select which one to spin up using docker-compose up svcs2 svcs3.

Why Do You Want This?

The docker-compose file may contain some services that are not needed in Tilt, moreover it feels like Tilt should expose this docker-compose feature.

Sometimes docker-compose and Tilt are used together even though they overlap a bit on their scope. That's why in the docker-compose file you may have services that you may not want in Tilt.

@GiorgioBullo GiorgioBullo added the enhancement New feature or request label Aug 6, 2024
@nicks
Copy link
Member

nicks commented Aug 6, 2024

i just tried this and it worked like i expected?

  1. Checkout https://github.com/tilt-dev/tilt-example-docker-compose
  2. Run tilt up redis
  3. Observe: redis starts, app does not

What am i missing?

Here are the docs: https://docs.tilt.dev/disable_resources

@GiorgioBullo
Copy link
Author

Following my previous example, I was thinking about something like the following, in the Tiltfile:

docker_compose('./docker-compose.yml', services=['svcs2','svcs3'])

yamlDeploy = helm(
  './path/to/svcs1-helm-chart',
  name='svcs1',
  values=['./path/to/svcs1-helm-values.yaml']
)

k8s_yaml(yamlDeploy)

So, when I run tilt up, svcs1 and svcs3 are deployed from docker-compose and svcs1 is ignored, but then installed using helm chart by Tilt. Without specifying the services=['svcs2','svcs3'] in the docker_compose() command, I would get an error because svcs1 is defined 2 times.

I understand that this could be solved by removing svcs1 from the docker-compose.yml, however I would prefer not to and I was wondering why docker_compose() doesn't provide that option.

Let me know if I got something wrong.

@nicks
Copy link
Member

nicks commented Aug 7, 2024

i think you can do this with something like:

dc_resource('app', new_name='unused')
k8s_yaml('app.yaml')
config.set_enabled_resources(['redis', 'app'])

@GiorgioBullo
Copy link
Author

GiorgioBullo commented Aug 8, 2024

it doesn't look like a feasible solution, because to disable a couple of resources I need to rename them (which could be fine), but then I need to enable everything else, that, in some cases I am working on, it could go up to 15 resources or more, that are not coming from the docker-compose file. It is true that the same holds for docker-compose up svcs2 svcs3 svcs4 svc5 ... if I want to disable only svcs1, however for tilt it is even worse, because I don't only have resources coming from docker-compose, but many comes from helm yaml manifests. Moreover, the approach you mention still shows the resources in the UI.

I wonder whether it exists a config.set_disabled_resources(), in this way I could "surgically" disable the few resources I don't need.

@nicks
Copy link
Member

nicks commented Aug 8, 2024

i guess you could also use docker-compose overrides to accomplish this:

Tiltfile:

docker_compose([
    'docker-compose.yaml',
    'docker-compose.override.yaml',
    ])

docker-compose.override.yaml

services:
  app: !reset null

@GiorgioBullo
Copy link
Author

Good, I guess the solutions you provided will satisfy most of the people out there 💪. I'll leave it to you whether you want to close this or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants