serverless / compose

Orchestrate Serverless Framework in monorepos
https://serverless.com/framework/docs/guides/compose
MIT License
110 stars 15 forks source link

Support multiple compose files #147

Open wjensen-godaddy opened 2 years ago

wjensen-godaddy commented 2 years ago

Is there an existing issue for this?

Use case description

The services I need to run vary depending on the environment: local, dev, prod.

Proposed solution (optional)

It would be nice if I could have a config file for each of them, and then a way to tell serverless which one to use. Perhaps something like: serverless deploy --config=serverless-compose-dev.yml

mnapoli commented 2 years ago

@wjensen-godaddy thanks, I'm curious about your use case and whether it could be better solved with, for example, stage parameters in Compose config.

Could you share what is different between the files between dev and other stages?

wjensen-godaddy commented 2 years ago

@mnapoli For sure. This is what we need in prod:

# serverless-compose.yml

services:
  elastic-search:
    path: services/elastic-search

  graph:
    path: services/graph
    params:
      elasticUrl: ${elastic-search.url}

  dynamo-event-mapping:
    path: services/dynamo-event-mapping
    params:
      elasticUrl: ${elastic-search.url}
      dynamoStreamArn: ${graph.dynamoStreamArn}

And this is what we need locally and in dev:

# serverless-compose.yml

services:
  graph:
    path: services/graph

We also support spinning up a deploy for each PR. And we want to give devs the options to deploy the full stack, or the skinny version.

Like you say, maybe there's a better way to support that than multiple config files?

pgrzesik commented 2 years ago

We've also had some proposals that you could deploy only specific services - https://github.com/serverless/compose/issues/35 Looking at your use case, it also sounds like something that could solve the problem, correct?

wjensen-godaddy commented 2 years ago

@pgrzesik Possibly. Although if I filtered out elastic-search, wouldn't my graph service complain that ${elastic-search.url} can't be resolved?

pgrzesik commented 2 years ago

Oh right, I've missed that part there, thanks for correction @wjensen-godaddy 👍

wjensen-godaddy commented 2 years ago

Another idea I had, is when issuing service specific commands, missing dependencies could be a warning instead of an error. That way I could run sls graph:offline or sls graph:deploy.

My current workaround, is I run (cd services/graph && sls offline).

juztinlazaro commented 8 months ago

any news about specific compose config?