got docker to work
This commit is contained in:
parent
cc15911379
commit
d08749a6b4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,6 +3,7 @@ docs/Oscar_Credentials.md
|
||||||
scripts/test_oscarhost.js
|
scripts/test_oscarhost.js
|
||||||
scripts/oscarhost/private/
|
scripts/oscarhost/private/
|
||||||
coverage/
|
coverage/
|
||||||
|
e2e_coverage/
|
||||||
uploads/
|
uploads/
|
||||||
app/e2e_tests/screeshots/*
|
app/e2e_tests/screeshots/*
|
||||||
tmp
|
tmp
|
||||||
|
|
89
Dockerfile
89
Dockerfile
|
@ -10,65 +10,62 @@
|
||||||
FROM ubuntu:latest
|
FROM ubuntu:latest
|
||||||
MAINTAINER David Baldwynn <team@tellform.com>
|
MAINTAINER David Baldwynn <team@tellform.com>
|
||||||
|
|
||||||
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
|
# Install Utilities
|
||||||
RUN apt-get update -q
|
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
|
&& 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 nodejs
|
||||||
|
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
|
||||||
# Install gem sass for grunt-contrib-sass
|
RUN sudo apt-get install -yq nodejs \
|
||||||
RUN apt-get install -y ruby
|
&& apt-get clean \
|
||||||
RUN gem install sass
|
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
# Install NodeJS
|
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
|
|
||||||
RUN sudo apt-get install -yq nodejs
|
|
||||||
|
|
||||||
# Install MEAN.JS Prerequisites
|
# 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/tellform/public/lib
|
||||||
RUN mkdir -p /opt/mean.js/public/lib
|
WORKDIR /opt/tellform
|
||||||
WORKDIR /opt/mean.js
|
|
||||||
|
|
||||||
# Copies the local package.json file to the container
|
# Copies the local package.json file to the container
|
||||||
# and utilities docker container cache to not needing to rebuild
|
# and utilities docker container cache to not needing to rebuild
|
||||||
# and install node_modules/ everytime we build the docker, but only
|
# and install node_modules/ everytime we build the docker, but only
|
||||||
# when the local package.json file changes.
|
# when the local package.json file changes.
|
||||||
# Install npm packages
|
# Add npm package.json
|
||||||
ADD package.json /opt/mean.js/package.json
|
COPY package.json /opt/tellform/package.json
|
||||||
RUN npm install --quiet
|
#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
|
||||||
ADD bower.json /opt/mean.js/bower.json
|
COPY bower.json /opt/tellform/bower.json
|
||||||
ADD .bowerrc /opt/mean.js/.bowerrc
|
COPY .bowerrc /opt/tellform/.bowerrc
|
||||||
RUN bower install --quiet --allow-root --config.interactive=false
|
#RUN bower install --quiet --allow-root --config.interactive=false
|
||||||
|
|
||||||
# Share local directory on the docker container
|
COPY ./app /opt/tellform/app
|
||||||
ADD . /opt/mean.js
|
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
|
||||||
|
|
12
README.md
12
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)
|
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
|
## Testing Your Application
|
||||||
You can run the full test suite included with MEAN.JS with the test task:
|
You can run the full test suite included with MEAN.JS with the test task:
|
||||||
|
|
2
config/env/all.js
vendored
2
config/env/all.js
vendored
|
@ -8,7 +8,7 @@ module.exports = {
|
||||||
keywords: process.env.APP_KEYWORDS || 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs'
|
keywords: process.env.APP_KEYWORDS || 'typeform, pdfs, forms, opensource, formbuilder, google forms, nodejs'
|
||||||
},
|
},
|
||||||
db: {
|
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: {
|
options: {
|
||||||
user: '',
|
user: '',
|
||||||
pass: ''
|
pass: ''
|
||||||
|
|
2
config/env/development.js
vendored
2
config/env/development.js
vendored
|
@ -3,7 +3,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
baseUrl: process.env.BASE_URL || 'http://localhost:5000',
|
baseUrl: process.env.BASE_URL || 'http://localhost:5000',
|
||||||
db: {
|
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: {
|
options: {
|
||||||
user: '',
|
user: '',
|
||||||
pass: ''
|
pass: ''
|
||||||
|
|
|
@ -12,7 +12,7 @@ module.exports = function (app, db) {
|
||||||
|
|
||||||
var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] });
|
var io = socketio(config.socketPort, { transports: ['websocket', 'polling'] });
|
||||||
var redis = require('socket.io-redis');
|
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
|
// Add an event listener to the 'connection' event
|
||||||
io.on('connection', function (socket) {
|
io.on('connection', function (socket) {
|
||||||
|
|
|
@ -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
|
|
|
@ -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"
|
|
|
@ -46,7 +46,6 @@ exports = module.exports = app;
|
||||||
|
|
||||||
// Logging initialization
|
// Logging initialization
|
||||||
console.log('--');
|
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('Environment:\t\t\t' + process.env.NODE_ENV));
|
||||||
console.log(chalk.green('Port:\t\t\t\t' + config.port));
|
console.log(chalk.green('Port:\t\t\t\t' + config.port));
|
||||||
console.log(chalk.green('Database:\t\t\t' + config.db.uri));
|
console.log(chalk.green('Database:\t\t\t' + config.db.uri));
|
||||||
|
|
Loading…
Reference in a new issue