Skip to content

Commit

Permalink
Fixes #16074 - Adds BIND variable to startup process
Browse files Browse the repository at this point in the history
Instead of binding to 0.0.0.0 we default to localhost
and use ENV variable BIND to override.
This also introduces '.env' files which helps to set
other ENV variables
  • Loading branch information
shlomizadok authored and domcleal committed Sep 14, 2016
1 parent 698e916 commit 3b10c2a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# node_modules is ignored by default
app/**
vendor/**
config/webpack.config.js
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ config/hooks
.envrc
node_modules
public/webpack
.env*
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Run Rails & Webpack concurrently
# If you wish to use a different server then the default, use e.g. `export RAILS_STARTUP='puma -w 3 -p 3000 --preload'`
rails: [ -n "$RAILS_STARTUP" ] && $RAILS_STARTUP || bin/rails server -b 0.0.0.0
rails: [ -n "$RAILS_STARTUP" ] && $RAILS_STARTUP || [ -n "$BIND" ] && bin/rails server -b $BIND || bin/rails server
# you can use WEBPACK_OPTS to customize webpack server, e.g. 'WEBPACK_OPTS='--https --key /path/to/key --cert /path/to/cert.pem --cacert /path/to/cacert.pem' foreman start '
webpack: ./node_modules/.bin/webpack-dev-server --config config/webpack.config.js $WEBPACK_OPTS
3 changes: 2 additions & 1 deletion config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ var devServerPort = 3808;

// set TARGETNODE_ENV=production on the environment to add asset fingerprints
var production = process.env.RAILS_ENV === 'production' || process.env.NODE_ENV === 'production';
var bindOn = process.env.BIND || '127.0.0.1';

var config = {
entry: {
Expand Down Expand Up @@ -91,7 +92,7 @@ if (production) {
);
} else {
config.devServer = {
host: '0.0.0.0',
host: bindOn,
port: devServerPort,
headers: { 'Access-Control-Allow-Origin': '*' }
};
Expand Down

0 comments on commit 3b10c2a

Please sign in to comment.