Giter Club home page Giter Club logo

Comments (3)

JohnPreston avatar JohnPreston commented on May 25, 2024

I have done this with ECS Compose-X by setting some deploy.labels which indicate family (so the two services defined in the compose file are joined in the same task definition) and you can then set an exit condition, i.e. for your init script, you could use SUCCESS. Because of the implication here that SUCCESS means the container runs, executes, and we expect return 0 before moving on to starting the next container, compose-x automatically understands that's not an essential container.

See https://docs.compose-x.io/syntax/compose_x/ecs.details/deploy.html#labels

There are plenty of other examples in the labs which highlight having primary containers, that have to be healthy, and others that do not.

Hope this helps :)

from compose-cli.

zuk avatar zuk commented on May 25, 2024

@JohnPreston I've been trying to figure out what you're hinting at, but I'm getting nowhere. Like @tkrotoff I too have a database migration that that exits.

With the standard docker compose (3.9) syntax, you just set the depends_on condition to service_completed_successfully. Are you saying that this has no effect on ECS, and there is some other mechanism that needs to be layered on top of this? i.e. so @tkrotoff's example would be changed to something like this:

services:
  front:
    ...

  back:
    ...
    depends_on:
      database-init:
        condition: service_completed_successfully
    deploy:
      labels:
        ecs.task.family: db-init
        ecs.depends.condition: SUCCESS

  database-init:
    ...
    command: ['npm', 'run', 'db:init']
    depends_on:
      database:
        condition: service_healthy
    deploy:
      labels:
        ecs.task.family: db-init

  database:
    ...

I can't quite figure out how this is supposed to work or what the underlying conceptual model is based on the docs you linked to.

from compose-cli.

JohnPreston avatar JohnPreston commented on May 25, 2024

Apologies @zuk
The docs to the tool is a different one, not the ECS docker plugin extension which sadly does not support this.

Compose-X support most of the ECS plugin x- extensions, and much more.

Taking the exemple above you should have

services:
  front:
    ...

  back:
    ...
    depends_on:
      database-init
    deploy:
      labels:
        ecs.task.family: backend # goes to task family backend

  database-init:
    ...
    command: ['npm', 'run', 'db:init']
    depends_on:
      database:
        condition: service_healthy
    deploy:
      labels:
        ecs.task.family: backend # goes to task family backend
        ecs.depends.condition: SUCCESS # this container starts first and must return 0 for the next one to start
  database:
    ...

The backend task & service definition (family) will deploy both containers together in order database-init then back

command to run to create the templates / deploy to AWS ECS

ecs-compose-x init
ecs-compose-x up -f docker-compose.yaml -p my-app-stack

The database service will be created before the service "backend" though considering that you need it up and running first

If you have a DB on AWS that uses RDS you can use the x-rds module to have compose-x create ingress rules and paramete/env vars to say simplify the integration

from compose-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.