merged chanegs

This commit is contained in:
David Baldwynn 2016-04-25 12:47:17 -04:00
commit 1ddf23a848
9 changed files with 265 additions and 242 deletions

View file

@ -13,4 +13,4 @@ ENV NODE_ENV development
# Port 3000 for server # Port 3000 for server
# Port 35729 for livereload # Port 35729 for livereload
EXPOSE 3000 35729 EXPOSE 3000 35729
CMD ["grunt default"] CMD ["grunt"]

View file

@ -55,13 +55,18 @@ $ grunt build
Create your .env file. It should look like this Create your .env file. It should look like this
``` ```
MAILER_EMAIL_ID=example@test.com GOOGLE_ANALYTICS_ID=yourGAID
PRERENDER_TOKEN=yourPrerender.ioToken
COVERALLS_REPO_TOKEN=yourCoveralls.ioToken
MAILER_EMAIL_ID=SMTP_Injection
MAILER_FROM=noreply@yourdomain.com MAILER_FROM=noreply@yourdomain.com
MAILER_PASSWORD=yourmandrillapikey MAILER_PASSWORD=your_sparkpost_apikey
MAILER_SERVICE_PROVIDER=Mandrill MAILER_SERVICE_PROVIDER=SparkPost
BASE_URL=yourdomain.com BASE_URL=yourdomain.com
``` ```
Currenty we are using Raven and Sentry [https://www.getsentry.com](https://www.getsentry.com) for error logging. To use it you must provide a valid private DSN key in your .env file and a public DSN key in app/views/layout.index.html
Create this directory or you will get errors. Create this directory or you will get errors.
``` ```
@ -73,6 +78,7 @@ Edit the 'env' config in gruntfile.js to make sure your .env file is being used.
To run development version: To run development version:
```$ grunt default``` ```$ grunt default```
To run production version: To run production version:
```$ grunt production``` ```$ grunt production```

View file

@ -96,14 +96,14 @@
{% endif %} {% endif %}
<script> <script>
// Raven.config('http://db01e03015ce48e2b68240ea8254b17c@sentry.polydaic.com/1', { Raven.config('http://825fefd6b4ed4a4da199c1b832ca845c@sentry.tellform.com/2', {
// // Raven settings // Raven settings
// }) })
// .setUser({ .setUser({
// "id": "SERVER_RENDERED_ID", "id": "SERVER_RENDERED_ID",
// "email": "SERVER_RENDERED_EMAIL" "email": "SERVER_RENDERED_EMAIL"
// }) })
// .install() .install()
</script> </script>
<!-- [if lt IE 9]> <!-- [if lt IE 9]>
@ -114,7 +114,17 @@
<p><a href="http://browsehappy.com" class="btn btn-primary btn-lg" role="button">Yes, upgrade my browser!</a></p> <p><a href="http://browsehappy.com" class="btn btn-primary btn-lg" role="button">Yes, upgrade my browser!</a></p>
</section> </section>
<![endif] --> <![endif] -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '{{google_analytics_id}}', 'auto');
ga('send', 'pageview');
</script>
</body> </body>
</html> </html>

3
config/env/all.js vendored
View file

@ -2,6 +2,7 @@
module.exports = { module.exports = {
app: { app: {
google_analytics_id: process.env.GOOGLE_ANALYTICS_ID || '',
title: 'TellForm', title: 'TellForm',
description: 'Opensource form builder alternative to TypeForm', description: 'Opensource form builder alternative to TypeForm',
keywords: 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs', keywords: 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs',
@ -18,7 +19,7 @@ module.exports = {
}, },
//Sentry DSN Client Key //Sentry DSN Client Key
DSN: 'http://db01e03015ce48e2b68240ea8254b17c:5d878e9bb6c6488fbb70fb81295ee700@sentry.polydaic.com/1', DSN: process.env.RAVEN_DSN || '',
// The secret should be set to a non-guessable string that // The secret should be set to a non-guessable string that
// is used to compute a session hash // is used to compute a session hash

View file

@ -38,10 +38,10 @@ module.exports = function(db) {
}); });
// Setting application local variables // Setting application local variables
app.locals.google_analytics_id = config.app.google_analytics_id;
app.locals.title = config.app.title; app.locals.title = config.app.title;
app.locals.description = config.app.description; app.locals.description = config.app.description;
app.locals.keywords = config.app.keywords; app.locals.keywords = config.app.keywords;
app.locals.facebookAppId = config.facebook.clientID;
app.locals.bowerJSFiles = config.getBowerJSAssets(); app.locals.bowerJSFiles = config.getBowerJSAssets();
app.locals.bowerCssFiles = config.getBowerCSSAssets(); app.locals.bowerCssFiles = config.getBowerCSSAssets();

