Only Launch Individual Services in Dev Mode

Hey team!

Can I run dev mode with just a single service (and its specified dependencies) without running everything in my project? When I use garden dev some-service everything starts along with it.

Thanks,

Harley

Great question!

We’re working on a big update to our config syntax, which we’ll be releasing in the coming months.

Once that’s out, you’ll be able to specify tags for your services, tests etc., which you can then use on the CLI to deploy/test/… only the matching services/tests/…, which implements exactly the workflow you’re describing there.

In the meantime, you can accomplish this by defining a dev environment for each of these groups, and using environment-level variables to select services:

...
variables:
  ...
  # The default, optionally overridden in specific environments.
  disabledServices: []
environments:
  - name: test
    ...
    variables:
      # disabledServices: [] <--- we just use the default here
  - name: prod
    ...
    variables:
      # disabledServices: [] <--- we just use the default here
  - name: dev
    ...
    variables:
      # disabledServices: [] <--- we just use the default here
  - name: dev-group-1
    ...
    variables:
      disabledServices: [a, e, ...]
  - name: dev-group-2
    ...
    variables:
      disabledServices: [a, c, d, ...]
  ...

Then you can simply use disabled: ${var.disabledServices contains "some-service"} in the config for that module/service, and only the group-appropriate set of modules/services will be processed when you run e.g. garden dev --env dev-group-2.

Conversely, you could use enabledServices: [<all service names>] as the default (might be easier to read if you’re including fewer services than you’re excluding in most groups).

Hope that helps!