这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@josegonzalez
Copy link
Member

This PR implements preliminary docker-compose support. It's pretty untested, but building containers and deploying them the dokku way appears to work. A few notes:

  • links do not work. This is because containers have random names when we start them, and the links depend upon those names being applied to running containers. There isn't a straightforward way to do this since you cannot re-link running containers. I'm sure other compose features are similarly broken.

  • We require using a Procfile.compose to track the required image for a given process type. It's pretty hacky and I'm not proud of it.

  • It goes without saying, but you need both a Dockerfile and a docker-compose.yml file. Unfortunately there is currently no way to disable docker-compose support.

  • Tests don't pass, mostly because github is broken atm and I didn't run them locally. We probably want a docker-compose test as well. I have a small app that should work.

  • You still need to run the following (as root) to get this to work:

    curl -L https://raw.githubusercontent.com/0k/shyaml/master/shyaml > /usr/local/bin/shyaml; chmod +x /usr/local/bin/shyaml
    curl -L https://github.com/docker/compose/releases/download/1.5.0rc1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
    apt-get install python-yaml

Todo:

  • Add a test
  • Display warning if links are specified in docker-compose.yml.
  • Create a package for shyaml
  • Create a package for docker-compose (and a PR upstream would be nice as well)
  • Do another pass on documentation

Refs #1564
Refs #1594

@josegonzalez josegonzalez force-pushed the docker-compose-support branch from b4be79e to aad27d8 Compare October 23, 2015 10:25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this docker-compose? or at least something less generic.

@michaelshobbs
Copy link
Member

need docs and tests

@michaelshobbs
Copy link
Member

Can you describe this deployment scenario from repo to deployment?

Now that the implementation is out of the way 😜 what is the justification for adding this new method?

@josegonzalez
Copy link
Member Author

Read the attached docs for more reasoning :)

@josegonzalez
Copy link
Member Author

Basically this "solves" the issue where Dockerfile deployments currently have no way of running multiple processes. We treat the docker-compose.yml as a method of defining separate process types.

@michaelshobbs
Copy link
Member

Can you include some example repo artifacts for this method? Even better a test app would be great.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From line 75-90, the file is generated and copied.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh i see that now. the use of a generic directory like /opt/ seems odd to me. can we use /tmp or /tmp/build in the container instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I can take a stab at that.

@josegonzalez
Copy link
Member Author

Heh I've managed to stay this long without having tests!

https://github.com/josegonzalez/dokku-compose-app

It's more or less the sample docker-compose application, but modified to understand environment variables for the redis url.

@mahnunchik
Copy link

+1

@josegonzalez
Copy link
Member Author

Please do not +1 feature pull requests. We'll merge the features when they are ready :)

@josegonzalez
Copy link
Member Author

@michaelshobbs If I add my test app, would you mind adding actual tests for it?

@michaelshobbs
Copy link
Member

please add a test app in this PR and i can add tests to the documented spec. (side note: make sure those docs clarify the expected behavior)

This method does not currently scale non-web/app containers properly.
fig became docker-compose
This will allow us to specify a custom image for each process.
docker-compose processes are simply top-level entries in the docker-compose.yml file. We need to keep track of custom images for containers where the file specifies them, and otherwise use the built image. We use a special `Procfile.compose` file to keep track of this within the base image itself, and then later retrieve this when deploying each scaled container.
@josegonzalez
Copy link
Member Author

Why?

@mrmierzejewski
Copy link

@josegonzalez I would like to run multiple instances (web, workers) using Dockerfile deployment method (no Procfile).

Currently if I have Dockerfile, dokku creates only web process and there is no way to run other type of processes (for example workers). Using docker-compose standard, dokku can automatically create web and workers processes which are defined in docker-compose.yml file.

@josegonzalez
Copy link
Member Author

How do you imagine linking works? Really what we want is a way to define multiple images or the same image with different start commands. Compose more or less replicates a lot of what dokku does and supporting it properly isn't feasible.

The above could work but would leave everyone upset with how things are implemented/not supported.

@mrmierzejewski
Copy link

I understand your concerns about django-compose which overlaps dokku functionality. And I agree with you.

@josegonzalez
Copy link
Member Author

So what would you like us to do? Ideally we do not introduce a dokku.yml :)

@jvanbaarsen
Copy link
Contributor

@josegonzalez For me the removal of Zero-Downtime deploys would be a dealbreaker. What would be biggest benefit be for the Docker-compose?

