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.
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.