Hello,
I have reviewed two online references related to deploying a Go app to Heroku, https://devcenter.heroku.com/articles/deploying-go and https://confluence.atlassian.com/bitbucket/deploy-to-heroku-872013667.html.
I am struggling with understanding how I can deploy a Go App to Heroku from Bitbucket when the repository is private and it includes a private repo package. I have not been able to find an end-to-end example for this scenario.
Any ideas or advice would be appreciated, thank you.
Aaron
Hi Aaron,
Have you got any specific error messages we can work off? This seems like it's an authentication problem?
If you already use Heroku on your local machine then you should be able to copy over the script commands you use with the appropriate auth set up. If you haven't gotten that set up yet locally, it'll probably be easier for you to figure that out first before trying to set up Pipelines.
For setting up Pipelines, you will probably need to piece together a few bits of documentation.
(The following is all untested, so you may encounter errors that you may need to do some further debugging with)
The first thing you'll need to do is set up a Go build + test environment.
We have a full Golang example here: https://bitbucket.org/atlassian/pipelines-examples-go/src/master/
And another one here with just a configuration: https://confluence.atlassian.com/bitbucket/language-guides-856821477.html
# This is a sample build configuration for Go.
# Only use spaces to indent your .yml configuration.
# -----
# You can use any Docker image from Docker Hub, or your own container registry, as your build environment.
image: golang:1.7
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}"
- mkdir -pv "${PACKAGE_PATH}"
- tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
- cd "${PACKAGE_PATH}"
- go get -v
- go build -v
- go test -v
The next thing you'll need to do is set up Heroku. That's where our Heroku guide comes in: https://confluence.atlassian.com/bitbucket/deploy-to-heroku-872013667.html?_ga=2.164091126.859441905.1522715061-825437565.1515570924
So you should have a configuration that now looks something like:
image: golang:1.7
clone:
depth: full
pipelines:
default:
- step:
script: # Modify the commands below to build your repository.
- PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}"
- mkdir -pv "${PACKAGE_PATH}"
- tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
- cd "${PACKAGE_PATH}"
- go get -v
- go build -v
- go test -v
- git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
Finally you'll need to ensure your build is in line with the Heroku docs here: https://devcenter.heroku.com/articles/deploying-go As, Heroku will need to rebuild you Golang app in order for it to run.
A lot to do here. Get it working locally first if you haven't already, it'll make more sense once you try to do it in Pipelines instead.
Thanks,
Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.