rafecolton / docker-builder

Docker builder builds Docker images from a friendly config file.
MIT License
80 stars 11 forks source link

Easy Travis and other CI webhook integration. #61

Closed colegleason closed 10 years ago

colegleason commented 10 years ago

It would be great if I could run the HTTP server and specify a Bobfile for a path. Then I could give that path to Travis webhooks and have it hit the build server after successful CI.

Something like http://localhost:5000/docker-build/project/travis, perhaps?

rafecolton commented 10 years ago

Hmm, interesting. Could you give a more detailed example?

colegleason commented 10 years ago

@rafecolton Sure. I want to be able to build and push a Docker container up to my private registry on every commit so I have a tag for each respective Github commit. However, I don't want to build/push a container if tests fail.

My solution was going to be: On every successful Travis build, have Travis send an HTTP request to docker-builder. This request would contain everything relating to the Git commit to build. docker-builder would know to load other relevant settings from the Bobfile, such as which containers to build. It would then follow the normal docker-builder flow.

Travis Webhook body may look like this:

{
  "id": 1,
  "number": "1",
  "status": null,
  "started_at": null,
  "finished_at": null,
  "status_message": "Passed",
  "commit": "62aae5f70ceee39123ef",
  "branch": "master",
  "message": "the commit message",
  "compare_url": "https://github.com/svenfuchs/minimal/compare/master...develop",
  "committed_at": "2011-11-11T11: 11: 11Z",
  "committer_name": "Sven Fuchs",
  "committer_email": "svenfuchs@artweb-design.de",
  "author_name": "Sven Fuchs",
  "author_email": "svenfuchs@artweb-design.de",
  "type": "push",
  "build_url": "https://travis-ci.org/svenfuchs/minimal/builds/1",
  "repository": {
    "id": 1,
    "name": "minimal",
    "owner_name": "svenfuchs",
    "url": "http://github.com/svenfuchs/minimal"
   },
  "config": {
    "notifications": {
      "webhooks": ["http://evome.fr/notifications", "http://example.com/"]
    }
  },
  "matrix": [
    {
      "id": 2,
      "repository_id": 1,
      "number": "1.1",
      "state": "created",
      "started_at": null,
      "finished_at": null,
      "config": {
        "notifications": {
          "webhooks": ["http://evome.fr/notifications", "http://example.com/"]
        }
      },
      "status": null,
      "log": "",
      "result": null,
      "parent_id": 1,
      "commit": "62aae5f70ceee39123ef",
      "branch": "master",
      "message": "the commit message",
      "committed_at": "2011-11-11T11: 11: 11Z",
      "committer_name": "Sven Fuchs",
      "committer_email": "svenfuchs@artweb-design.de",
      "author_name": "Sven Fuchs",
      "author_email": "svenfuchs@artweb-design.de",
      "compare_url": "https://github.com/svenfuchs/minimal/compare/master...develop"
    }
  ]
}

It's essentially a bit of glue to convert common CI webhooks like the one Travis supports into a docker-builder job. Otherwise I need to have an extra proxy that converts the HTTP request.

colegleason commented 10 years ago

Another webhook to support, for example, would be Github's: https://developer.github.com/webhooks/

rafecolton commented 10 years ago

Yep, I think it's time docker-builder learned how to speak Travis and GitHub. Starting with https://github.com/martini-contrib/auth/pull/11

colegleason commented 10 years ago

I've started writing a webhook route for Travis. I will work on Github next and, if all goes well, submit a PR.

rafecolton commented 10 years ago

:thumbsup:

rafecolton commented 10 years ago

Tagged and released. Thanks again for your contributions!