GithubHelp home page GithubHelp logo

Comments (6)

apisit avatar apisit commented on May 21, 2024 9

I am able to use dep with codebuild fine when properly define a SRC_DIR in buildspec.yaml and if the submitter is root meaning click start build directly in codebuild

env:
  variables:
    SRC_DIR: src/github.com/xxx/xxx

in the build logs there should be

CODEBUILD_SRC_DIR=/codebuild/output/src694249801/src/github.com/xxx/xxx

However, if I were to use codepipeline to be a submitter, it doesn't seem to create a directory defined in buildspec and this causes dep to fail

This error

root project import: dep does not currently support using GOPATH/src as the project root

Build logs

CODEBUILD_SRC_DIR=/codebuild/output/src127950602/src

would love to know how to solve this.

from aws-codebuild-docker-images.

rvdwijngaard avatar rvdwijngaard commented on May 21, 2024 6

Thanks for your answer @clareliguori; I think it might be very useful to give an example of building a golang project with sub packages and dep with codebuild.

from aws-codebuild-docker-images.

luckydev avatar luckydev commented on May 21, 2024 2

Another workaround for dep:

If you echo $GOPATH, we will get /go:/codebuild/output/src265478100. So if you simply copy all contents of vendor/ contents to /go, build succeeds for me. I'm running aws managed go 1.10.x machine image in codebuild config.

version: 0.2

env:
  variables:
    GOOS: "linux"
phases:
  install:
    commands: 
      - echo CODEBUILD_SRC_DIR - $CODEBUILD_SRC_DIR
      - echo GOPATH - $GOPATH
      - echo GOROOT - $GOROOT
      - echo Moving packages
      - cp -r ./vendor/* /go/src/
  build:
    commands:
      - echo Build started on `date`
      - echo Compiling the Go code...
      - go build -o app main.go 
  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - app
    - appspec.yml
    - buildspec.yml
    - codedeploy/*

Catch here is - you have to commit vendor/ to git. Which is fine because many projects commit all the deps to the repo to have one solid working unit without relying on packages/repos disappearing from remotes.

from aws-codebuild-docker-images.

sapessi avatar sapessi commented on May 21, 2024 1

@apisit I'm running into the same issue with dep - documented on golang/dep#417

This is how I worked around it in my buildspec file:

phases:
  pre_build:
    commands:
      - mkdir -p ../github.com/sapessi/xxxxxxx
      - mv * ../github.com/sapessi/xxxxxxx
      - mv ../github.com .
      - cd github.com/sapessi/xxxxxxx && dep ensure
...

from aws-codebuild-docker-images.

clareliguori avatar clareliguori commented on May 21, 2024

Thanks for reporting this @rvdwijngaard! We're working on getting the dep permissions fixed in our internal release process. In the meantime, chmod +x /go/bin/dep in your buildspec should get your build going.

from aws-codebuild-docker-images.

clareliguori avatar clareliguori commented on May 21, 2024

Fixed f524c81

from aws-codebuild-docker-images.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.