diff --git a/.gitignore b/.gitignore index 31364e09..aa98f96b 100755 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ docs/Oscar_Credentials.md scripts/test_oscarhost.js scripts/oscarhost/private/ coverage/ +e2e_coverage/ uploads/ app/e2e_tests/screeshots/* tmp diff --git a/Dockerfile b/Dockerfile index 0673190a..f00c48eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,68 +7,65 @@ # Compose: # docker-compose up -d -FROM ubuntu:latest +FROM ubuntu:latest MAINTAINER David Baldwynn -WORKDIR ~/Documents/tellform +# 80 = HTTP, 443 = HTTPS, 3000 = TellForm server, 35729 =livereload, 8080 = node-inspector, 6379 = redis, 27017 = mongo +EXPOSE 80 443 3000 35729 8080 + +# Set development environment as default +ENV NODE_ENV development # Install Utilities -RUN apt-get update -q -RUN apt-get install -yqq python wget aptitude htop vim git traceroute dnsutils curl ssh sudo tree tcpdump nano psmisc gcc make build-essential libfreetype6 libfontconfig libkrb5-dev +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/* -ENV python /usr/bin/python - -# Install gem sass for grunt-contrib-sass -RUN apt-get install -y ruby -RUN gem install sass - -# Install NodeJS -RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - -RUN sudo apt-get install -yq nodejs +# 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-cli gulp bower mocha karma-cli pm2 +RUN npm install --quiet -g grunt bower mocha karma-cli pm2 && npm cache clean -RUN mkdir /opt/mean.js -RUN mkdir -p /opt/mean.js/public/lib -WORKDIR /opt/mean.js +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. -# Install npm packages -ADD package.json /opt/mean.js/package.json -RUN npm install --quiet +# 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 -# Install bower packages -ADD bower.json /opt/mean.js/bower.json -ADD .bowerrc /opt/mean.js/.bowerrc -RUN bower install --quiet --allow-root --config.interactive=false +# Add bower.json +COPY bower.json /opt/tellform/bower.json +COPY .bowerrc /opt/tellform/.bowerrc +#RUN bower install --quiet --allow-root --config.interactive=false -# Share local directory on the docker container -ADD . /opt/mean.js +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 -# Machine cleanup -RUN npm cache clean -RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Set development environment as default -ENV NODE_ENV development - -# Ports generic -EXPOSE 80:80 -EXPOSE 443:443 - -# Port 3000 for MEAN.JS server -EXPOSE 3000:3000 - -# Port 5858 for node debug -EXPOSE 5858:5858 - -# Port 35729 for livereload -EXPOSE 35729:35729 - -# Run MEAN.JS server -CMD ["npm", "start"] +# Run TellForm server +CMD npm start diff --git a/README.md b/README.md index d9fb1574..20086f6b 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,18 @@ Set ```NODE_ENV=production``` in .env file Your application should run on port 3000 or the port you specified in your .env file, so in your browser just go to [http://localhost:3000](http://localhost:3000) +##Deploying with Docker + +To deploy with docker, first install docker [https://docs.docker.com/engine/installation/](here). + +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 +``` ## Testing Your Application You can run the full test suite included with MEAN.JS with the test task: diff --git a/config/env/all.js b/config/env/all.js index ee86a2f9..c7f46e1d 100755 --- a/config/env/all.js +++ b/config/env/all.js @@ -8,13 +8,13 @@ module.exports = { keywords: process.env.APP_KEYWORDS || 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs' }, db: { - uri: 'mongodb://'+(process.env.DB_HOST || 'localhost')+'/mean', + uri: 'mongodb://'+ (process.env.DB_PORT_27017_TCP_ADDR || process.env.DB_HOST || 'localhost')+'/mean', options: { user: '', pass: '' } }, - + port: process.env.PORT || 3000, socketPort: process.env.SOCKET_PORT || 20523, diff --git a/config/env/development.js b/config/env/development.js index d95f02fe..dfd42593 100755 --- a/config/env/development.js +++ b/config/env/development.js @@ -3,7 +3,7 @@ module.exports = { baseUrl: process.env.BASE_URL || 'http://localhost:5000', db: { - uri: 'mongodb://'+(process.env.DB_HOST || 'localhost')+'/mean', + uri: 'mongodb://'+( process.env.DB_PORT_27017_TCP_ADDR || process.env.DB_HOST || 'localhost') +'/mean', options: { user: '', pass: '' diff --git a/config/socket.io.js b/config/socket.io.js index d710b712..4ea8a6b1 100644 --- a/config/socket.io.js +++ b/config/socket.io.js @@ -12,7 +12,7 @@ module.exports = function (app, db) { var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] }); var redis = require('socket.io-redis'); - io.adapter(redis(process.env.REDIS_URL || { host: '127.0.0.1', port: 6379 })); + io.adapter(redis( process.env.REDIS_URL || { host: process.env.REDIS_DB_PORT_6379_TCP_ADDR || '127.0.0.1' , port: process.env.REDIS_DB_PORT_6379_TCP_PORT || 6379 })); // Add an event listener to the 'connection' event io.on('connection', function (socket) { diff --git a/docker-compose.override.yml.template b/docker-compose.override.yml.template deleted file mode 100644 index d06dcca6..00000000 --- a/docker-compose.override.yml.template +++ /dev/null @@ -1,9 +0,0 @@ - -version: '2' -services: - web: - environment: - - MAILER_SERVICE_PROVIDER=Gmail - - MAILER_EMAIL_ID=test@example.com - - MAILER_PASSWORD=password - - HOST=http://localhost:3000 diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index e8c8e2f6..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,24 +0,0 @@ -web: - restart: always - build: . - container_name: tellform - command: npm start - links: - - db - ports: - - "3000:3000" - - "5858:5858" - - "35729:35729" - environment: - - NODE_ENV=development - volumes: - - ./:/opt/mean.js - - /opt/mean.js/node_modules - - /opt/mean.js/public - - /opt/mean.js/uploads -db: - image: mongo:3.2 - container_name: db_1 - restart: always - ports: - - "27017:27017" diff --git a/server.js b/server.js index 526c6c7c..ceabf3d0 100755 --- a/server.js +++ b/server.js @@ -46,7 +46,6 @@ exports = module.exports = app; // Logging initialization console.log('--'); -console.log(chalk.green(config.app.title + ' application started')); console.log(chalk.green('Environment:\t\t\t' + process.env.NODE_ENV)); console.log(chalk.green('Port:\t\t\t\t' + config.port)); console.log(chalk.green('Database:\t\t\t' + config.db.uri));