compose icon indicating copy to clipboard operation
compose copied to clipboard

Support multiple compose files

Open wjensen-godaddy opened this issue 3 years ago • 7 comments

Is there an existing issue for this?

  • [X] I have searched existing issues, it hasn't been reported yet

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

wjensen-godaddy avatar Jul 07 '22 00:07 wjensen-godaddy

@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?

mnapoli avatar Jul 07 '22 07:07 mnapoli

@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?

wjensen-godaddy avatar Jul 07 '22 15:07 wjensen-godaddy

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?

pgrzesik avatar Jul 07 '22 15:07 pgrzesik

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

wjensen-godaddy avatar Jul 07 '22 15:07 wjensen-godaddy

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

pgrzesik avatar Jul 07 '22 15:07 pgrzesik

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).

wjensen-godaddy avatar Jul 07 '22 15:07 wjensen-godaddy

any news about specific compose config?

juztinlazaro avatar Nov 24 '23 05:11 juztinlazaro