Commit a77b0a73 authored by Killian Kemps's avatar Killian Kemps

Dockerize Qowala

Move Qowala app to child directory because of a COPY command in
Dockerfile.
Update Mongo connection in Qowala app to use Docker Environment
variables.
Qowala app is now accessible under localhost instead of 192.12.34 with
Vagrant.
parent ec444cb5
node_modules/
config/twitter.json
qowala_app/config/twitter.json
.vagrant
*.sublime-project
*.sublime-workspace
......
FROM ubuntu
FROM node:0.12
MAINTAINER Killian Kemps
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | sudo bash -
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 || true
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
RUN mkdir /var/app
COPY qowala_app/package.json var/app/package.json
RUN apt-get update && apt-get install -y \
nodejs \
build-essential \
mongodb-org
RUN cd /var/app && npm install
RUN npm install -g forever
ADD . /home
COPY qowala_app var/app/
WORKDIR /home
WORKDIR /var/app
RUN npm install
EXPOSE 8080
EXPOSE 8080
CMD ["nodejs", "server.js"]
VOLUME ["/home"]
\ No newline at end of file
ADD docker/service-start.sh /
CMD ["/service-start.sh"]
qowala_app:
build: .
ports:
- "80:8080"
links:
- mongo
mongo:
image: mongo
ports:
- "27017:27017"
#!/bin/bash
# WORKDIR
cd /var/app
# Start NodeJS server
#forever -l forever.log -ao stdout.log -e stderr.log start server.js
node server.js
FROM node:0.12
MAINTAINER Killian Kemps
#RUN apt-get update
#RUN apt-get install -y curl
# Install nvm for NodeJS
#RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
#RUN export NVM_DIR="/root/.nvm"
#RUN [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
#
## Install NodeJS v0.12 via nvm
#RUN nvm install v0.12
#RUN nvm use v0.12
RUN mkdir /var/app
# Fails here as it only copies the Dockerfile
COPY * /var/app/
WORKDIR /var/app/
RUN cd /var/app/ && ls
RUN npm install
RUN npm install -g forever
EXPOSE 8080
CMD ["forever", "-l forever.log -ao stdout.log -e stderr.log start server.js"]
FROM ubuntu
MAINTAINER Killian Kemps
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 || true
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
RUN apt-get update && apt-get install -y \
build-essential \
mongodb-org
EXPOSE 27017
CMD ["mongod"]
......@@ -18,17 +18,18 @@ var dbconfig = require('./config/db');
var mongoUri = process.env.MONGODB_ADDON_URI ||
process.env.MONGOLAB_URI ||
process.env.MONGOHQ_URL ||
'mongodb://' + process.env.MONGO_PORT_27017_TCP_ADDR + '/qowala:' + process.env.MONGO_PORT_27017_TCP_PORT ||
dbconfig.url;
mongoose.connect(mongoUri, function(err, dbconfig) {
if(!err) {
console.log("We are connected to mongoDB");
}
else {
console.log('Error while connecting to mongo: ', err);
}
}); // Connect to our mongoDB database (commented out after you enter in your own credentials)
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
// Setup sessions
app.use(session({
secret: 'this1337is42a1337super42secret1337keyword'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment