duanlang1196 2015-03-22 19:06
浏览 64

Docker的推荐项目结构

I'm working on a Go project that has the following structure (schematic):

./lib1
./prog1
    ./...
./prog2
    ./...

Where:

  • lib1 is a library
  • prog1 and prog2 are executables (both depend on lib1)

In a nutshell: How do I create Dockerfiles for prog1 and prog2?


I tried several approaches, all to no avail:

Creating a Dockerfile in prog1/

Failed because docker cannot ADD ../lib1 to the container since it is out of the context (see http://docs.docker.com/reference/builder/#add).

Creating a Dockerfile in the root directory

Ignoring the fact that I actually need two Dockerfiles (for prog1, and for prog2), I tried placing the Dockerfile in the root directory of the project.

However, the docker image I need to use (golang:1.4.1-onbuild) fails to find any Go files (since they are in ./prog1, and not in the root):

+ exec go install -v
can't load package: package app: no buildable Go source files in /go/src/app

What is the recommended project structure for the golang:1.4.1-onbuild image?


Edit: Better asked here: https://stackoverflow.com/questions/29209202/dockerizing-gos-hello-world

  • 写回答

1条回答 默认 最新

  • dopgv00024 2015-03-22 19:21
    关注

    Most pull the files in via their VCS or just go get instead of using ADD. You add the the source tree in the same way regardless of what tool your building, since you need the structure of $GOPATH to be the same for each.

    Note, you can also name your docker file via docker build -f, so if you want to use ADD, you can have multiple DOCKERFILEs in your root directory.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?