I'm trying to push Go app into cloud foundry. When I try to build the binary and push it the app crashes and it returns start unsuccessful.
This is my manifest file
---
applications:
- name: project-suspension
instances: 1
memory: 256MB
disk_quota: 512MB
buildpacks:
- go_buildpack
- binary_buildpack
env:
GOPACKAGENAME: dev.azure.com/.../service-infrastructure
I tried putting every file inside the root folder of the project but the app is still crashing when I push it. The other thing i tried is using the command flag -c "project-suspension" and it still crashes.
CodePudding user response:
As mentioned in the comment, you don't need both buildpacks. Use either the go-buildpack, if you are pushing source code, or the binary buildpack if you are building locally and pushing the binary. If pushing a binary built locally, you need to cross-compile for Linux (unless you are running Linux as your workstation).
Ex:
---
applications:
- name: project-suspension
instances: 1
memory: 256MB
disk_quota: 512MB
buildpacks:
- go_buildpack
env:
GOPACKAGENAME: dev.azure.com/.../service-infrastructure
or
---
applications:
- name: project-suspension
instances: 1
memory: 256MB
disk_quota: 512MB
buildpacks:
- binary_buildpack
command: ./project-suspension
The latter assumes that the binary you want to run is called project-suspension
and that it exists in the same directory from which cf push
is run (or the same directory where you've set path:
or -p
.
Also, be aware that applications can fail to start for other reasons, like if the health check does not pass. The default health check is going to be port-based, so it'll expect your application to be listening on the port number set with $PORT
. Make sure your app reads $PORT
and listens on that port.