# 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]; ```