I'm trying to figure out how to deploy a Cloudfoundry application that uses the Vapor infrastructure on IBM Bluemix.
IBM provides tools and recommendations for using its Swift server application development platform with its Kitura framework. I think that as a Cloudfoundry provider, with the appropriate Swift package, we should be able to deploy shared server-side Swift code.
Finally, while studying CF bits, I got to the point where with CLI CloudFoundry:
- I am connecting to the Bluemix API endpoint (api.eu-gb.bluemix.net)
- Input ok (after extending the timeout env. Var CF_DIAL_TIMEOUT to 20)
- Creating a "cf push". He creates the application, downloads and compiles everything.
- The application state is running.
But when I load the page ( https://sommobilitatcore.eu-gb.mybluemix.net/ ), I get:
404 Not Found: Requested route ('sommobilitatcore.eu-gb.mybluemix.net') does not exist.
Can someone help me with this? Thanks!
In some context:
. manifest.yml:
applications: - path: . memory: 256M instances: 1 name: SomMobilitatCore disk_quota: 1024M buildpack: https:
Profile
web: App
(main.swift is in Source / App /)
No port is configured in the Vapor configuration files, then Vapor tries to listen on port 80:
import Vapor import HTTP let drop = Droplet() let _ = drop.config["app", "key"]?.string ?? "" drop.get("/") { request in return try drop.view.make("welcome.html") } (...) let port = drop.config["app", "port"]?.int ?? 80
UPDATE:
Finally, run it without Procfile, manifest.yml
- path: . instances: 1 memory: 256M disk_quota: 1024M name: SomMobilitat4 command: App --env=production --workdir="./" buildpack: swift_buildpack
And / Config / production / servers.json:
{ "production": { "port": "$PORT" } }
I do not specify a port variable in the main.swift file. With the updated version of Vapor:
import Vapor import HTTP let drop = Droplet() drop.get("/") { request in return "hello vapor in bluemix cloudfoundry" } drop.run()
If you're new to Cloudfoundry or IBM Bluemix, this is the way to work: