Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker compose profiles support #163

Merged
merged 3 commits into from
May 14, 2023

Conversation

nilcolor
Copy link
Contributor

@nilcolor nilcolor commented May 2, 2023

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:

  • I have added tests
  • I have made corresponding changes to the documentation

```
  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.
@bibendi
Copy link
Owner

bibendi commented May 2, 2023

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
Copy link
Contributor Author

nilcolor commented May 6, 2023

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

@bibendi bibendi merged commit 62ac8d2 into bibendi:master May 14, 2023
@bibendi
Copy link
Owner

bibendi commented May 14, 2023

Thank you!

Rolled v7.6.0 out

@nilcolor nilcolor deleted the profiles-support branch May 14, 2023 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants