Skip to content

Clarify the precedence between config.yml and docker compose files. #415

Closed

Description

@rickmanelius

What happened (or feature request):

Clarification of project intentions/goals.

What you expected to happen:

In a conversation with @Schnitzel, there was a philosophical discussion on the relationship between ddev and docker and whether the source of truth would be located within ddev's config.yml file OR if that would be secondary/subordinate to docker-compose.yml (and other files). This conversation touched on everything from ease of use, flexibility, best practices from the larger docker ecosystem, etc.

Ultimately, I think ddev strikes this balance by considering the config.yml primary in order to set (and update) the webserver and database docker compose entries while allowing users to add additional services and overrides following the patterns discussed in our documentation https://ddev.readthedocs.io/en/latest/users/extend/custom-compose-files/.

One thing surfaced in the conversation was the desire to, if an existing docker-compose.yml was already in existence to use that instead of generating a stock one from values stored in .ddev/config.yml. While that it is possible (essentially making ddev a wrapper), my bias would be to not adopt that approach OR to provide some additional guidance in converting that to an override Docker compose file.

This is just a placeholder for now as I need to put a little more thought and detail on this in order to make something actionable out of this.

Activity

  1. Schnitzel commented on Jul 20, 2017

    @Schnitzel

    maybe some background here as well.
    amazee.io plans to use docker-compose.yml files to configure the hosting environment. As for amazee.io it is very important to not only have awesome production hosting, but also local development hosting, we're interested in having one file that configures everything.

    here an example file for just a super easy node hosting:
    https://github.com/amazeeio/node-example/blob/master/.amazeeio.yml

    there is a key in there amazeeio: which is not part of the docker-compose specs but as it is yaml, docker-compose actually doesn't care and just looks at the keys that are interesting for itself.

  2. rickmanelius commented on Sep 6, 2017

    @rickmanelius
    ContributorAuthor

    This is now being prioritized for our next sprint to get to a decision/solution.

  3. self-assigned this
    on Sep 6, 2017
  4. modified the milestones: v1.0.0, v1.1.0 on Sep 6, 2017
  5. Schnitzel commented on Sep 7, 2017

    @Schnitzel

    Just a short update of what happened on our side.
    Unfortunately we had to realize that just adding a key to the yaml causes some versions of docker-compose to freak out and not parse it at all, even it is a fully valid Yaml.

    So we went ahead and found a solution with using labels, example here:
    https://github.com/amazeeio/drupal-example/blob/lagoonize/docker-compose.yml
    So all these com.amazeeio.* labels tell our build and deploy system lagoon how to create the needed resources on kubernetes/openshift.

  6. rfay commented on Sep 7, 2017

    @rfay
    Member

    It's probably too late for this, but it would be great if you'd give an example of "adding a key to the yaml causes some versions of docker-compose to freak out" so we'd understand it fully.

    Labels does sound like the correct path though, (as little as I actually understand the problem being solved.)

  7. rickmanelius commented on Sep 7, 2017

    @rickmanelius
    ContributorAuthor

    Hi @Schnitzel. Just a quick heads up that we had a productive conversation this morning and will be following up by tomorrow with a proposed path forward. The example docker-compose file was incredibly helpful in understanding the use case and what would work/not work in each proposed path forward. Thanks for sending that along and we're looking forward to driving this issue to a completion state!

  8. rfay commented on Sep 11, 2017

    @rfay
    Member

    There are a couple of issues here, the stated issue and some things behind it.

    • Currently, the config.yml just overrides the images for the docker-compose.yml. It does that by setting environment variables that are used in the docker-compose. So the precedence is actually clear.
    • ddev never overrides or edits an existing docker-compose.yml
    • The docker-compose.yml can in fact be edited by the end-user to their delight, and ddev will not validate or be able to recover from weird things that may happen.

    However, the long-term issues remain: This whole situation is not clear to the end-user, and the end-user can easily make the docker-compose file do things that we wish they wouldn't :) So long-term we may want to spin off an issue to wrap the docker-compose with something clearly owned by ddev.

  9. Schnitzel commented on Sep 11, 2017

    @Schnitzel

    Currently, the config.yml just overrides the images for the docker-compose.yml.

    but this docker-compose.yml sits within a ddev folder no? so ddev could basically say: if I find a docker-compose.yml within the root folder, I don't even look at a config.yml or any ddev folder.

    ddev never overrides or edits an existing docker-compose.yml

    good! it shouldn't

    This whole situation is not clear to the end-user, and the end-user can easily make the docker-compose file do things that we wish they wouldn't :)

    mhh but they can also create weird stuff in a config.yml that might create broke stuff (like defining a Docker Image that actually does not do what it should)

  10. 6 remaining items

  11. modified the milestones: v1.2.0, v1.0.0 on Dec 11, 2017
  12. removed this from the v1.0.0 milestone on Feb 13, 2018
  13. rickmanelius commented on Apr 3, 2018

    @rickmanelius
    ContributorAuthor

    At this point, the product has changed focus and is biasing towards stability and reliability instead of attempting to take on an unbounded answer space as a thin wrapper to Docker/Docker-compose. To that end, if a person/team had an arbitrary docker-compose that they wished to stand-up, they could always configure as a default php app and simply copy the additional compose file into the .ddev folder. This could also be done via a simple pre-start copy drush exec-host command to copy from the project root to .ddev/. To that end, closing this longstanding issue out.

  14. Schnitzel commented on Apr 13, 2018

    @Schnitzel

    As discussed during DrupalCon Nashville together with Rick, Kevin, Jam, Tyler and Me. We would like to reopen this issue and support the following:

  15. rfay commented on May 4, 2018

    @rfay
    Member
    • ddev now owns docker-compose.yaml. It should never be edited, and it is replace on every ddev start
    • config.yaml provides information that is inserted/preprocessed into docker-compose.*.yaml via environment variables.
    • Additional user-defined docker-compose stuff goes into docker-compose.*.yaml, as described in teh docs.

    Closing again.

  16. thom8 commented on Jun 3, 2018

    @thom8

    Understand that this issue is contentious but would it be possible to add support for a project type of custom which just disables the automatic generation of the docker-compose.yaml and launches whatever is defined in there, allowing for persistent customisations.

    This can come with a major disclaimer and even be an "officially unsupported feature" but still allow others to extend ddev.

  17. rfay commented on Jun 3, 2018

    @rfay
    Member

    @thom8 I think you can override anything with custom docker-compose files, does that do the job for you? You can create any docker-compose.*.yaml that overrides or adds features, and you can specifically override with docker-compose.override.yaml. Only the main file is managed (and recreated on every start) by ddev.

    Please let us know what you need that can't be done with that... Thanks!

  18. thom8 commented on Jun 4, 2018

    @thom8

    Looks like I can't easily extend one of the current services by building FROM the default image eg.

    version: '3'
    services:
      web:
        build:
          context: .
          dockerfile: Dockerfile.web
    

    Do you have any ideas how this could be done?

  19. rfay commented on Jun 4, 2018

    @rfay
    Member

    If you really, really want to get into the business of building and maintaining your own docker image, then you can either extend ours (Use FROM drud/nginx-php-fpm-local:v0.19.0 and build it, or else fork the contents (especially Dockerfile.in) in containers/nginx-php-fpm-local and use make container there. But it's likely to break when we change the upstream image. Then you would change the image line in your docker override to specify your forked/derived image.

    We don't build any images in the docker-compose, so that's why it's not going to work for you there.

  20. thom8 commented on Jun 4, 2018

    @thom8

    This would be possible if we had the ability to override the docker-compose.yaml understanding that we would need to manage any upstream conflicts.

    Extending an image from within the project is far easier than having to build outside and specify the forked image.

    And with CI we'll pick this up pretty quickly if there was an upstream conflict.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions