Deploy the App
Page last updated:
Page last updated:
In this step, you will deploy the app to Swisscom Application Cloud.
Push your app to the cloud by executing the following command and replacing the “my-random-hostname” with your own hostname. This will be part of the URL your app will be reached at and it has to be globally unique so be creative. The -m 64M
tells Cloud Foundry to use 64MB of memory for our app which should be plenty.
$ cf push my-go-app -m 64M -n my-random-hostname Creating app my-go-app in org MyOrg / space MySpace as user@mydomain.com... OK Creating route my-random-hostname.scapp.io... OK Binding my-random-hostname.scapp.io to my-go-app... OK Uploading my-go-app... Uploading app files from: /Users/taafuto1/go/src/github.com/swisscom/cf-sample-app-go Uploading 912B, 3 files Done uploading OK ... OK App my-go-app was started using this command `cf-sample-app-go` Showing health and status for app my-go-app in org MyOrg / space MySpace as user@mydomain.com... OK requested state: started instances: 1/1 usage: 64M x 1 instances urls: my-random-hostname.scapp.io last uploaded: Mon Nov 7 13:59:18 UTC 2016 stack: cflinuxfs2 buildpack: Go state since cpu memory disk details #0 running 2016-11-07 02:59:51 PM 0.0% 3.3M of 64M 8.7M of 1G
The application is now deployed. Ensure that the app is running:
$ cf app my-go-app Showing health and status for app my-go-app in org MyOrg / space MySpace as user@mydomain.com... OK requested state: started instances: 1/1 usage: 64M x 1 instances urls: my-random-hostname.scapp.io last uploaded: Mon Nov 7 13:59:18 UTC 2016 stack: cflinuxfs2 buildpack: Go state since cpu memory disk details #0 running 2016-11-07 02:59:51 PM 0.0% 7M of 64M 8.7M of 1G
Now visit the app at the URL. You can find the URL in the urls
property of the statement above.
Binary buildpack
By building your app locally using the go build
command, you can also push your application as a binary file using the Binary buildpack. This method allows you to manage dependencies locally and is an alternative to using the standard Go buildpack. To try it out, execute the following commands:
$ GOOS=linux GOARCH=amd64 go build $ cf push my-go-app -b binary_buildpack -c './cf-sample-app-go'
The first line tells go to cross-compile your app for linux so that it runs in the cloud. The -c
flag specifies the command to start your app with. In our case, that’s just executing the binary.