Skip to content

Commit

Permalink
Merge branch 'release/v0.4.1-preview5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdaan committed Feb 25, 2016
2 parents c4c1b9e + 9b07dc8 commit 359584d
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 6 deletions.
11 changes: 10 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@
"plugins": [
"transform-runtime",
"transform-decorators-legacy"
]
],
"env": {
"production": {
"plugins": [
"transform-react-remove-prop-types",
"transform-react-constant-elements",
"transform-react-inline-elements"
]
}
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Packages:
* [Generate component](./docs/generate-component.md)
* [React-router howto](./docs/react-router-howto.md)
* [How to create CRUD](./docs/crud.md)
* [Configure and setup own server](./docs/local-server.md)

## Dependency docs

Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* [Generate component](./generate-component.md)
* [React-router howto](./react-router-howto.md)
* [How to create CRUD](./crud.md)
* [Configure and setup own server](./docs/local-server.md)

### Dependency

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $ npm run build
or, for a production build:

```shell
$ npm run build -- --release
$ BABEL_ENV=production npm run build -- --release
```

After running this command, the `/build` folder will contain the compiled
Expand Down
119 changes: 119 additions & 0 deletions docs/local-server.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
## Setup own server, without Docker and cloud-based solutions

This approach is relevant if you want to:

* speed up your dev-computer
* deploy application on a dedicated server (or vps)
* run app in corporate network

General scheme will looks like:
```
+------+ +------------+ +----------------+
| user +---> | web server +----> | express server |
+------+ +------------+ +----------------+
```

First you need pre-installed and configured linux/nix system (not windows/osx).
I will consider the example of ubuntu-server.

Install nvm (node version manager):

```
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
```

Then install Node.js 5.x, and setup default node version:
```
$ nvm install 5.4
$ nvm alias default 5.4
```

Then you need process manager for Node.js app server. This may be one of the:

* [pm2](https://github.com/Unitech/pm2)
* [forever](https://github.com/foreverjs/forever)
* other managers...

I chose `pm2`:
```
$ npm install pm2 -g
```

Next you need build you app and upload on server, for example to `/var/www/myapp`
(better to use git hooks or npm task for this).

```
$ BABEL_ENV=production npm run build -- --release && rsync . [email protected]:/var/www/myapp
```

If you app successfully loaded, configure you process manager and start application:

```shell
web@server:/var/www/myapp# NODE_ENV=production PORT=5000 NAME=awesomeapp.com pm2 add --name "my-awesome-app" ./build/server.js

┌─────────────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
├─────────────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤
│ my-awesome-app │ 1 │ fork │ 777 │ online │ 0 │ 0m │ 7 MB │ disabled │
└─────────────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘

```

Please note that we have specified `NODE_ENV=production` and other environment
variables (NAME and PORT).

Next you need web server, such as:

* nginx
* apache2
* lighttpd
* other web-servers..

Once you have installed the server, you will need to configure it.

Basic apache2 (with mod_proxy) configuration could look like this:
```
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName awesomeapp.com
ServerAlias www.awesomeapp.com
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://127.0.0.1:5000/
ProxyPassReverse http://127.0.0.1:5000/
</Location>
</VirtualHost>
```

Basic nginx configuration:
```
upstream nodeserver {
server 127.0.0.1:5000;
}
server {
listen 0.0.0.0:80;
server_name awesomeapp.com;
access_log /var/log/nginx/awesomeapp.com.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://nodeserver/;
proxy_redirect off;
}
}
```

Setup and reload web server - now your application server is ready.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"dependencies": {
"alt": "^0.18.1",
"axios": "^0.9.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-polyfill": "^6.5.0",
"babel-runtime": "^6.5.0",
"bluebird": "3.3.1",
Expand Down Expand Up @@ -43,6 +42,10 @@
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.3",
"babel-plugin-react-transform": "^2.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-react-constant-elements": "^6.5.0",
"babel-plugin-transform-react-inline-elements": "^6.5.0",
"babel-plugin-transform-react-remove-prop-types": "^0.2.2",
"babel-plugin-transform-runtime": "^6.5.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
Expand All @@ -66,8 +69,8 @@
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"postcss": "^5.0.16",
"postcss-import": "^8.0.2",
"postcss-custom-media": "^5.0.0",
"postcss-import": "^8.0.2",
"postcss-loader": "^0.8.1",
"precss": "^1.4.0",
"raw-loader": "^0.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/PrivatePage/PrivatePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class PrivatePage extends Component {

return (
<div className={s.root}>
<h1>This is example of prtected page</h1>
<h1>This is example of protected page</h1>
<p>You profile info:</p>
<table>
<tbody>
Expand Down
2 changes: 1 addition & 1 deletion tools/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const clientConfig = extend(true, {}, config, {
output: {
path: path.join(__dirname, '../build/public'),

publicPath: DEBUG ? 'http://localhost:5000/' : '/',
publicPath: DEBUG ? 'http://localhost:3000/' : '/',

filename: DEBUG ? '[name].js?[hash]' : '[name].[hash].js',
},
Expand Down

0 comments on commit 359584d

Please sign in to comment.