douxu4610 2015-09-21 03:32
浏览 100
已采纳

Docker-compose golang-无可构建源

I've followed a couple of tutorials and am having trouble figuring out what i've done wrong. I suspect its a very basic principal but that said as i'm new to both GoLang and docker-compose i'm not 100% sure which is my problem.

I'm running the golang:build docker image which just retrieves a couple github repositories.

Any help would be much appreciated.

The error is as follows:

+ exec go get -v -d
can't load package: package app: no buildable Go source files in /go/src/app
Service 'ddd' failed to build: The command '/bin/sh -c go-wrapper download' returned a non-zero code: 1

The Docker-Compose file looks like this

ddd:
  build: ./goSvc
  working_dir: /go/src/
  command: go run main.go
  volumes:
    - ./goSvc/src/main.go:/go/src/main.go
    - ./goSvc/src/ddd:/go/src/ddd
  ports:
    - 8080:8080
  environment:
    - DB_NAME=rnse
    - DEBUG=true

Go project structure

root
  goSvc
    pkg
    src
      ddd
        internal
          logic
        ...myGoFiles
      github.com
      main.go
    Dockerfile

Edit: Including docker file for golang:

FROM golang:onbuild
RUN go get github.com/gorilla/mux
RUN go get github.com/lib/pq
EXPOSE 8080
  • 写回答

1条回答 默认 最新

  • dongtuoao7987 2015-09-22 08:51
    关注

    Image you used is used to automatically build Go app when building initial image.

    Have a look at it's Dockerfile. There is ONBUILD COPY . /go/src/app statement.

    So you can either locate Dockerfile where main.go is located or use image without ONBUILD trigger and then run go run manually/with docker-compose.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动