Git Product home page Git Product logo

cf-meteor-buildpack's Introduction

Cloud Foundry Meteor Buildpack

##Create a sample app with 'meteor'

% meteor create --example leaderboard
leaderboard: created.

To run your new app:
   cd leaderboard
   meteor

##Initial deploy of your app

We need to do an initial deploy of our app to Cloud Foundry so the app environment and bound services can be modified in following steps.

% cf push leaderboard -b https://github.com/cloudfoundry-community/cf-meteor-buildpack.git --no-start

This will not start the app, it will only upload the app. We will need to create a database to make the example app work.

##Start your Cloud Foundry app

To bind a Mongo service to our app we will look into the Cloud Foundry marketplace, create a mongo service instance and then bind that instance to our app.

There are two options, you can use MongoDB or Mongolab.

###MongoDB

% cf marketplace
Getting services from marketplace in org cs-home / space development as [username]...
OK

service   plans   description
mongodb   100    MongoDB NoSQL database

% cf create-service mongodb 100 leaderboard-mongodb
Creating service leaderboard-mongodb in org cs-home / space development as [username]...
OK

% cf services
Getting services in org cs-home / space development as [username]...
OK

name               service   plan   bound apps
leaderboard-mongodb   mongodb   100

% cf bind-service leaderboard leaderboard-mongodb
Binding service leaderboard-mongodb to app leaderboard in org [org] / space development as [username]...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect

% cf start leaderboard
Starting app leaderboard in org [org] / space development as [username]...
...
1 of 1 instances running

App started
...

###MongoLab

% cf marketplace
Getting services from marketplace in org cs-home / space development as [username]...
OK

service   plans   description
mongolab  sandbox    MongoDB NoSQL database

% cf create-service mongolab sandbox leaderboard-mongolab
Creating service leaderboard-mongolab in org cs-home / space development as [username]...
OK

% cf services
Getting services in org cs-home / space development as [username]...
OK

name               service   plan   bound apps
leaderboard-mongolab   mongolab   sandbox

% cf bind-service leaderboard leaderboard-mongolab
Binding service leaderboard-mongolab to app leaderboard in org [org] / space development as [username]...
OK
TIP: Use 'cf restage' to ensure your env variable changes take effect

% cf start leaderboard
Starting app leaderboard in org [org] / space development as [username]...
...
1 of 1 instances running

App started
...

Now the leaderboard app should be running on Cloud Foundry. Go to your ROOT_URL, http://leaderboard.[CF Domain URL] in a 2 browsers and watch updates show up on the other browser immediately via web sockets to Cloud Foundry app.

cf-meteor-buildpack's People

Contributors

adelevie avatar afeld avatar csterwa avatar jsloyer avatar shinji62 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cf-meteor-buildpack's Issues

Specifying Meteor settings

How can I specify Meteor settings to run the app with? Env variables set by GUI or cf set-env do not apply when running the app.

Upload Failed Server Error 500

Error when trying to upload my meteor project using cf cli and this buildpack -

Server error, status code: 500, error code: 0, message:

Have tried several times. Error code always 0 and message always blank.

Anything else I can try?

Thanks.

Does this still work?

I successfully uploaded an app to IBM Bluemix a couple of months ago, but now I can't push either my own app, nor the leaderboard example to Bluemix using the instructions in the documentation. Does anyone else have a problem doing so?

Thanks

Support for offline environment

I need to use this buildpack in an environment which is not connected to the internet.
I have the necessary Meteor and Node versions in my network, Do I need to change only their URLs?

Deploying of todos example fails

Hi,

I tried to follow the instructions at http://www.managingsoftwaredebt.com/2015/03/25/deploying-meteor-apps-to-cloud-foundry/ the best I could, but did not manage to get the todos example running on Cloud Foundry. One thing I needed to change was the command for creating the MongoDB service. I used cf create-service mongolab sandbox todos-mongo since at least the Pivotal CF was not offering a mongodb service.

These are the contents of manifest.yml

---
applications:
- name: meteor-todos
  memory: 512M
  buildpack: https://github.com/csterwa/cf-meteor-buildpack.git
  services:
    - todos-mongo

And here's the tail of log output:

