Got vagrant to work

This commit is contained in:
David Baldwynn 2016-12-02 09:35:29 -08:00
parent 19fe40f028
commit 2f5132a70a
10 changed files with 115 additions and 37 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.vagrant
npm-debug.*
docs/Oscar_Credentials.md
scripts/test_oscarhost.js

View File

@ -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 <team@tellform.com>
# 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

68
Dockerfile-production Normal file
View File

@ -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 <team@tellform.com>
# 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"]

View File

@ -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

23
Vagrantfile vendored Normal file
View File

@ -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

View File

@ -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"
}
}
}
}

View File

@ -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']

5
process.yml Normal file
View File

@ -0,0 +1,5 @@
apps:
- script : 'server.js'
name : 'TellForm'
exec_mode: 'cluster'
instances: 4

View File

@ -3,7 +3,7 @@
<div class="container" cg-busy="{promise:updatePromise,templateUrl:'modules/forms/admin/views/directiveViews/cgBusy/update-form-message-TypeB.html',message:'Updating form...', backdrop:false, wrapperClass:'.busy-updating-wrapper'}"></div>
<section class="admin-form">
<!-- Modal Delete Dialog Template -->
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">

View File

@ -1,6 +1,7 @@
<section class="auth sigin-view valign-wrapper" data-ng-controller="AuthenticationController">
<!--<h3 class="col-md-12 text-center">{{ 'SIGNIN_HEADER_TEXT' | translate }}</h3>-->
<!-- <div class="col-md-12 text-center">
<!--
<div class="col-md-12 text-center">
<a href="/auth/facebook" class="undecorated-link">
<img src="/modules/users/img/buttons/facebook.png">
</a>
@ -16,7 +17,8 @@
<a href="/auth/github" class="undecorated-link">
<img src="/modules/users/img/buttons/github.png">
</a>
</div> -->
</div>
-->
<!-- <h3 class="col-md-12 text-center">Or with your account</h3> -->
<div class="row valign">