View file

@ -3,25 +3,20 @@ version: '2'
services: services:
db: db:
image: mongo:3.2 image: mongo:3.2
command: ['bash', '-c', 'mongod --storageEngine wiredTiger'] #['mongod', '--storageEngine', 'wiredTiger']
volumes: volumes:
- mongo-data-wt:/data/db - mongo-data-wt:/data/db
#- /tmp/etc:/etc
networks:
- back-tier
web: web:
build: build: .
context: .
volumes: volumes:
- .:/usr/src/app - .:/usr/src/app
ports: ports:
- "3000:3000" - "3000:3000"
- "35729:35729" - "35729:35729"
networks: environment:
- back-tier DB_1_PORT_27017_TCP_ADDR: db
PORT: 3000
links:
- db
volumes: volumes:
mongo-data-wt: mongo-data-wt:
driver: local driver: local
networks:
back-tier:
driver: bridge

View file

@ -1,13 +1,10 @@
Installing Sentry Server #Installing Sentry Server
------------------------
TellForm is an opensource *form builder* that can create stunning forms from PDFs or from scratch ### Before You Begin
## Before You Begin
Make sure you understand what sentry server does. You can view documentation for sentry server [here](https://sentry.readthedocs.org/). This document was written for a server running *Ubuntu 14.04 LTS server* (we used Azure). Make sure you understand what sentry server does. You can view documentation for sentry server [here](https://sentry.readthedocs.org/). This document was written for a server running *Ubuntu 14.04 LTS server* (we used Azure).
## Prerequisites ### Prerequisites
Make sure you have these installed: Make sure you have these installed:
* apt-get * apt-get
* python2.7 * python2.7
@ -15,236 +12,238 @@ Make sure you have these installed:
## Installation Steps ### Installation Steps
1. Add non-root user. 1. Add non-root user.
``` ```
sudo adduser sentry sudo adduser sentry
sudo adduser sentry sudo sudo adduser sentry sudo
``` ```
2. Update all apt-get packages 2. Update all apt-get packages
``` ```
sudo apt-get update sudo apt-get update
sudo apt-get dist-upgrade sudo apt-get dist-upgrade
sudo apt-get autoremove sudo apt-get autoremove
sudo apt-get install libxml2-dev libxslt1-dev libffi-dev sudo apt-get install libxml2-dev libxslt1-dev libffi-dev libpq-dev python-dev
sudo reboot sudo reboot
``` ```
3. Install easy_install and pip 3. Install easy_install and pip
``` ```
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
sudo easy_install pip sudo easy_install pip
``` ```
4. Install virtualenv and virtualenvwrapper 4. Install virtualenv and lmxl
``` ```
sudo pip install virtualenv sudo pip install virtualenv
``` sudo pip install lxml
```
5. Install Sentry and Setup 5. Install Sentry and Setup
``` ```
# make server directory # make server directory
mkdir ~/SentryServer; cd ~/SentryServer; mkdir ~/SentryServer; cd ~/SentryServer;
# make virtualenv # make virtualenv
virtualenv ./ virtualenv ./
#activate virtualenv #activate virtualenv
source ./bin/activate source ./bin/activate
# install sentry and its postgresql dependencies # install sentry and its postgresql dependencies
pip install -U sentry[postgres] pip install -U sentry[postgres]
``` ```
6. Install postgresql 6. Install postgresql
``` ```
# install postgres # install postgres
sudo apt-get install postgresql postgresql-contrib libpq-dev sudo apt-get install postgresql postgresql-contrib libpq-dev
# install postgres adminpack # install postgres adminpack
sudo -u postgres psql sudo -u postgres psql
CREATE EXTENSION "adminpack"; CREATE EXTENSION "adminpack";
\q \q
``` ```
7. Setup postgresql DB 7. Setup postgresql DB
``` ```
# change postgres password & create database # change postgres password & create database
sudo passwd postgres sudo passwd postgres
sudo su - postgres sudo su - postgres
psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'changeme';" psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'changeme';"
createdb sentry createdb sentry
createuser sentry_user --pwprompt createuser sentry_user --pwprompt
psql -d template1 -U postgres psql -d template1 -U postgres
GRANT ALL PRIVILEGES ON DATABASE sentry to sentry_user; GRANT ALL PRIVILEGES ON DATABASE sentry to sentry_user;
\q \q
exit exit
``` ```
8. Setup Sentry Configuration 8. Setup Sentry Configuration
``` ```
# initialize conf file # initialize conf file
sentry init sentry init
#edit sentry configuration
vim ~/.sentry/sentry.conf.py
```
#edit sentry configuration The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB)
vim ~/.sentry/sentry.conf.py
``` ```
DATABASES = {
The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB) 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
``` 'NAME': 'sentry',
DATABASES = { 'USER': 'sentry_user',
'default': { 'PASSWORD': 'your_password',
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'HOST': 'localhost',
'NAME': 'sentry', }
'USER': 'sentry_user', }
'PASSWORD': 'your_password', # No trailing slash!
'HOST': 'localhost', SENTRY_URL_PREFIX = 'http://sentry.example.com'
}
} SENTRY_WEB_HOST = '0.0.0.0'
# No trailing slash! SENTRY_WEB_PORT = 9000
SENTRY_URL_PREFIX = 'http://sentry.example.com' SENTRY_WEB_OPTIONS = {
'workers': 3, # the number of gunicorn workers
SENTRY_WEB_HOST = '0.0.0.0' 'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'}, # detect HTTPS mode from X-Forwarded-Proto header
SENTRY_WEB_PORT = 9000 }
SENTRY_WEB_OPTIONS = {
'workers': 3, # the number of gunicorn workers #CONFIGURE REDIS
'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'}, # detect HTTPS mode from X-Forwarded-Proto header SENTRY_REDIS_OPTIONS = {
} 'hosts': {
0: {
#CONFIGURE REDIS 'host': '127.0.0.1',
SENTRY_REDIS_OPTIONS = { 'port': 6379,
'hosts': { 'timeout': 3,
0: { #'password': 'redis auth password'
'host': '127.0.0.1', }
'port': 6379, }
'timeout': 3, }
#'password': 'redis auth password'
} #CONFIGURE OUTGOING MAIL
} EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
} EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
#CONFIGURE OUTGOING MAIL EMAIL_PORT = 587
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_HOST_USER = 'your_gmail_username@gmail.com'
EMAIL_USE_TLS = True EMAIL_HOST_PASSWORD = 'your_gmail_password'
EMAIL_HOST = 'smtp.gmail.com' DEFAULT_FROM_EMAIL = 'testing@testing.com
EMAIL_PORT = 587 ```
EMAIL_HOST_USER = 'your_gmail_username@gmail.com'
EMAIL_HOST_PASSWORD = 'your_gmail_password'
DEFAULT_FROM_EMAIL = 'testing@testing.com
```
9. Setup Database and Start Sentry 9. Setup Database and Start Sentry
``` ```
#install and run redis-server #install and run redis-server
wget http://download.redis.io/releases/redis-stable.tar.gz wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz tar xzf redis-stable.tar.gz
cd redis-stable cd redis-stable
make make
make test make test
sudo make install sudo make install
cd utils cd utils
sudo ./install_server.sh sudo ./install_server.sh
#Go back to app directory #Go back to app directory
cd ~/SentryServer cd ~/SentryServer
sudo service redis_6379 start sudo service redis_6379 start
# set up databse # set up databse
sentry upgrade sentry upgrade
# let's try it out! # let's try it out!
sentry start sentry start
``` ```
10. Install nginx 10. Install nginx
``` ```
# install nginx # install nginx
sudo apt-get install nginx sudo apt-get install nginx
# remove the default symbolic link # remove the default symbolic link
sudo rm /etc/nginx/sites-enabled/default sudo rm /etc/nginx/sites-enabled/default
# create a new blank config, and make a symlink to it # create a new blank config, and make a symlink to it
sudo touch /etc/nginx/sites-available/sentry sudo touch /etc/nginx/sites-available/sentry
cd /etc/nginx/sites-enabled cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/sentry sudo ln -s ../sites-available/sentry
# edit the nginx configuration file # edit the nginx configuration file
sudo vim /etc/nginx/sites-available/sentry sudo vim /etc/nginx/sites-available/sentry
``` ```
*Here are the contents of my nginx file:* *Here are the contents of my nginx file:*
``` ```
server { server {
# listen on port 80 # listen on port 80
listen 80; listen 80;
# for requests to these domains # for requests to these domains
server_name yourdomain.com www.yourdomain.com; server_name yourdomain.com www.yourdomain.com;
# keep logs in these files # keep logs in these files
access_log /var/log/nginx/sentry.access.log; access_log /var/log/nginx/sentry.access.log;
error_log /var/log/nginx/sentry.error.log; error_log /var/log/nginx/sentry.error.log;
# You need this to allow users to upload large files # You need this to allow users to upload large files
# See http://wiki.nginx.org/HttpCoreModule#client_max_body_size # See http://wiki.nginx.org/HttpCoreModule#client_max_body_size
# I'm not sure where it goes, so I put it in twice. It works. # I'm not sure where it goes, so I put it in twice. It works.
client_max_body_size 0; client_max_body_size 0;
location / { location / {
proxy_pass http://localhost:9000; proxy_pass http://localhost:9000;
proxy_redirect off; proxy_redirect off;
proxy_read_timeout 5m; proxy_read_timeout 5m;
# make sure these HTTP headers are set properly # make sure these HTTP headers are set properly
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} }
} }
``` ```
11. Start the worker processes 11. Start the worker processes
``` ```
# restart nginx # restart nginx
sudo service nginx restart sudo nginx -t
sudo service nginx reload
#start sentry
sentry celery worker -B #start sentry
``` sentry celery worker -B
```
12. Install and Configure supervisord 12. Install and Configure supervisord
``` ```
pip install supervisord pip install supervisord
sudo echo_supervisord_conf > ~/SentryServer/etc/supervisord.conf sudo echo_supervisord_conf > ~/SentryServer/etc/supervisord.conf
#Edit yuour supervisord Config
vim /etc/supervisord.conf
```
#Edit yuour supervisord Config Configuration file should look like this
vim /etc/supervisord.conf ```
``` [program:sentry-web]
directory=~/SentryServer/
Configuration file should look like this command=~/SentryServer/bin/sentry start
``` autostart=true
[program:sentry-web] autorestart=true
directory=~/SentryServer/ redirect_stderr=true
command=~/SentryServer/bin/sentry start stdout_logfile=syslog
autostart=true stderr_logfile=syslog
autorestart=true
redirect_stderr=true [program:sentry-worker]
stdout_logfile=syslog directory=~/SentryServer/
stderr_logfile=syslog command=~/SentryServer/bin/sentry celery worker -B
autostart=true
[program:sentry-worker] autorestart=true
directory=~/SentryServer/ redirect_stderr=true
command=~/SentryServer/bin/sentry celery worker -B stdout_logfile=syslog
autostart=true stderr_logfile=syslog
autorestart=true ```
redirect_stderr=true
stdout_logfile=syslog
stderr_logfile=syslog
```
13. Run Server (with supervisord) 13. Run Server (with supervisord)
``` ```
supervisord supervisord
``` ```

