1

I'm trying to deploy the Starter Kit of React.js (available here : https://github.com/kriasoft/react-starter-kit) on Openshift. To do that, I modified some little things that I explain here.

First, the logs in Openshift tells me that the import keyword in the servers.js file is not recognized. I think Babel is not used by Openshift at this point.

A workaround for that is mentioned here : How do I modify the node startup command in Open Shift?

So I modified the server.js content (because Openshift run the node server.js command and not the babel-node tools/run start defined in the scripts.start property of package.json) with the recommended content and renamed my base server.js to app.js.

Now, the logs tells me that babel-core is not found so I modified the package.json file to put babel-core and babel-cli in dependencies instead of devDependencies and remove a DEV value of another property.

All the times, when I push my code on Openshift (code of the src folder), the compilation failed at a random time (when dependencies are installed) and it take a long long time. However, when I reboot the cartridge I can see logs I explained.

My current situation is that things are looking better but the problem is the disk space : not enough. That's surprising me because the cartridge can host 1GB and on my local machine all files with dependencies take ~148MB. I tried to delete and recreate the cartridge : the same thing appears.

Does anybody know what can be wrong here ? The fact that the cardridge exceed 1GB is weird...

Thank you all.

Community
  • 1
  • 1
romfret
  • 391
  • 2
  • 11

1 Answers1

0

Here's the solution... I hope it will save hours for some people !

  • Set the "production" mode to the cartridge app (so that in don't download so many inodes) :

    rhc set-env NODE_ENV=production --app appname

  • Don't forget to modify config.js :

    export const port = process.env.OPENSHIFT_NODEJS_PORT || process.env.PORT || 3000; export const host = process.env.OPENSHIFT_NODEJS_IP || 'localhost'; export const databaseUrl = 'sqlite:' + process.env.OPENSHIFT_DATA_DIR + 'database.sqlite';

  • Modify app.js (include the host):

    import { port, host, auth, analytics } from './config'; //... models.sync().catch(err => console.error(err.stack)).then(() => { app.listen(port, host, () => { console.log(`The server is running at http://${host}:${port}/`); });

romfret
  • 391
  • 2
  • 11