Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

improve docker images, fix jsep and initial build #344

Merged
merged 5 commits into from Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
data/
dist
.vagrant
npm-debug.*
Expand Down
64 changes: 41 additions & 23 deletions Dockerfile
Expand Up @@ -4,33 +4,16 @@
# Run:
# docker run -it tellform-prod

FROM phusion/baseimage:0.9.19
FROM node:10-alpine
MAINTAINER Arielle Baldwynn <team@tellform.com>

# 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
Expand All @@ -47,13 +30,48 @@ 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
# when the local package.json file changes.
# 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"]
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -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",
Expand Down
9 changes: 8 additions & 1 deletion config/socket.io.js
Expand Up @@ -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');
Expand Down
24 changes: 11 additions & 13 deletions docker-compose.yml
Expand Up @@ -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"
wodka marked this conversation as resolved.
Show resolved Hide resolved
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
Leopere marked this conversation as resolved.
Show resolved Hide resolved
links:
- mongo
- redis
ports:
- "5000:5000"
# - "20523:20523"
depends_on:
- mongo
- redis
Expand All @@ -43,10 +41,10 @@ services:
- "80:80"
Leopere marked this conversation as resolved.
Show resolved Hide resolved
- "443:443"
Leopere marked this conversation as resolved.
Show resolved Hide resolved
- "20523:20523"
env_file:
- .env
volumes:
- "$ROOT/certs:/certs"
environment:
NODE_ENV: development
#volumes:
Leopere marked this conversation as resolved.
Show resolved Hide resolved
# - "$ROOT/certs:/certs"
# - ./nginx/conf.d:/etc/nginx/conf.d
networks:
- back-tier
Expand Down
8 changes: 8 additions & 0 deletions nginx/Dockerfile
Expand Up @@ -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
6 changes: 3 additions & 3 deletions scripts/create_admin.js
Expand Up @@ -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']
});
Expand Down
5 changes: 3 additions & 2 deletions server.js
Expand Up @@ -40,15 +40,16 @@ 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);
}
});

// Init the express application
var app = require('./config/express')(db);

//Create admin account
if (process.env.CREATE_ADMIN_ACCOUNT === 'TRUE') {
if (process.env.CREATE_ADMIN === 'TRUE') {
Leopere marked this conversation as resolved.
Show resolved Hide resolved
var create_admin = require('./scripts/create_admin');

create_admin.run(app, db, function(err){
Expand Down