bibendi / dip

The dip is a CLI dev–tool that provides native-like interaction with a Dockerized application.
MIT License
1.26k stars 44 forks source link

add docker compose profiles support #163

Closed nilcolor closed 1 year ago

nilcolor commented 1 year ago

Context

  full:
    description: Run all services
    runner: docker_compose
    compose:
      profiles: [workers, backend]

Config like this will run docker compose --profile workers --profile backend up command. Run options ~and service~ configs are ignored even if provided. Can also be a part of subcommand:

  rails:
    description: Run Rails commands
    service: backend
    command: bundle exec rails
    subcommands:
      all:
        description: Run Rails server, Sidekiq and RabbitMQ workers
        compose:
          profiles: [workers, backend]

There is an issue with Ctrl+C command in this case:

...
Aborting on container exit...
[+] Running 9/9
 ✔ Container app-realtime-1   Stopped    10.4s
 ✔ Container app              Stopped     0.3s
 ✔ Container app-rabbitmq-1   Stopped     1.3s
 ✔ Container app-sidekiq-1    Stopped    10.3s
 ✔ Container app-faye-1       Stopped     0.2s
 ✔ Container app-mongodb-1    Stopped     0.2s
 ✔ Container app-memcached-1  Stopped     0.2s
 ✔ Container app-database-1   Stopped     1.9s
 ✔ Container app-redis-1      Stopped     0.1s
canceled

$ docker container ls --all
CONTAINER ID   IMAGE                           COMMAND                  CREATED              STATUS                   NAMES
67475bb645b3   app-dev:latest             "/app/.dockerdev/ent…"   About a minute ago   Exited (137) 24 seconds ago   app-realtime-1
47ab521ae5c7   app-dev:latest             "/app/.dockerdev/ent…"   About a minute ago   Exited (137) 24 seconds ago   app-sidekiq-1
22e7a9bd7faf   app-dev:latest             "/app/.dockerdev/ent…"   About a minute ago   Exited (1) 34 seconds ago     app
c96e42e35f18   srv-faye:latest            "docker-entrypoint.s…"   About a minute ago   Exited (0) 24 seconds ago     app-faye-1
1816e2dfac59   rabbitmq:3.9.7-management  "docker-entrypoint.s…"   About a minute ago   Exited (0) 33 seconds ago     app-rabbitmq-1
6fc9360684fc   memcached:1.5.22-alpine    "docker-entrypoint.s…"   About a minute ago   Exited (0) 24 seconds ago     app-memcached-1
aa9bde5cf18e   redis:5-bullseye           "docker-entrypoint.s…"   About a minute ago   Exited (0) 24 seconds ago     app-redis-1
677beebb60a2   mariadb:10.2               "docker-entrypoint.s…"   About a minute ago   Exited (0) 22 seconds ago     app-database-1
014529fd2f5e   mongo:4.4.8                "docker-entrypoint.s…"   About a minute ago   Exited (0) 24 seconds ago     app-mongodb-1

I.e. on Ctrl+C, containers are not removed. So, the next dip up command may raise an error about missing network. To resolve, dip down can be used. Also, dip down was slightly updated to remove orphan containers by adding --remove-orphans flag.

Related tickets

What's inside

Checklist:

bibendi commented 1 year ago

Hi, Alexey! Thank you for the contribution! I'll try to review your PR this or next week. I apologize in advance if this seems like a long time to you :)

nilcolor commented 1 year ago

No worries Michael :) Take your time, there is no rush.

bibendi commented 1 year ago

Thank you!

Rolled v7.6.0 out