README.md 1.81 KB
Newer Older
nabil el mahiri committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
# One code base multiple apps


# Install

```
    cd [your-workspace]

    # clone pine-server
    git clone git@labs.fractalite.com:pine/pine-server.git
    cd pine-server
    npm install

    # clone an app
    cd apps
    git clone git@labs.fractalite.com:webapps/atlas-incoming.git

    # continue if app has html ui
    
    # install theme
    cd [your-workspace]/pine-server
    npm install $theme-name

    # copy browser scripts from modules to apps/atlasincoming
    # copy css from theme to apps/atlasincoming/public
    # copy img from theme to apps/atlasincoming/public
    cd <your-workspace>/pine-server
    grunt pine --app atlasincoming

```


# Create an app

```
    cd [your-workspace]/pine-server/apps
    mkdir yourapp
    mkdir yourapp/etc
    touch yourapp/etc/conf.json
    touch yourapp/etc/conf.dev.json
    touch yourapp/etc/conf.stage.json
    touch yourapp/etc/conf.prod.json
    mkdir yourapp/etc/nginx
    mkdir yourapp/public
    touch yourapp/robots.txt

```
## add nginx config

### 1. Copy sample conf

```
    cd [your-workspace]/pine-server
    cp etc/nginx.sample.conf apps/yourapp/etc/nginx/nginx.dev.conf

```

### 2. Edit

```
    vim apps/yourapp/etc/nginx/nginx.dev.conf
```

change $public var to:

```
    set $public _your-workspace_/pine-server/apps/yourapp/public;
```

change upstream name and port (the same as in conf.json#http.port)
when binding express to a unix socket use nginx's unix:path/to/socket syntax
    
```
    upstream node_[yourappname] {
       server 127.0.0.1:[express-port];
    }  
```

change the vhost port (the port nginx will listen on, must be different from upstream port)

```
  server {
    listen   [port];
    server_name  localhost;
```

change the proxy_pass under ``location /`` so as it points to you upstream
        
```
  proxy_pass http://node_[yourappname];
```