diff --git a/.gitignore b/.gitignore index aa98f96b..9d2dd270 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vagrant npm-debug.* docs/Oscar_Credentials.md scripts/test_oscarhost.js diff --git a/Dockerfile b/Dockerfile index f00c48eb..2858ac46 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,21 @@ # Build: -# docker build -t meanjs/mean . +# docker build -t tellform -f ./Dockerfile . # # Run: -# docker run -it meanjs/mean -# -# Compose: -# docker-compose up -d - -FROM ubuntu:latest +# docker run -it tellform +FROM phusion/baseimage:0.9.19 MAINTAINER David Baldwynn -# 80 = HTTP, 443 = HTTPS, 3000 = TellForm server, 35729 =livereload, 8080 = node-inspector, 6379 = redis, 27017 = mongo -EXPOSE 80 443 3000 35729 8080 +# 3000 = TellForm server, 35729 = livereload, 8080 = node-inspector +EXPOSE 3000 35729 8080 # Set development environment as default ENV NODE_ENV development +ENV BASE_URL tellform.dev +ENV PORT 3000 # Install Utilities -RUN apt-get update -q \ +RUN apt-get update -q \ && apt-get install -yqq \ curl \ git \ @@ -38,7 +36,7 @@ RUN sudo apt-get install -yq nodejs \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Install MEAN.JS Prerequisites -RUN npm install --quiet -g grunt bower mocha karma-cli pm2 && npm cache clean +RUN npm install --quiet -g grunt bower && npm cache clean RUN mkdir -p /opt/tellform/public/lib WORKDIR /opt/tellform @@ -49,14 +47,12 @@ WORKDIR /opt/tellform # when the local package.json file changes. # Add npm package.json COPY package.json /opt/tellform/package.json -#RUN npm install --quiet && npm cache clean RUN npm install --production RUN mv ./node_modules ./node_modules.tmp && mv ./node_modules.tmp ./node_modules && npm install # Add bower.json COPY bower.json /opt/tellform/bower.json COPY .bowerrc /opt/tellform/.bowerrc -#RUN bower install --quiet --allow-root --config.interactive=false COPY ./app /opt/tellform/app COPY ./public /opt/tellform/public @@ -65,7 +61,5 @@ COPY ./gruntfile.js /opt/tellform/gruntfile.js COPY ./server.js /opt/tellform/server.js COPY ./.env /opt/tellform/.env - - # Run TellForm server CMD npm start diff --git a/Dockerfile-production b/Dockerfile-production new file mode 100644 index 00000000..6aa80ade --- /dev/null +++ b/Dockerfile-production @@ -0,0 +1,68 @@ +# Build: +# docker build -t tellform-prod -f ./Dockerfile-production . +# +# Run: +# docker run -it tellform-prod + +FROM phusion/baseimage:0.9.19 +MAINTAINER David Baldwynn + +# 4545 = TellForm server +EXPOSE 4545 + +# Set development environment as default +ENV NODE_ENV production +ENV PORT 4545 +ENV BASE_URL tellform.com + +# Install Utilities +RUN apt-get update -q \ + && apt-get install -yqq \ + curl \ + git \ + gcc \ + make \ + build-essential \ + libkrb5-dev \ + python \ + sudo \ + apt-utils \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install nodejs +RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - +RUN sudo apt-get install -yq nodejs \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +# Install MEAN.JS Prerequisites +RUN npm install --quiet -g grunt bower pm2 && npm cache clean + +RUN mkdir -p /opt/tellform/public/lib +WORKDIR /opt/tellform + +# Copies the local package.json file to the container +# and utilities docker container cache to not needing to rebuild +# and install node_modules/ everytime we build the docker, but only +# when the local package.json file changes. +# Add npm package.json +COPY package.json /opt/tellform/package.json +RUN npm install --production +RUN mv ./node_modules ./node_modules.tmp && mv ./node_modules.tmp ./node_modules && npm install + +# Add bower.json +COPY bower.json /opt/tellform/bower.json +COPY .bowerrc /opt/tellform/.bowerrc + +COPY ./app /opt/tellform/app +COPY ./public /opt/tellform/public +COPY ./config /opt/tellform/config +COPY ./gruntfile.js /opt/tellform/gruntfile.js +COPY ./server.js /opt/tellform/server.js +COPY ./.env /opt/tellform/.env + +RUN grunt build + +# Run TellForm server +CMD ["pm2-docker","process.yml"] diff --git a/README.md b/README.md index 20086f6b..6c1cc108 100755 --- a/README.md +++ b/README.md @@ -104,10 +104,9 @@ To deploy with docker, first install docker [https://docs.docker.com/engine/inst Then run these commands ``` -$ docker build -t tellform . $ docker run -p 27017:27017 -d --name some-mongo mongo $ docker run -p 6379:6379 -d --name some-redis redis -$ docker run --rm -p 3000:3000 --link some-redis:redis-db --link some-mongo:db tellform +$ docker run --rm -p 3000:3000 --link some-redis:redis-db --link some-mongo:db tellform/development ``` ## Testing Your Application diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..c6489ef7 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,23 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# All Vagrant configuration is done below. The "2" in Vagrant.configure +# configures the configuration version (we support older styles for +# backwards compatibility). Please don't change it unless you know what +# you're doing. +Vagrant.configure("2") do |config| + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://atlas.hashicorp.com/search. + config.vm.box = "ubuntu/trusty64" + config.vm.network :forwarded_port, guest: 3000, host: 4567 + + config.vm.provision "docker" do |d| + d.run "mongo", + args: "-p 27017:27017 -d --name some-mongo" + d.run "redis", + args: "-p 6379:6379 -d --name some-redis" + d.run "tellform/development", + args: "-p 3000:3000 --link some-redis:redis-db --link some-mongo:db" + end +end diff --git a/ecosystem.json b/ecosystem.json index 0970d393..895df5b5 100644 --- a/ecosystem.json +++ b/ecosystem.json @@ -30,18 +30,5 @@ "NODE_ENV": "production", "BASE_URL": "admin.tellform.com" } - }, - "kmc" : { - "user" : "polydaic", - "host" : "159.203.2.71", - "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": "kmc.tellform.com" - } - } } } diff --git a/gruntfile.js b/gruntfile.js index 003f9a0c..8ce70231 100755 --- a/gruntfile.js +++ b/gruntfile.js @@ -7,13 +7,12 @@ module.exports = function(grunt) { // Unified Watch Object var watchFiles = { - serverViews: ['app/views/**/*.*'], serverJS: ['gruntfile.js', 'server.js', 'config/**/*.js', 'app/**/*.js', '!app/tests/'], - clientViews: ['public/modules/**/views/**/*.html', '!public/modules/**/demo/**/*.html', '!public/modules/**/dist/**/*.html', '!public/modules/**/node_modules/**/*.html'], - clientJS: ['public/js/*.js', 'public/form_modules/**/*.js', 'public/modules/**/*.js', '!public/modules/**/gruntfile.js', '!public/modules/**/demo/**/*.js', '!public/modules/**/dist/**/*.js', '!public/modules/**/node_modules/**/*.js'], - clientCSS: ['public/modules/**/*.css', 'public/form_modules/**/*.css', '!public/modules/**/demo/**/*.css', '!public/modules/**/dist/**/*.css', '!public/modules/**/node_modules/**/*.css'], + clientViews: ['public/modules/**/views/**.html'], + clientJS: ['public/js/*.js', 'public/form_modules/**/*.js', 'public/modules/**/*.js'], + clientCSS: ['public/modules/**/*.css', 'public/form_modules/**/*.css', '!public/modules/**/demo/**/*.css', '!public/modules/**/dist/**/*.css'], serverTests: ['app/tests/**/*.js'], clientTests: ['public/modules/**/tests/*.js', '!public/modules/**/demo/**/*.js', '!public/modules/**/dist/**/*.js', '!public/modules/**/node_modules/**/*.js'] diff --git a/process.yml b/process.yml new file mode 100644 index 00000000..e361593c --- /dev/null +++ b/process.yml @@ -0,0 +1,5 @@ +apps: + - script : 'server.js' + name : 'TellForm' + exec_mode: 'cluster' + instances: 4 diff --git a/public/modules/forms/admin/views/admin-form.client.view.html b/public/modules/forms/admin/views/admin-form.client.view.html index b71e405e..a7bb6b4f 100644 --- a/public/modules/forms/admin/views/admin-form.client.view.html +++ b/public/modules/forms/admin/views/admin-form.client.view.html @@ -3,7 +3,7 @@
- +