Single dockerfiles GitHub repository + Docker Hub automated builds











up vote
1
down vote

favorite












I would like to create a dockerfiles repository on GitHub to centralize all custom Dockerfiles I've created so far. I also would like to automatize builds of each image on Docker Hub, independently.



There is many repositories like this on GitHub :




  • https://github.com/tianon/dockerfiles

  • https://github.com/vimagick/dockerfiles


(I would not talk here about the most starred repository : https://github.com/jessfraz/dockerfiles, because as you can see on Docker Hub, these are not automated builds)



Wanted structure of dockerfiles repository



I'd like my dockerfiles GitHub repository have the following structure (branch master), based on GitHub repositories I mentioned above :



dockerfiles (GitHub repo)
|- docker-image-1
|- Dockerfile
|- docker-image-2
|- Dockerfile
|- ...


Docker Hub builds automation



Configuration



On Docker Hub, I could create 2 public automated builds : docker-image-1 and docker-image-2, both referring to my dockerfiles GitHub repository, but with different Build Settings (in fact, only Dockerfile Location differs) :




  • for docker-image-1 :



    • Type : Branch


    • Name : master


    • Dockerfile Location : /docker-image-1/


    • Docker Tag Name : latest



  • for docker-image-2 :



    • Type : Branch


    • Name : master


    • Dockerfile Location : /docker-image-2/


    • Docker Tag Name : latest




Drawbacks



With this configuration, all images will be rebuilt if a push on master branch is made (even if there is only 1 Dockerfile concerned by the push and Dockerfile Locations are different). I've checked, it seems to be configured like this for vimagick's repository. But I don't think it's the right way (if I'm wrong, tell me).



Of course, in Build Settings of each automated build, I could disable option "When active, builds will happen automatically on pushes" to avoid this, but I'll have to trigger each build manually depending on what Dockerfile I've updated (not automatic).



Improve automation?



Solutions I see to improve automation are :




  1. separate each Dockerfile in its own GitHub repository. No more dockerfiles repository, so each one have its own workflow

  2. use a single GitHub repository dockerfiles, but with different branches (one per Docker image). Each build could then be configured to be triggered only on the appropriate branch


With these solutions, problem is that I lost a global overview of all my Dockerfiles. I prefer the idea of a single repository with a single branch, but I don't want all images to be rebuilt on each push on this single branch.



If I'm choosing solution 1, I don't know if git can help me to keep a single repository dockerfiles referencing all my repositories, like :



 dockerfiles (GitHub repo)
|- docker-image-1 -> link to https://github.com/norbjd/docker-image-1
|- Dockerfile
|- docker-image-2 -> link to https://github.com/norbjd/docker-image-2
|- Dockerfile


It would then be easier to clone the whole project and do Pull Requests (since some images are related : updating docker-image-1/Dockerfile could lead to update docker-image-2/Dockerfile). I've read about Git submodules and subtrees, but I don't know if these are appropriate here.



Maybe it's possible with a single repository, and it's just about finding the right Docker Hub Build Settings.



What are the best practices?










share|improve this question


























    up vote
    1
    down vote

    favorite












    I would like to create a dockerfiles repository on GitHub to centralize all custom Dockerfiles I've created so far. I also would like to automatize builds of each image on Docker Hub, independently.



    There is many repositories like this on GitHub :




    • https://github.com/tianon/dockerfiles

    • https://github.com/vimagick/dockerfiles


    (I would not talk here about the most starred repository : https://github.com/jessfraz/dockerfiles, because as you can see on Docker Hub, these are not automated builds)



    Wanted structure of dockerfiles repository



    I'd like my dockerfiles GitHub repository have the following structure (branch master), based on GitHub repositories I mentioned above :



    dockerfiles (GitHub repo)
    |- docker-image-1
    |- Dockerfile
    |- docker-image-2
    |- Dockerfile
    |- ...


    Docker Hub builds automation



    Configuration



    On Docker Hub, I could create 2 public automated builds : docker-image-1 and docker-image-2, both referring to my dockerfiles GitHub repository, but with different Build Settings (in fact, only Dockerfile Location differs) :




    • for docker-image-1 :



      • Type : Branch


      • Name : master


      • Dockerfile Location : /docker-image-1/


      • Docker Tag Name : latest



    • for docker-image-2 :



      • Type : Branch


      • Name : master


      • Dockerfile Location : /docker-image-2/


      • Docker Tag Name : latest




    Drawbacks



    With this configuration, all images will be rebuilt if a push on master branch is made (even if there is only 1 Dockerfile concerned by the push and Dockerfile Locations are different). I've checked, it seems to be configured like this for vimagick's repository. But I don't think it's the right way (if I'm wrong, tell me).



    Of course, in Build Settings of each automated build, I could disable option "When active, builds will happen automatically on pushes" to avoid this, but I'll have to trigger each build manually depending on what Dockerfile I've updated (not automatic).



    Improve automation?



    Solutions I see to improve automation are :




    1. separate each Dockerfile in its own GitHub repository. No more dockerfiles repository, so each one have its own workflow

    2. use a single GitHub repository dockerfiles, but with different branches (one per Docker image). Each build could then be configured to be triggered only on the appropriate branch


    With these solutions, problem is that I lost a global overview of all my Dockerfiles. I prefer the idea of a single repository with a single branch, but I don't want all images to be rebuilt on each push on this single branch.



    If I'm choosing solution 1, I don't know if git can help me to keep a single repository dockerfiles referencing all my repositories, like :



     dockerfiles (GitHub repo)
    |- docker-image-1 -> link to https://github.com/norbjd/docker-image-1
    |- Dockerfile
    |- docker-image-2 -> link to https://github.com/norbjd/docker-image-2
    |- Dockerfile


    It would then be easier to clone the whole project and do Pull Requests (since some images are related : updating docker-image-1/Dockerfile could lead to update docker-image-2/Dockerfile). I've read about Git submodules and subtrees, but I don't know if these are appropriate here.



    Maybe it's possible with a single repository, and it's just about finding the right Docker Hub Build Settings.



    What are the best practices?










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I would like to create a dockerfiles repository on GitHub to centralize all custom Dockerfiles I've created so far. I also would like to automatize builds of each image on Docker Hub, independently.



      There is many repositories like this on GitHub :




      • https://github.com/tianon/dockerfiles

      • https://github.com/vimagick/dockerfiles


      (I would not talk here about the most starred repository : https://github.com/jessfraz/dockerfiles, because as you can see on Docker Hub, these are not automated builds)



      Wanted structure of dockerfiles repository



      I'd like my dockerfiles GitHub repository have the following structure (branch master), based on GitHub repositories I mentioned above :



      dockerfiles (GitHub repo)
      |- docker-image-1
      |- Dockerfile
      |- docker-image-2
      |- Dockerfile
      |- ...


      Docker Hub builds automation



      Configuration



      On Docker Hub, I could create 2 public automated builds : docker-image-1 and docker-image-2, both referring to my dockerfiles GitHub repository, but with different Build Settings (in fact, only Dockerfile Location differs) :




      • for docker-image-1 :



        • Type : Branch


        • Name : master


        • Dockerfile Location : /docker-image-1/


        • Docker Tag Name : latest



      • for docker-image-2 :



        • Type : Branch


        • Name : master


        • Dockerfile Location : /docker-image-2/


        • Docker Tag Name : latest




      Drawbacks



      With this configuration, all images will be rebuilt if a push on master branch is made (even if there is only 1 Dockerfile concerned by the push and Dockerfile Locations are different). I've checked, it seems to be configured like this for vimagick's repository. But I don't think it's the right way (if I'm wrong, tell me).



      Of course, in Build Settings of each automated build, I could disable option "When active, builds will happen automatically on pushes" to avoid this, but I'll have to trigger each build manually depending on what Dockerfile I've updated (not automatic).



      Improve automation?



      Solutions I see to improve automation are :




      1. separate each Dockerfile in its own GitHub repository. No more dockerfiles repository, so each one have its own workflow

      2. use a single GitHub repository dockerfiles, but with different branches (one per Docker image). Each build could then be configured to be triggered only on the appropriate branch


      With these solutions, problem is that I lost a global overview of all my Dockerfiles. I prefer the idea of a single repository with a single branch, but I don't want all images to be rebuilt on each push on this single branch.



      If I'm choosing solution 1, I don't know if git can help me to keep a single repository dockerfiles referencing all my repositories, like :



       dockerfiles (GitHub repo)
      |- docker-image-1 -> link to https://github.com/norbjd/docker-image-1
      |- Dockerfile
      |- docker-image-2 -> link to https://github.com/norbjd/docker-image-2
      |- Dockerfile


      It would then be easier to clone the whole project and do Pull Requests (since some images are related : updating docker-image-1/Dockerfile could lead to update docker-image-2/Dockerfile). I've read about Git submodules and subtrees, but I don't know if these are appropriate here.



      Maybe it's possible with a single repository, and it's just about finding the right Docker Hub Build Settings.



      What are the best practices?










      share|improve this question













      I would like to create a dockerfiles repository on GitHub to centralize all custom Dockerfiles I've created so far. I also would like to automatize builds of each image on Docker Hub, independently.



      There is many repositories like this on GitHub :




      • https://github.com/tianon/dockerfiles

      • https://github.com/vimagick/dockerfiles


      (I would not talk here about the most starred repository : https://github.com/jessfraz/dockerfiles, because as you can see on Docker Hub, these are not automated builds)



      Wanted structure of dockerfiles repository



      I'd like my dockerfiles GitHub repository have the following structure (branch master), based on GitHub repositories I mentioned above :



      dockerfiles (GitHub repo)
      |- docker-image-1
      |- Dockerfile
      |- docker-image-2
      |- Dockerfile
      |- ...


      Docker Hub builds automation



      Configuration



      On Docker Hub, I could create 2 public automated builds : docker-image-1 and docker-image-2, both referring to my dockerfiles GitHub repository, but with different Build Settings (in fact, only Dockerfile Location differs) :




      • for docker-image-1 :



        • Type : Branch


        • Name : master


        • Dockerfile Location : /docker-image-1/


        • Docker Tag Name : latest



      • for docker-image-2 :



        • Type : Branch


        • Name : master


        • Dockerfile Location : /docker-image-2/


        • Docker Tag Name : latest




      Drawbacks



      With this configuration, all images will be rebuilt if a push on master branch is made (even if there is only 1 Dockerfile concerned by the push and Dockerfile Locations are different). I've checked, it seems to be configured like this for vimagick's repository. But I don't think it's the right way (if I'm wrong, tell me).



      Of course, in Build Settings of each automated build, I could disable option "When active, builds will happen automatically on pushes" to avoid this, but I'll have to trigger each build manually depending on what Dockerfile I've updated (not automatic).



      Improve automation?



      Solutions I see to improve automation are :




      1. separate each Dockerfile in its own GitHub repository. No more dockerfiles repository, so each one have its own workflow

      2. use a single GitHub repository dockerfiles, but with different branches (one per Docker image). Each build could then be configured to be triggered only on the appropriate branch


      With these solutions, problem is that I lost a global overview of all my Dockerfiles. I prefer the idea of a single repository with a single branch, but I don't want all images to be rebuilt on each push on this single branch.



      If I'm choosing solution 1, I don't know if git can help me to keep a single repository dockerfiles referencing all my repositories, like :



       dockerfiles (GitHub repo)
      |- docker-image-1 -> link to https://github.com/norbjd/docker-image-1
      |- Dockerfile
      |- docker-image-2 -> link to https://github.com/norbjd/docker-image-2
      |- Dockerfile


      It would then be easier to clone the whole project and do Pull Requests (since some images are related : updating docker-image-1/Dockerfile could lead to update docker-image-2/Dockerfile). I've read about Git submodules and subtrees, but I don't know if these are appropriate here.



      Maybe it's possible with a single repository, and it's just about finding the right Docker Hub Build Settings.



      What are the best practices?







      git docker dockerhub






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 14:05









      norbjd

      1,1771422




      1,1771422





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209370%2fsingle-dockerfiles-github-repository-docker-hub-automated-builds%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53209370%2fsingle-dockerfiles-github-repository-docker-hub-automated-builds%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Xamarin.form Move up view when keyboard appear

          Post-Redirect-Get with Spring WebFlux and Thymeleaf

          Anylogic : not able to use stopDelay()