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 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题