2015-06-16T09:44:27.92+0300 [STG/0] ERR + echo Meteor 1.1.0.2 has been installed in your home directory (/.meteor).
2015-06-16T09:44:27.92+0300 [STG/0] ERR Meteor 1.1.0.2 has been installed in your home directory (
/.meteor).
2015-06-16T09:44:27.92+0300 [STG/0] ERR + readlink /home/vcap/.meteor/meteor
2015-06-16T09:44:27.92+0300 [STG/0] ERR + METEOR_SYMLINK_TARGET=packages/meteor-tool/1.1.3/mt-os.linux.x86_64/meteor
2015-06-16T09:44:27.92+0300 [STG/0] ERR + dirname packages/meteor-tool/1.1.3/mt-os.linux.x86_64/meteor
2015-06-16T09:44:27.92+0300 [STG/0] ERR + METEOR_TOOL_DIRECTORY=packages/meteor-tool/1.1.3/mt-os.linux.x86_64
2015-06-16T09:44:27.92+0300 [STG/0] ERR + LAUNCHER=/home/vcap/.meteor/packages/meteor-tool/1.1.3/mt-os.linux.x86_64/scripts/admin/launch-meteor
2015-06-16T09:44:27.92+0300 [STG/0] ERR + cp /home/vcap/.meteor/packages/meteor-tool/1.1.3/mt-os.linux.x86_64/scripts/admin/launch-meteor /usr/local/bin/meteor
2015-06-16T09:44:27.93+0300 [STG/0] ERR + type sudo
2015-06-16T09:44:27.93+0300 [STG/0] ERR + echo Writing a launcher script to /usr/local/bin/meteor for your convenience.
2015-06-16T09:44:27.93+0300 [STG/0] ERR Writing a launcher script to /usr/local/bin/meteor for your convenience.
2015-06-16T09:44:27.93+0300 [STG/0] ERR + echo This may prompt for your password.
2015-06-16T09:44:27.93+0300 [STG/0] ERR This may prompt for your password.
2015-06-16T09:44:27.93+0300 [STG/0] ERR + [ ! -d /usr/local/bin ]
2015-06-16T09:44:27.93+0300 [STG/0] ERR + sudo cp /home/vcap/.meteor/packages/meteor-tool/1.1.3/mt-os.linux.x86_64/scripts/admin/launch-meteor /usr/local/bin/meteor
2015-06-16T09:44:27.93+0300 [STG/0] ERR sudo: no tty present and no askpass program specified
2015-06-16T09:44:27.94+0300 [STG/0] ERR + cat
2015-06-16T09:44:27.94+0300 [STG/0] ERR Couldn't write the launcher script. Please either:
2015-06-16T09:44:27.94+0300 [STG/0] ERR (1) Run the following as root:
2015-06-16T09:44:27.94+0300 [STG/0] ERR cp "/home/vcap/.meteor/packages/meteor-tool/1.1.3/mt-os.linux.x86_64/scripts/admin/launch-meteor" /usr/bin/meteor
2015-06-16T09:44:27.94+0300 [STG/0] ERR (2) Add "$HOME/.meteor" to your path, or
2015-06-16T09:44:27.94+0300 [STG/0] ERR (3) Rerun this command to try again.
2015-06-16T09:44:27.94+0300 [STG/0] ERR Then to get started, take a look at 'meteor --help' or see the docs at
2015-06-16T09:44:27.94+0300 [STG/0] ERR docs.meteor.com.
2015-06-16T09:44:27.94+0300 [STG/0] ERR + trap - EXIT
2015-06-16T09:44:27.94+0300 [STG/0] OUT -----> Done
2015-06-16T09:44:27.94+0300 [STG/0] OUT -----> Updating PATH with Meteor
2015-06-16T09:44:27.94+0300 [STG/0] OUT -----> Building meteor bundle
2015-06-16T09:44:34.27+0300 [STG/0] ERR Supply the server hostname and port in the --server option for mobile app
2015-06-16T09:44:34.27+0300 [STG/0] ERR builds.
2015-06-16T09:44:34.30+0300 [STG/0] ERR /tmp/buildpacks/cf-meteor-buildpack/bin/compile: line 75: cd: deploy/bundle/programs/server: No such file or directory
2015-06-16T09:44:34.30+0300 [STG/0] OUT -----> Installing npm dependencies
2015-06-16T09:44:34.82+0300 [STG/0] OUT npm ERR! install Couldn't read dependencies
2015-06-16T09:44:34.82+0300 [STG/0] OUT npm ERR! package.json ENOENT, open '/tmp/staged/app/package.json'
2015-06-16T09:44:34.82+0300 [STG/0] OUT npm ERR! package.json This is most likely not a problem with npm itself.
2015-06-16T09:44:34.82+0300 [STG/0] OUT npm ERR! package.json npm can't find a package.json file in your current directory.
2015-06-16T09:44:34.82+0300 [STG/0] OUT npm ERR! System Linux 3.16.0-39-generic
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! command "/tmp/staged/app/.vendor/node/bin/node" "/tmp/staged/app/.vendor/node/bin/npm" "install"
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! cwd /tmp/staged/app
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! node -v v0.10.38
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! npm -v 1.4.28
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! path /tmp/staged/app/package.json
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! code ENOPACKAGEJSON
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! errno 34
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR!
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! Additional logging details can be found in:
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! /tmp/staged/app/npm-debug.log
2015-06-16T09:44:34.83+0300 [STG/0] OUT npm ERR! not ok code 0
2015-06-16T09:44:34.84+0300 [STG/0] OUT -----> Checking for post_compile script
2015-06-16T09:44:41.89+0300 [STG/43] OUT -----> Uploading droplet (90M)
2015-06-16T09:44:51.33+0300 [DEA/43] OUT Starting app instance (index 0) with guid a1f1e0e5-b71c-4940-9391-8eacb12b8627
2015-06-16T09:44:55.85+0300 [App/0] ERR
2015-06-16T09:44:55.85+0300 [App/0] ERR module.js:340
2015-06-16T09:44:55.85+0300 [App/0] ERR throw err;
2015-06-16T09:44:55.85+0300 [App/0] ERR ^
2015-06-16T09:44:55.86+0300 [App/0] ERR Error: Cannot find module '/home/vcap/app/deploy/bundle/main.js'
2015-06-16T09:44:55.86+0300 [App/0] ERR at Function.Module._resolveFilename (module.js:338:15)
2015-06-16T09:44:55.86+0300 [App/0] ERR at Function.Module._load (module.js:280:25)
2015-06-16T09:44:55.86+0300 [App/0] ERR at Function.Module.runMain (module.js:497:10)
2015-06-16T09:44:55.86+0300 [App/0] ERR at startup (node.js:119:16)
2015-06-16T09:44:55.86+0300 [App/0] ERR at node.js:935:3
2015-06-16T09:44:55.86+0300 [App/0] OUT
2015-06-16T09:44:55.94+0300 [DEA/43] ERR Instance (index 0) failed to start accepting connections
2015-06-16T09:44:56.00+0300 [API/0] OUT App instance exited with guid a1f1e0e5-b71c-4940-9391-8eacb12b8627 payload: {"cc_partition"=>"default", "droplet"=>"a1f1e0e5-b71c-4940-9391-8eacb12b8627", "version"=>"9dd1a67e-5c83-49cc-8b5e-cd7a2affb4db", "instance"=>"5e2dda678d034e04afd10e31a434bee5", "index"=>0, "reason"=>"CRASHED", "exit_status"=>8, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1434437095}
2015-06-16T09:44:56.01+0300 [API/0] OUT App instance exited with guid a1f1e0e5-b71c-4940-9391-8eacb12b8627 payload: {"cc_partition"=>"default", "droplet"=>"a1f1e0e5-b71c-4940-9391-8eacb12b8627", "version"=>"9dd1a67e-5c83-49cc-8b5e-cd7a2affb4db", "instance"=>"5e2dda678d034e04afd10e31a434bee5", "index"=>0, "reason"=>"CRASHED", "exit_status"=>8, "exit_description"=>"failed to accept connections within health check timeout", "crash_timestamp"=>1434437095}

