Skip to content

The BCDevExchange website is the public facing site for the BC Developers' Exchange - an experiment in tech innovation and collaboration.

License

Notifications You must be signed in to change notification settings

nancymz/BCDevExchange-app

 
 

Repository files navigation

BCDevExchange Organization Web Site

Being designed and built, but in the lab. May change, disappear, or be buggy.

The BCDevExchange website is the public facing site for the BC Developers' Exchange - an experiment in tech innovation and collaboration.

We are open to pull requests! See our contributing guide for the details.

MEAN Stack##

This web app is built on the MEAN stack:

  • AngularJS
  • Bootstrap
  • NodeJS
  • MongoDB
  • nginx

Development

You'll need MongoDB, NodeJS, and Git. Clone this repo from GitHub, change directory to the repo root and:

$ npm install

We use WebStorm for development, but contributors are free to use any editor.

To ensure appropriate license is on every appropriate file, use:

gulp

To automatically update/insert license, use:

gulp --update

Server Deployment

You'll need a Linux server with:

First time setup

Install forever globally using

sudo npm install -g forever

Next, set up the repo

git clone --branch <master or discovery> git://github.com/BCDevExchange/BCDevExchange-app.git
cd BCDevExchange
npm install --production
chmod +x foreverme.sh

You'll want to create a local.json configuration file in /config:

touch config/local.json

Spin up the server using forever:

forever start server.js

By default the server is available at localhost:8000.

Following regular MongoDB installation and create new DBs and user accounts. These names, usernames and passwords must be configured in your /config/local.json

Optional forever configuration

Starting the NodeJS server in forever mode on bootup the rc.local way:

sudo -e /etc/rc.local

then add to the bottom:

sudo -u bitnami /bin/bash /home/bitnami/apps/lab/BCDevExchange-app/foreverme.sh

Stdout, stderr and forever logs are here:

<path to app root>/log/

Following regular nginx installation and feel free to use the sample configs are provided in under /config/nginx

Updating a deployment

Navigate to the app root (e.g. /home/bitnami/apps/lab/BCDevExchange-app/), then

git pull
npm install --production
forever list
forever restart <pid>

Where <pid> is the process ID of the environment you want to restart.

Installing or Upgrading NodeJS via N

First you'll need N installed:

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

Typically, you'll upgrade to latest stable:

sudo n stable

Test you have the right version now:

node -v

Then restart forever processes, post-install:

forever list
forever restart <pid>

Where <pid> is the process ID of the environment you want to restart.

Google Analytics API

This is for setting up access to the Google Analytics API. Those who do not have access to BCDevExchange's Google Analytics account can skip this step. The site will function without Google Analytics set up.

  1. Log into the Google account that has access to BCDevExchange's Google Analytics.

  2. In the Developers Console, create a new project.

  3. Under "APIs & auth", go to "APIs". Search for the "Analytics API" and enable it.

  4. Next go to "Credentials". Create a new Client ID. Make sure to select "Service Account" and for the key type select "P12 Key". This will automatically download a .p12 file to your computer, and the Developers Console will provide you with a password to access it (by default it should be "notasecret").

  5. Make a note of the "Email address" field under your new "Service account". It should look like XXXX@developer.gserviceaccount.com.

  6. The .p12 file needs to be converted to a .pem file. Run the following command where your .p12 file is located:

    openssl pkcs12 -in XXXXX.p12 -nocerts -nodes -out XXXXX.pem
    

    You will be prompted for a password. By default it should be "notasecret".

  7. Add your developer.gserviceaccount.com email to the Google Analytics account with "Read & Analyze" access.

  8. Get the View ID from Google Analytics. This is found in the "Admin" section at the top, under the "View" category in "View Settings".

  9. Lastly the configuration files need to be updated. Update local.json inside /config. An example is provided below:

"google_analytics": {
    "api_email": "your-developer-gservice-email@developer.gserviceaccount.com",
    "analytics_view_id": "your-view-id",
    "key_file": "/path/to/the/pem/file/key.pem"
}

Server Sizing

We've benchmarked performance for this site as it was running on a Microsoft Azure Standard D1 (One Core) 4 GB RAM VM using a [Bitnami packaged Ubuntu VM] (https://bitnami.com/stack/mean).

Static file serving (all Ngnix): 4000 req/sec

Dynamic resource serving (Nginx + NodeJS): 100 req/sec < 500ms

License

     Copyright 2015 Province of British Columbia

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

BCDevExchange Search Tags

BCDevExchange-Project

About

The BCDevExchange website is the public facing site for the BC Developers' Exchange - an experiment in tech innovation and collaboration.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 83.7%
  • HTML 14.9%
  • Other 1.4%