dousong5161 2018-11-12 04:32
浏览 60

从Docker内部的Github运行go文件

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/

  • 写回答

1条回答 默认 最新

  • doucuan5365 2018-11-13 12:03
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?