Skip to content

Commit

Permalink
Fix heroku deployment and add app.json necessary for review apps (key…
Browse files Browse the repository at this point in the history
…stonejs#941)

* Try a thing

* Try another thing

* Try a thing

* Try again

* Try a thing

* Change thing

* Add app.json

* Try another thing

* Disable preconstruct aliases and babel loader building preconstruct packages when on heroku

* Try running blog

* Fix building next site

* Try a thing

* Revert "Try a thing"

This reverts commit 0eb5c88.

* Revert "Fix building next site"

This reverts commit fabaa4d.

* Revert "Try running blog"

This reverts commit 2ab592a.

* Replace process.env.HEROKU === 'true' with isHerokuEnv constant

* const
  • Loading branch information
emmatown authored Mar 27, 2019
1 parent 7f87ae2 commit fd57de8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 4 deletions.
33 changes: 33 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "keystone-5",
"scripts": {},
"env": {
"CI": {
"required": true
},
"ENABLE_DEV_FEATURES": {
"required": true
},
"MONGODB_URI": {
"required": true
},
"NPM_CONFIG_PRODUCTION": {
"required": true
},
"HEROKU": {
"required": true
}
},
"formation": {
"web": {
"quantity": 1
}
},
"addons": [],
"buildpacks": [
{
"url": "heroku/nodejs"
}
],
"stack": "heroku-18"
}
2 changes: 1 addition & 1 deletion demo-projects/todo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keystone
})
.then(({ server }) => {
server.app.use(server.express.static(path.join(__dirname, 'public')));
return server.start();
return server.start(process.env.MONGODB_URI);
})
.then(({ port }) => {
console.log(`Listening on port ${port}`);
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"prepare": "yarn run --silent contributing-guide",
"contributing-guide": "is-ci && exit 0 || chalk -t \"\n\n{bold 📝 Contributing to KeystoneJS?}\n\nBe sure to build the modules first:\n> {yellow.bold yarn build}\n\" && link '🔗 Read the full Contributing Guide' 'https://github.com/keystonejs/keystone-5/blob/master/CONTRIBUTING.md' && echo \"\n\n\"",
"contributors:add": "all-contributors add",
"contributors:generate": "all-contributors generate"
"contributors:generate": "all-contributors generate",
"heroku-postbuild": "bolt && yarn build"
},
"dependencies": {
"@babel/core": "^7.3.4",
Expand Down
14 changes: 13 additions & 1 deletion packages/admin-ui/server/getWebpackConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const path = require('path');

const { enableDevFeatures, mode } = require('./env');

const isHerokuEnv = process.env.HEROKU === 'true';

module.exports = function({ adminMeta, entry }) {
const templatePlugin = new HtmlWebpackPlugin({
title: 'KeystoneJS',
Expand All @@ -18,7 +20,15 @@ module.exports = function({ adminMeta, entry }) {
const rules = [
{
test: /\.js$/,
exclude: [/node_modules(?!\/@keystone-alpha\/admin-ui)/],
exclude: [
/node_modules(?!\/@keystone-alpha\/admin-ui)/,
// this only affects things while developing in the monorepo
// we do this so we can use less memory on heroku, this uses less memory
// since it doesn't have to compile these things with babel
// note that the preconstruct aliases are also disabled on heroku to enable this
// when we have static builds for the admin ui, we can remove this
...(isHerokuEnv ? [/@keystone-alpha\/field/, /@arch-ui/] : []),
],
use: [
{
loader: 'babel-loader',
Expand Down Expand Up @@ -101,6 +111,8 @@ module.exports = function({ adminMeta, entry }) {
'react-dom$': require.resolve('react-dom'),
...(() => {
try {
// see the comment in the babel-loader exclude option for why this is disabled on heroku
if (isHerokuEnv) return;
return require('preconstruct').aliases.webpack(path.join(__dirname, '..', '..', '..'));
} catch (e) {}
})(),
Expand Down
2 changes: 1 addition & 1 deletion test-projects/basic/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keystone

server.app.use(staticRoute, server.express.static(staticPath));

await server.start();
await server.start(process.env.MONGODB_URI);

// Initialise some data.
// NOTE: This is only for test purposes and should not be used in production
Expand Down

0 comments on commit fd57de8

Please sign in to comment.