diff --git a/.gitignore b/.gitignore index 01fc19d8..c1152952 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +data/ dist .vagrant npm-debug.* diff --git a/Dockerfile b/Dockerfile index 97e1855d..4c957018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,33 +4,16 @@ # Run: # docker run -it tellform-prod -FROM phusion/baseimage:0.9.19 +FROM node:10-alpine MAINTAINER Arielle Baldwynn -# Install Utilities -RUN apt-get update -q \ - && apt-get install -yqq \ - curl \ - ant \ - 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 some needed packages +RUN apk add --no-cache \ + git \ + && rm -rf /tmp/* # Install NPM Global Libraries -RUN npm install --quiet -g grunt bower pm2 && npm cache clean +RUN npm install --quiet -g grunt bower pm2 && npm cache clean --force WORKDIR /opt/tellform RUN mkdir -p /opt/tellform/public/lib @@ -47,6 +30,39 @@ COPY ./gruntfile.js /opt/tellform/gruntfile.js COPY ./server.js /opt/tellform/server.js COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js +# Set default ENV +ENV NODE_ENV=development +ENV SECRET_KEY=ChangeMeChangeMe +#ENV MONGODB_URI=mongodb://mongo/tellform +#ENV REDIS_URL=redis://redis:6379 +ENV PORT=5000 +ENV BASE_URL=localhost +ENV SOCKET_PORT=20523 +ENV SIGNUP_DISABLED=FALSE +ENV SUBDOMAINS_DISABLED=FALSE +ENV ENABLE_CLUSTER_MODE=FALSE +ENV MAILER_EMAIL_ID=tellform@localhost +ENV MAILER_PASSWORD= +ENV MAILER_FROM=tellform@localhost +ENV MAILER_SERVICE_PROVIDER= +ENV MAILER_SMTP_HOST= +ENV MAILER_SMTP_PORT= +ENV MAILER_SMTP_SECURE= + +ENV CREATE_ADMIN=FALSE +ENV ADMIN_EMAIL=admin@tellform.com +ENV ADMIN_USERNAME=root +ENV ADMIN_PASSWORD=root + +ENV APP_NAME=Tellform +ENV APP_KEYWORDS= +ENV APP_DESC= + +# optional ENV settings +ENV COVERALLS_REPO_TOKEN= +ENV GOOGLE_ANALYTICS_ID= +ENV RAVEN_DSN= + # 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 @@ -54,6 +70,8 @@ COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js # Add npm package.json COPY ./package.json /opt/tellform/package.json RUN npm install --only=production --quiet +RUN bower install --allow-root +RUN grunt build # Run TellForm server CMD ["node", "server.js"] diff --git a/bower.json b/bower.json index afdaec71..d351e104 100755 --- a/bower.json +++ b/bower.json @@ -37,7 +37,7 @@ "angular-translate": "~2.11.0", "ng-translate": "*", "deep-diff": "^0.3.4", - "jsep": "^0.3.1", + "jsep": "0.3.1", "ngclipboard": "^1.1.1", "mobile-detect": "^1.3.3", "socket.io-client": "^1.7.2", diff --git a/config/socket.io.js b/config/socket.io.js index 9500d538..7ae1d99e 100644 --- a/config/socket.io.js +++ b/config/socket.io.js @@ -9,7 +9,14 @@ var config = require('./config'), // Define the Socket.io configuration method module.exports = function (app, db) { var server = http.createServer(app); - var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] }); + var io; + + // make it possible to only expose one domain + if (process.env.SOCKET_PORT != process.env.PORT) { + io = socketio(config.socketPort, { transports: ['websocket', 'polling'] }); + } else { + io = socketio(server, { transports: ['websocket', 'polling'] }); + } if(config.enableClusterMode){ var redis = require('socket.io-redis'); diff --git a/docker-compose.yml b/docker-compose.yml index f51c2573..4b619de0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,31 +3,29 @@ services: redis: restart: always image: redis - volumes: - - "${PWD}/.env:/opt/tellform/.env" networks: - back-tier mongo: restart: always image: mongo volumes: - - "$ROOT/mongo:/data" + - ".data/mongo:/data" networks: - back-tier tellform: build: context: . - env_file: - - .env - volumes: - # - "${PWD}/.env:/opt/tellform/.env" - - .:/opt/tellform + environment: + CREATE_ADMIN: "TRUE" + MONGODB_URI: mongodb://mongo/tellform + REDIS_URL: redis://redis +# volumes: +# - .:/opt/tellform links: - mongo - redis ports: - "5000:5000" - # - "20523:20523" depends_on: - mongo - redis @@ -43,10 +41,10 @@ services: - "80:80" - "443:443" - "20523:20523" - env_file: - - .env - volumes: - - "$ROOT/certs:/certs" + environment: + NODE_ENV: development + #volumes: + # - "$ROOT/certs:/certs" # - ./nginx/conf.d:/etc/nginx/conf.d networks: - back-tier diff --git a/nginx/Dockerfile b/nginx/Dockerfile index 3184ee05..3959a099 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -8,4 +8,12 @@ RUN chmod +x /start.py RUN chmod +x /letsencrypt.py RUN chmod +x /config.py +ENV NODE_ENV=development +ENV PORT=5000 +ENV SOCKET_PORT=20523 +ENV TLS_FLAVOR=notls +ENV BASE_URL=localhost +ENV SUBDOMAIN_URL=*.localhost +ENV SOCKETS_URL=ws.localhost + CMD /start.py diff --git a/scripts/create_admin.js b/scripts/create_admin.js index 6d5ee5c6..b676f92e 100644 --- a/scripts/create_admin.js +++ b/scripts/create_admin.js @@ -5,14 +5,14 @@ var config = require('../config/config'), exports.run = function(app, db, cb) { var User = mongoose.model('User'); - var email = 'admin@admin.com' || config.admin.email; + var email = config.admin.email || 'admin@admin.com'; var newUser = new User({ firstName: 'Admin', lastName: 'Account', email: email, - username: 'root' || config.admin.username, - password: 'root' || config.admin.password, + username: config.admin.username || 'root', + password: config.admin.password || 'root', provider: 'local', roles: ['admin', 'user'] }); diff --git a/server.js b/server.js index 78aeefa6..276531b5 100755 --- a/server.js +++ b/server.js @@ -40,7 +40,8 @@ const smtpTransport = nodemailer.createTransport(config.mailer.options); smtpTransport.verify(function(error, success) { if (error) { console.error(chalk.red('Your mail configuration is incorrect: ' + error)); - process.exit(-1); + // verify but to abort! + // process.exit(-1); } }); @@ -48,7 +49,7 @@ smtpTransport.verify(function(error, success) { var app = require('./config/express')(db); //Create admin account -if (process.env.CREATE_ADMIN_ACCOUNT === 'TRUE') { +if (process.env.CREATE_ADMIN === 'TRUE') { var create_admin = require('./scripts/create_admin'); create_admin.run(app, db, function(err){