@josegonzalez
Copy link
Member Author

Being able to run multiple commands for a Dockerfile-based deploy.

@mrmierzejewski
Copy link

@josegonzalez I suggest to add a new option to specify path to Dockerfile (as environmental variable). It gives possibility to create separate Dockerfiles for web and workers.

For example, I can have the following repository structure:

/Dockerfile
/worker/Dockerfile
/src/
...

And then I can create a worker by defining path to /worker/, e.g. dokku config:set my_app DOCKERFILE_PATH=/worker/

@mmerickel
Copy link
Contributor

@josegonzalez I suggest to add a new option to specify path to Dockerfile (as environmental variable). It gives possibility to create separate Dockerfiles for web and workers.

This is already possible via the DOCKER_BUILD_OPTIONS part of the docker-options plugin. You can specify dokku docker-options:add myapp build -b worker/Dockerfile or some such incantation.

@josegonzalez
Copy link
Member Author

You can't do that for a specific process though.

@mmerickel
Copy link
Contributor

I've had success using a Procfile and the DYNO environment variable and a docker-entrypoint.sh script to dispatch/start the appropriate worker. I suspect this is the right approach currently. You use the Procfile to declare your worker names and then the DYNO var contains "worker:1", etc. so you know which one to start in your entrypoint script. The Dockerfile itself defines the dokku app. Separate Dockerfiles would not fit particularly well into dokku's model I don't think.

@josegonzalez
Copy link
Member Author

@mmerickel would you be willing to write an documentation for this?

@josegonzalez
Copy link
Member Author

Note: even in such a deploy, you don't get the ability to run different dockerfiles. I suppose that is okay.

@josegonzalez
Copy link
Member Author

Closing in favor of using the Procfile behavior that @pmclanahan is going to work on :)

@josegonzalez josegonzalez deleted the docker-compose-support branch February 21, 2016 01:09
@raphaklaus
Copy link
Contributor

@josegonzalez is there any feedback about the feature @pmclanahan is working on?

@josegonzalez
Copy link
Member Author

That ended up being our Procfile support as documented here.

@blocka
Copy link

blocka commented Jan 31, 2017

There is another use-case for this which, I believe, is much more compelling -- dev-prod parity. Currently you can use dokku plugins to link to other services, which is great for production but if you app depends on those services you can no longer use it locally. Docker-compose allows you to have the same exact environment, complete with orchestrated services locally and and in production.

Currently, I get around this by using vagrant to orchestrate local docker containers.

It would be great to be able to deploy a docker-compose file as well. It seems to be supported by heroku as well, so I know i'm not crazy: https://devcenter.heroku.com/articles/local-development-with-docker-compose

@josegonzalez
Copy link
Member Author

This just doesn't work with zero-downtime deploys. Docker-compose doesn't handle that properly at all, and it's not clear to me how we'd handle conditionally starting/stopping certain services once they are running.

If you'd like to contribute to this, please see me on chat - my nick is savant - and we can discuss any potential issues before you start working on this.

@michaelshobbs
Copy link
Member

@josegonzalez I thought I saw the new v3 compose config supports docker services. Perhaps dokku automatically turns it's zero downtime off in the case of compose and we leave it up to the docker-compose.yml author to do what they want. shrug

@josegonzalez
Copy link
Member Author

@michaelshobbs you may as well just shove sshfront + docker-compose if you're going to do that. I don't see the value of using docker-compose for infra if you are tossing out the best parts of Dokku.

@michaelshobbs
Copy link
Member

I get your point. To be fair zero-downtime is just part of the build -> deploy -> proxy pipeline. The point about using docker-compose to represent prod environments in development is also valid. Just throwing it out there that this might be possible with the latest version of docker-compose.

@blocka
Copy link

blocka commented Jan 31, 2017

dokku does offer some other goodies like automatically setting up nginx proxies for your containers, plugins (especially letsencrypt...)

@josegonzalez
Copy link
Member Author

I mean if someone wants to do the work of refactoring our pipeline to make it easy to make this an engine, then they may want to speak to me directly on chat.

@dokku dokku locked and limited conversation to collaborators Jan 31, 2017
@josegonzalez
Copy link
Member Author

I'm locking this thread as I don't think it's productive - the code here isn't mergeable anymore anyhow - and would rather we go back to the drawing board on how this might fit in.

I mentioned engines above, and have had this convo with @michaelshobbs via video, but if you are interested, please chat with me directly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants