I've made a Golang application and I've no problem getting it to work on Heroku using the buildpack but now I would like to distribute the compiled program to others without the source code.
Is it possible to get the binary working on Heroku without the source code or does Heroku need the source code to create its own compiled version?
The Heroku buildpack for Go doesn't do anything special: it just calls out to the Go tool to compile the binary based on whether you use godeps or not.
Just call go build in the directory of your package main or go build repo.com/you/yourmainpackage to output a binary you can distribute.
In addition, you'll want to see this buildpack if you want to have others run a provided binary on Heroku: https://github.com/ph3nx/heroku-binary-buildpack — make sure the binary has been compiled for amd64 Linux if you are targeting Heroku.
Related
I am trying to Access GCP Managed Prometheus metrics from Grafana on Windows, for which I need to compile a Windows static binary for the Prometheus UI Frontend so that I can use it as an authentication proxy for Grafana.
I have downloaded the Go source from GitHub as well as Go for Windows v1.19.3.
Running go run main.go resulted in a bunch of errors similar to the following:
main.go:43:2: no required module provides package github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui; to add it:
go get github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui
I whittled these down by running the go get commands as indicated. One such command resulted in a further complaint about git being unavailable, so I added the Windows binary for that as well to the PATH and proceeded with the process. Ultimately however I'm left with the following error:
D:\Go>go get github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui
go: github.com/GoogleCloudPlatform/prometheus-engine/pkg/ui: no matching versions for query "upgrade"
A web search for the error hasn't been of much help. Suspecting some sort of version conflict I've tried with Go v1.18.8 as well, but that results in the same error. Since I'm simply Going about this blindly, having zero prior experience with Go, I'd really appreciate some help in this matter.
I'm trying to find a way to make the compilation of a Go program faster. It is currently about 30 seconds, which makes it slow to work with the project.
When I run go build -v, I see that most of the time is spent compiling go-sqlite3 (which links to the C sqlite lib). However, since this lib never changes, I'm wondering if it's possible to prevent the build tool from recompiling this every time?
Try go install -a github.com/mattn/go-sqlite3 which will install the compiled-against-Go-1.3 package into your $GOPATH.
Right now, you likely have an older version installed under $GOPATH/pkg/ and therefore Go is recompiling it for every build.
This is likely due to you upgrading to go 1.3
I had to remove $GOPATH/pkg to get rid of old (incompatible) binaries
and then it was able to cache compilation results again
In Go 1.10 no need to run go install etc. Just use go build. The new version uses a build cache to determine which packages need to be re-compiled.
Check out: https://tip.golang.org/doc/go1.10
Context
I'm new to Heroku, and fairly new to Google Protocol Buffers.
Steps Taken
Searched Stack Overflow
Searched Heroku help
Searched Google
Question
Is there way to install the Google Protocol Buffers on the Heroku platform?
You do not need to "install" Protobufs to use it at run-time. Just bundle the Protobuf Python code and the code generated by the Protobuf compiler together with your application's other code. The compiler (protoc) is only needed to generate code; it is not used when your application actually runs. So, there should be no problem.
If you want to use the experimental C-extension-backed implementation (which is off by default), you will also need to include the .so file implementing the extension. I am not personally very familiar with C extensions so I'm not sure exactly where you're supposed to put it, but again, you should be able to bundle it with your application without installing anything. I am also not very familiar with Heroku so I do not know if they will let you run C extensions -- I know that AppEngine, in comparison, does not allow extensions.
I want to use Node.js as a Share.js server and Ruby for the frontend. As far as I know, Heroku only allows one web-facing process called "web". Does anyone have some experience trying to do something like this?
No, Heroku detects the application type when you push your code to Heroku and it compiles the slug. You'd need to have them as seperate applications with a defined API between the two (not always a bad thing)
UPDATE: You can 'stack' buildpacks these days, eg Ruby + PHP so you could have both executed. See https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app for how to use multiple buildpacks in the same app.
As a caveat, you technically can install two languages on a single app — but I'm not sure about running them concurrently. I made this buildpack to combine NodeJS and PHP (so that I could run Grunt during the slug compilation):
https://github.com/gcpantazis/heroku-buildpack-php-gruntjs
The language detection is usually fairly dumb; it'll be looking for a file indicative of the lang, i.e. index.php or a rakefile. You'll have to change the detect bin so that your code will pass.
Update:
Even better, consider using https://github.com/ddollar/heroku-buildpack-multi ; it'll let you install buildpacks sequentially. Depending on your application you might need to find language buildpacks that don't have verification steps, i.e. checking for a package.json file in a NodeJS app.
Yes, it is mostly possible I believe, as long as you're not doing something very tricky. I once deployed a Flask (Python) app that used Stanford's CoreNLP - which is all written in Java. You will need heroku-buildpack-multi.
After adding this, make sure to make a .buildbacks file and add all the buildpacks you will be needing from the Heroku github.
This circumvents Heroku detecting your app type itself and makes it install all necessary buildpacks from the .buildpacks file.
I've got a ruby web app that uses lilypond to generate sheet music based on user input. I'd like to move the hosting to heroku (I've recently used heroku on a few projects and really liked it, plus my traffic is low enough that it'd be free host it on heroku, for a while at least). However, heroku's dyno architecture doesn't allow you to ssh in and install whatever packages you want...instead, you give it a gems manifest, and it will install the gems for you.
So, if I'm going to deploy to heroku, I'm going to need to package lilypond as a gem. I've released a few pure-ruby gems, but haven't dealt with native extensions or precompiled binaries, or anything like that.
Is it possible to take some precompiled binaries and package it inside a gem? Ideally, this would include binaries for OS X (which I develop on) and debian linux (which is what's running on heroku), and would install the proper binary when the gem was installed.
it is possible, since precompiled binary gems for windows are the norm. Take a look at rake compiler, perhaps.
also https://github.com/rdp/ruby_tutorials_core/wiki/gem (https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems) might help
-r
I think you've got a few options here:
You could get the Lilypond source and package it into a gem with a native C extension. There are some useful guides on how to do that at http://guides.rubygems.org/c-extensions/ and http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions
There's also a gem called gitara but I haven't been able to find any information about using it on Heroku. It might be worth emailing the author and asking if he knows anything about that.
You could create a Heroku buildpack that installs Lilypond as part of your deployment. I wasn't able to find any for Lilypond, but there are plenty of examples that do similar things - for example, this one installs Imagemagick (which is included by default on Heroku, so probably not necessary anymore - but hopefully the code is helpful). More documentation at https://devcenter.heroku.com/articles/buildpack-api and https://devcenter.heroku.com/articles/buildpack-binaries
Based on my reading, I think the buildpack option is the best way to go.
Hopefully this helps!
Instead of precompiling, you should be able to just list the gem in your .gems file, see the Heroku documentation. Of course, this requires your gem builds the native code correctly - this is still a task, but hopefully an easier one.