View file

@ -10,11 +10,23 @@
"ref" : "origin/master", "ref" : "origin/master",
"repo" : "git@github.com:whitef0x0/tellform.git", "repo" : "git@github.com:whitef0x0/tellform.git",
"path" : "/opt/deploy", "path" : "/opt/deploy",
"post-deploy" : "npm install && bower install --allow-root && pm2 startOrRestart ecosystem.json --env production", "post-deploy" : "npm install && bower install && pm2 startOrRestart ecosystem.json --env production",
"env" : { "env" : {
"NODE_ENV": "production", "NODE_ENV": "production",
"BASE_URL": "stage.tellform.com" "BASE_URL": "stage.tellform.com"
} }
} },
} "prod" : {
"user" : "polydaic",
"host" : "159.203.33.182",
"ref" : "origin/master",
"repo" : "git@github.com:whitef0x0/tellform.git",
"path" : "/opt/deploy",
"post-deploy" : "npm install && bower install && pm2 startOrRestart ecosystem.json --env production",
"env" : {
"NODE_ENV": "production",
"BASE_URL": "admin.tellform.com"
}
}
}
} }

View file

@ -1,7 +1,7 @@
{ {
"name": "TellForm", "name": "TellForm",
"description": "Opensource alternative to TypeForm", "description": "Opensource alternative to TypeForm",
"version": "1.2.1", "version": "1.3.0",
"homepage": "https://github.com/whitef0x0/tellform", "homepage": "https://github.com/whitef0x0/tellform",
"authors": [ "authors": [
"David Baldwynn <polydaic@gmail.com> (http://baldwynn.me)" "David Baldwynn <polydaic@gmail.com> (http://baldwynn.me)"