Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment to Heroku #18

Closed
mrtysn opened this issue Oct 19, 2017 · 10 comments
Closed

Deployment to Heroku #18

mrtysn opened this issue Oct 19, 2017 · 10 comments
Assignees
Projects

Comments

@mrtysn
Copy link

mrtysn commented Oct 19, 2017

Can you include a section for Heroku deployment instructions?

@mrtysn
Copy link
Author

mrtysn commented Oct 19, 2017

I was able to get production build working with this setup:

"heroku-prebuild": "yarn build",
"start": "node dist/server.js",
"start-local": "cross-env NODE_ENV=development nodemon --exec babel-node --watch ./src/server.js --watch ./src/client.js --watch ./src/core --watch ./webpack ./src/server.js",
"lint": "eslint --ignore-path .gitignore src webpack",
"build": "cross-env NODE_ENV=production webpack -p --config ./webpack/prod.client.babel.js && cross-env NODE_ENV=production webpack -p --verbose --config ./webpack/prod.server.babel.js",
"test": "npm run lint && cross-env NODE_ENV=test mocha --require babel-core/register "src/**/*.test.js""

You have to rename start to something else, since it is the default script heroku runs, if no Procfile is found.

@mrtysn
Copy link
Author

mrtysn commented Oct 19, 2017

When I add additional packages via yarn (i.e. yarn add semantic-ui-react styled-components), heroku rejects the build:

Module not found: Error: Can't resolve 'semantic-ui-react' in '/tmp/build_36081507992b01d8e7e6d781af163fcf/src/app/components/header'

However, it works locally, both in development and production mode

@tirthbodawala
Copy link
Member

@mrtysn We create a bundle on local when you add packages please make sure you add it to devDependencies.
yarn add semantic-ui-react --dev
This makes sure that whenever the bundle is created it has the code included in it.

When you just add without "--dev" the bundle will depend on the node_modules folder to run it completely.

What we are trying to do here is build a single server.js file already transpiled to es5 and all other bundles includes their respective dependencies.

I Hope this solves your problem

@tirthbodawala
Copy link
Member

Also @mrtysn I tried the free version of Heroku but it shows the following in logs:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch 2017-10-19T20:01:45.458827+00:00 heroku[web.1]: Stopping process with SIGKILL

I think its due to free version and limited memory. I am new to heroku. I just saw it after the issue was raised.

Is there a way we can build the application locally and then push the dist folder, hence running node server.js ?

@mrtysn
Copy link
Author

mrtysn commented Oct 19, 2017

Unfortunately, heroku is not designed that way. You push your code via version control (e.g. git) and the build scripts are automatically executed, as they are defined in Procfile. If a Procfile is not provided, they execute some default scripts, depending on the detected application type. In case of node.js, the start script is run.

You can define the Procfile as necessary but I don't know what could be done about the limited memory issue since the paid version also do not have much memory.

How about demonstrating an example deployment to Amazon's (AWS) EC2 service? If you were to automate such a deployment via scripts, heroku wouldn't be necessary. Using an EC2 machine also means more control on the system, hence it is more preferable.

@ghost
Copy link

ghost commented Oct 20, 2017

My two cents is that a boilerplate should remain independent of too much opinion lest it need to find its niche in an overcrowded field—of which this repo already has with its SEO focus IMO.

@mrtysn
Copy link
Author

mrtysn commented Oct 20, 2017

What I'm suggesting here is not a modification to the codebase. A set of instructions in the deployment section of the docs would help first time users of the project to get going.

@tirthbodawala
Copy link
Member

@mrtysn Dockerizing the application is already in the plan ( I am almost there with my local setup and docker )
I also know most of the good service providers like amazon ec2, google cloud, heroku
are now supporting docker deploy.
I hope anyone with bit of docker knowledge would be able to deploy it easily and scale it with docker-swarm.
I hope that would be a good solution for your deployment problem as well.

@mrtysn
Copy link
Author

mrtysn commented Oct 23, 2017

Dockerizing seems like a more robust plan than tailoring to each of these platforms one by one. However, since the only difference for any such platform would be a single short script, I wouldn't suggest completely discarding simpler deployment solutions.

@mrtysn mrtysn closed this as completed Oct 23, 2017
@edwardkong86
Copy link

Any deployment instructions to Amazon EC2, Google Cloud & Heroku or Docker?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Avengers
Awaiting triage
Development

No branches or pull requests

3 participants