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.
This web app is built on the MEAN stack:
- AngularJS
- Bootstrap
- NodeJS
- MongoDB
- nginx
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
You'll need a Linux server with:
- nginx
- NodeJS via N Use version 0.12.x
- MongoDB
- Bind as a local DNS cache
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
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
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.
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.
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.
-
Log into the Google account that has access to BCDevExchange's Google Analytics.
-
In the Developers Console, create a new project.
-
Under "APIs & auth", go to "APIs". Search for the "Analytics API" and enable it.
-
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
.p12file to your computer, and the Developers Console will provide you with a password to access it (by default it should be "notasecret"). -
Make a note of the "Email address" field under your new "Service account". It should look like
XXXX@developer.gserviceaccount.com. -
The
.p12file needs to be converted to a.pemfile. Run the following command where your.p12file is located:openssl pkcs12 -in XXXXX.p12 -nocerts -nodes -out XXXXX.pemYou will be prompted for a password. By default it should be "notasecret".
-
Add your
developer.gserviceaccount.comemail to the Google Analytics account with "Read & Analyze" access. -
Get the View ID from Google Analytics. This is found in the "Admin" section at the top, under the "View" category in "View Settings".
-
Lastly the configuration files need to be updated. Update
local.jsoninside/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"
}
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
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-Project