Run go file from Github inside Docker












0














I use "go get" command to download and install my go code from Github and other dependencies inside the Docker. For example:



docker run golang go get -v "github_repo_directory"


It downloads more than 900 MB initially for the dependencies. Then I can create the container and run the code inside the docker container. The issue is whenever I change something in the code, I have to to go through all the process and it again downloads a huge amount of file. Is there any way so that every time I modify my code, I don't have to download all the dependencies? I am using the following reference to run my code.



https://flaviocopes.com/golang-docker/










share|improve this question


















  • 1




    To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
    – Volker
    Nov 12 '18 at 6:55
















0














I use "go get" command to download and install my go code from Github and other dependencies inside the Docker. For example:



docker run golang go get -v "github_repo_directory"


It downloads more than 900 MB initially for the dependencies. Then I can create the container and run the code inside the docker container. The issue is whenever I change something in the code, I have to to go through all the process and it again downloads a huge amount of file. Is there any way so that every time I modify my code, I don't have to download all the dependencies? I am using the following reference to run my code.



https://flaviocopes.com/golang-docker/










share|improve this question


















  • 1




    To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
    – Volker
    Nov 12 '18 at 6:55














0












0








0







I use "go get" command to download and install my go code from Github and other dependencies inside the Docker. For example:



docker run golang go get -v "github_repo_directory"


It downloads more than 900 MB initially for the dependencies. Then I can create the container and run the code inside the docker container. The issue is whenever I change something in the code, I have to to go through all the process and it again downloads a huge amount of file. Is there any way so that every time I modify my code, I don't have to download all the dependencies? I am using the following reference to run my code.



https://flaviocopes.com/golang-docker/










share|improve this question













I use "go get" command to download and install my go code from Github and other dependencies inside the Docker. For example:



docker run golang go get -v "github_repo_directory"


It downloads more than 900 MB initially for the dependencies. Then I can create the container and run the code inside the docker container. The issue is whenever I change something in the code, I have to to go through all the process and it again downloads a huge amount of file. Is there any way so that every time I modify my code, I don't have to download all the dependencies? I am using the following reference to run my code.



https://flaviocopes.com/golang-docker/







docker go






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 4:32









Shihab Shahriar

164




164








  • 1




    To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
    – Volker
    Nov 12 '18 at 6:55














  • 1




    To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
    – Volker
    Nov 12 '18 at 6:55








1




1




To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
– Volker
Nov 12 '18 at 6:55




To build your program you will have to download all the dependencies. To run: not. Google multistage docker builds. medium.com/@pierreprinetti/the-go-1-11-dockerfile-a3218319d191 might be a starting point.
– Volker
Nov 12 '18 at 6:55












1 Answer
1






active

oldest

votes


















0














It depends what you want to do here. If your aim is to create an image for your production-ready app that you want to release for other people to use then you would need a Dockerfile that contains the instructions to fetch your code using go get -v "github_repo_directory". This would result in a new image that you could distribute. However this won't be useful for development, because any change you make to your code means you'll have to rebuild this image.



If you want to use Docker as a development environment you need to be able to see the changes you make locally right away. In this case you will be using the base image that allows you to run your app (e.g. the image provided by go), and you should mount your codebase inside the docker container. I would suggest reading up a bit on Docker, this article might be helpful.






share|improve this answer





















    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',
    autoActivateHeartbeat: false,
    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%2f53256000%2frun-go-file-from-github-inside-docker%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It depends what you want to do here. If your aim is to create an image for your production-ready app that you want to release for other people to use then you would need a Dockerfile that contains the instructions to fetch your code using go get -v "github_repo_directory". This would result in a new image that you could distribute. However this won't be useful for development, because any change you make to your code means you'll have to rebuild this image.



    If you want to use Docker as a development environment you need to be able to see the changes you make locally right away. In this case you will be using the base image that allows you to run your app (e.g. the image provided by go), and you should mount your codebase inside the docker container. I would suggest reading up a bit on Docker, this article might be helpful.






    share|improve this answer


























      0














      It depends what you want to do here. If your aim is to create an image for your production-ready app that you want to release for other people to use then you would need a Dockerfile that contains the instructions to fetch your code using go get -v "github_repo_directory". This would result in a new image that you could distribute. However this won't be useful for development, because any change you make to your code means you'll have to rebuild this image.



      If you want to use Docker as a development environment you need to be able to see the changes you make locally right away. In this case you will be using the base image that allows you to run your app (e.g. the image provided by go), and you should mount your codebase inside the docker container. I would suggest reading up a bit on Docker, this article might be helpful.






      share|improve this answer
























        0












        0








        0






        It depends what you want to do here. If your aim is to create an image for your production-ready app that you want to release for other people to use then you would need a Dockerfile that contains the instructions to fetch your code using go get -v "github_repo_directory". This would result in a new image that you could distribute. However this won't be useful for development, because any change you make to your code means you'll have to rebuild this image.



        If you want to use Docker as a development environment you need to be able to see the changes you make locally right away. In this case you will be using the base image that allows you to run your app (e.g. the image provided by go), and you should mount your codebase inside the docker container. I would suggest reading up a bit on Docker, this article might be helpful.






        share|improve this answer












        It depends what you want to do here. If your aim is to create an image for your production-ready app that you want to release for other people to use then you would need a Dockerfile that contains the instructions to fetch your code using go get -v "github_repo_directory". This would result in a new image that you could distribute. However this won't be useful for development, because any change you make to your code means you'll have to rebuild this image.



        If you want to use Docker as a development environment you need to be able to see the changes you make locally right away. In this case you will be using the base image that allows you to run your app (e.g. the image provided by go), and you should mount your codebase inside the docker container. I would suggest reading up a bit on Docker, this article might be helpful.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 12:03









        mickadoo

        2,0191429




        2,0191429






























            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%2f53256000%2frun-go-file-from-github-inside-docker%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







            這個網誌中的熱門文章

            Academy of Television Arts & Sciences

            L'Équipe

            1995 France bombings