Any ideas what's going wrong? I'll be happy to provide you with more information if needed.

Meteor 1.4 AssertionError: "undefined" === "function"

Meteor is now at 1.4: http://info.meteor.com/blog/announcing-meteor-1.4

The bluemix meteor buildpack picks up the 1.4 bootstrap, but the compile has not been changed to install node4 so you get the following error in bluemix when the application tries to start:

2016-07-28T09:56:24.854+0100[DEA/182]OUTStarting app instance (index 0) with guid 4338337c-4f95-4079-a663-cbe0ef82eb29
2016-07-28T09:56:30.362+0100[App/0]ERRassert.js:93
2016-07-28T09:56:30.362+0100[App/0]ERR
2016-07-28T09:56:30.363+0100[App/0]ERR throw new assert.AssertionError({
2016-07-28T09:56:30.363+0100[App/0]ERR ^
2016-07-28T09:56:30.366+0100[App/0]ERR at Module._compile (module.js:456:26)
2016-07-28T09:56:30.366+0100[App/0]ERR at Function.Module._load (module.js:312:12)
2016-07-28T09:56:30.366+0100[App/0]ERRAssertionError: "undefined" === "function"
2016-07-28T09:56:30.366+0100[App/0]ERR at Object. (/home/vcap/app/deploy/bundle/programs/server/boot.js:9:13)
2016-07-28T09:56:30.366+0100[App/0]ERR at require (module.js:380:17)
2016-07-28T09:56:30.366+0100[App/0]ERR at Object.Module._extensions..js (module.js:474:10)
2016-07-28T09:56:30.366+0100[App/0]ERR at Module.load (module.js:356:32)
2016-07-28T09:56:30.366+0100[App/0]ERR at Module.require (module.js:364:17)
2016-07-28T09:56:30.366+0100[App/0]ERR at Object. (/home/vcap/app/deploy/bundle/programs/server/mini-files.js:108:24)
2016-07-28T09:56:30.366+0100[App/0]ERR at Module._compile (module.js:456:26)
2016-07-28T09:56:30.366+0100[App/0]ERR at wrapPathFunction (/home/vcap/app/deploy/bundle/programs/server/mini-files.js:77:10)

Because mini-files.js:108 is specifying a node 4 function.

I have tried changing compile line to:
node_version=$(curl --silent --get https://semver.io/node/resolve/4.4.x)
which works fine with a simple try-meteor app.

Environment variable overwritten

cf-meteor-buildpack/bin/release

extract_root_url()

Custom domains are ignored. If I set an user variable with ROOT_URL, it is ignored and only the VCAP application is taken. While this is nice with the standard settings it causes problems if you want to overwrite this with a custom domain on purpose. (using bluemix, not sure if this is a common problem)

It would be nice to have a check if there is an existing environment variable and only set a new one if there is not.

Found an error and have a proposed fix

I love that this buildpack automagically sets the MONGO_URL, but I'm finding its current implementation inflexible:

export MONGO_URL=`echo $VCAP_SERVICES | $jq '."mongodb-2.4"[0].credentials.url'`

The Mongo version is hardcoded into the jq selector. I wonder if this could be re-written as something like:

export MONGO_URL=`echo $VCAP_SERVICES | $jq '."mongodb-*"[0].credentials.ur*'`

I implemented a quick and dirty fix that works in my organization, 18F, but perhaps we should coalesce around a more robust solution?

Thoughts, @afeld, @dlapiduz?

Error since 1.3 release

Since 1.3 release, I get

line 75: cd: deploy/bundle/programs/server: No such file or directory

I think this line did not do its job.

I have been deploying fine until 1.3 release. The buildpack installs Meteor 1.3 now because the install script was updated. My app is using 1.2.1.

Websocket issues

Have any of you had issues with web sockets when deployed on cf?

I've been getting:

WebSocket connection to 'wss://iaa-mvp.18f.gov/sockjs/820/8st6qt8v/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400

link

So I read on StackOverflow that I need to set the DDP_DEFAULT_CONNECTION_URL to use port 4443. I did that (DDP_DEFAULT_CONNECTION_URL: ddp+sockjs://iaa-mvp.18f.gov:4443/sockjs), and then I got a CORS error.

I added

WebApp.connectHandlers.use(function(req, res, next) {
  res.setHeader("Access-Control-Allow-Origin", "*");
  return next();
});

to the isServer block, but I'm still getting the same CORS error from before (from Chrome Dev Tools):

XMLHttpRequest cannot load https://iaa-mvp.18f.gov:4443/sockjs/info?cb=5kzx7yu53l. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://iaa-mvp.18f.gov' is therefore not allowed access.

Any help or guidance here would be great.

cc @dlapiduz @afeld

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.