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

Docker Compose Support #5102

Open
josegonzalez opened this issue Apr 9, 2022 · 17 comments
Open

Docker Compose Support #5102

josegonzalez opened this issue Apr 9, 2022 · 17 comments

Comments

@josegonzalez
Copy link
Member

josegonzalez commented Apr 9, 2022

Description of feature

Over the years, there have been a few tickets for docker compose:

As well as an early MR attempt: #1596

I recently - last night when I couldn't sleep - reinvestigated potential support for Compose, and I think we can do it now based on our work with the schedulers plugin as well as the evolution of the compose spec. Here is how it would work:

New plugins

New builder-compose plugin

The builder-compose plugin will not auto-detect, and is opt-in. Users will have to do select it to use it.

dokku builder:set selected $APP compose

During the build process, we will do the following:

  • Fail if there is any use of relative paths in volumes.
  • Remove any services with the label com.dokku.compose=false.
    • We could also allow folks to specify a profile that we use for builds and such.
  • Rewrite the image for any services with a build directive so that the image name ends up being dokku/$APP:latest-$PROCESS_TYPE.
    • The web process will end up being tagged latest. If there are multiple with the same exact build context, they will share the same tag (with the process type being that of web if that is an option or whatever the first is in lexicographical order).
    • If there is no web process, an alternative label com.dokku.primary-image=true can be specified on a service with a build context. This will force that - and any others with the same build context - to be the latest label. This is mutually exclusive with a web process, and the builder will fail if both are specified.
    • If there is no image that ends up being latest, the builder will fail.
  • Add the labels dokku uses internally for tracking images/containers to all the services with a build directive.
  • Run docker-compose build

Dokku internals will reference the latest image for extracting files or anything (though usually this happens in post-extract early on).

We should be able to specify the path to a compose file (for monorepo support) separately from selecting the builder via:

dokku builder-compose:set $APP compose-path $SOME_PATH

This will apply to both the builder and the scheduler.

We can also set buildx support on:

dokku builder-compose:set $APP buildx true

Potential issue is that we can't read and write the yaml file in Golang. I've opened an issue based on this here, so maybe I'm wrong and I'll be able to do this in Go. If not, we'll do the parsing/validation logic in a small python script.

New scheduler-compose plugin

Users will need to opt into this scheduler.

dokku scheduler:set selected $APP compose

This one will take the parsed/validated compose yaml file and run docker compose up. A user can specify a compose context to schedule apps to ACI or ECS via a scheduler-compose property:

dokku scheduler-compose:set $APP context $CONTEXT

Specifying a context may result in the proxy not working if the context does not use docker-local and the proxy mechanism is something local. We may in the future provide some fancy ingress, but users will be expected to use the networking mechanisms from the context otherwise.

Zero-downtime will be done by using compose's deployment strategies. The naive approach will be just to reload each service in a compose file one by one, which may result in downtime (not sure what compose does, we're just going to be running their commands). A future improvement might be to write our own zero-downtime code (similar to docker-rollout) but that won't be in the initial release. This may result in the proxy not routing to things before it is refreshed until we get to #5101 (but you should be great if you use an alternative proxy layer!), at which point it won't matter :)

Caveats

The above has a few caveats, and we'll consider it experimental going forward. Developers will need to opt into things and new limitations may pop up that I either won't immediately handle or will just be limits of the system. We'll need to make this clear and prominent in the docs.

Nice things

As a side-effect of this, we'll immediately support ACI and ECS, which would give quite a few users the ability to have HA Dokku fairly easily. I think we might even be able to expand this to kompose support and have a built-in kubernetes plugin in the future.

@yazinsai
Copy link
Contributor

Was searching for a way to setup Dokku with Docker Compose, and stumbled on this issue. Would love to see this come to reality!

@foogazy
Copy link

foogazy commented Jun 11, 2022

@josegonzalez Hello! Any news on this? This would be FANTASTIC!! Anyway we can help?

@josegonzalez
Copy link
Member Author

At this point it's mostly time (and funding for my time, see the github sponsors tab!). I have a decent idea of what to do to get this started, and the links above expound on the potential future functionality to drive deployments on ECS, Kubernetes, or Swarm.

@josegonzalez josegonzalez added this to Backlog in Release Board via automation Aug 23, 2022
@josegonzalez josegonzalez moved this from Backlog to To Do for current release in Release Board Aug 23, 2022
@josegonzalez
Copy link
Member Author

Might be good to also implement the ability to select a profile. That would allow folks to use a dokku profile or similar and only start deploy tasks with Dokku.

@josegonzalez
Copy link
Member Author

As much as I don't care what people use on their servers - it's your server, do whatever you want 😀 - this is an issue tracker for the dokku project. Please keep it clear of commentary about other projects in this space. Thanks.

@dokku dokku deleted a comment from SaadBazaz Dec 7, 2022
@dokku dokku deleted a comment from almereyda Dec 7, 2022
@IgnisDa
Copy link
Contributor

IgnisDa commented Jan 5, 2023

@josegonzalez Any updates on this?

@josegonzalez
Copy link
Member Author

If there was an update, it would be posted?

@pierre-b
Copy link

Hello guys, you might be aware of this, but it can motivate you to push Dokku in this direction: most of the new open-source SaaS (Airbyte, Cube.js...) are deployed either via k8s or docker compose. Managing a k8s is crazy expensive, so if you can provide a seamless deployment of "docker compose" recipes you will resurrect Dokku.

PS: I stopped using Dokku when Google Compute Engine instances started to handle containers.

@josegonzalez
Copy link
Member Author

I don't think this is a problem of motivation, but time. I also don't think Dokku is dead, so it probably doesn't need resurrection.

Glad to hear you found a solution that works for you though :)

@pierre-b
Copy link

Glad to hear you found a solution that works for you though :)

For most SaaS there is no easy solution to deploy a docker compose on a VM like Dokku does for containers, that's why you might bring a great one when time will come. Thanks for your awesome work anyway, I'm looking forward to deploy "docker compose" with Dokku when it's available.

@v3ss0n
Copy link

v3ss0n commented Feb 7, 2023

This is very interesting , looking forward to it.

@obrienmd
Copy link
Contributor

obrienmd commented Apr 27, 2023

Thanks for effort on this @josegonzalez - would be a big time-saver to be able to deploy docker compose directly on dokku! In many cases, the compose is just to stand up simple services that are covered well by dokku plugins (e.g. redis, postgres), but when it goes beyond that, figuring out how to represent a compose file on dokku is sometimes a non-trivial effort :)

@gamedevsam
Copy link
Contributor

I'd love to get Supabase deployed with dokku: https://github.com/supabase/supabase

@josegonzalez josegonzalez added the estimate: 10h Estimated time: 10 hours label Jan 30, 2024
@bfontaine
Copy link
Contributor

Is there something we can do to help moving this forward?

I'd love to get Supabase deployed with dokku: https://github.com/supabase/supabase

I tried but I eventually installed it with docker compose because it would have been a hell to translate the docker-compose.yml and its 12 containers into Dokku commands, even using dokkupose (which helps but misses a lot of things).

@josegonzalez
Copy link
Member Author

@bfontaine apologies for the late reply.

There are two paths forward:

  • Sponsor the work: I don't personally have any use for docker-compose on Dokku, so its hard to motivate myself to work on this ticket while there are other issues open. I've added an estimate on how much time I think it would take to implement, so if this is useful for you, please consider reaching out to sponsor the work.
  • File a pull request: If you don't have money but have time, I would be happy to take a pull request. While this may seem like a daunting task, we can figure out how to split it up such that it's easier to pull request in small chunks. I am more than happy to walk folks through contributing and am available on discord and slack.

The above goes for anyone interested in this or functionality in Dokku :)

@josegonzalez josegonzalez added this to the Future milestone Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Release Board
To Do for current release
Development

No branches or pull requests

9 participants