Skip to content

Commit

Permalink
Fixed dockerfile so it builds and runs the default configuration (#998)
Browse files Browse the repository at this point in the history
* Fixed dockerfile so it builds and runs the default configuration

* Fixed review comments and added usage description.

* Make sure to install git as dependency.
In package.json 'bower install' can be safely used -> will log output.

* Allow bower to be run under root user.
  • Loading branch information
kecso authored and Patrik Meijer committed May 26, 2016
1 parent 56b63a8 commit b0d5c39
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .bowerrc
@@ -1,3 +1,4 @@
{
"directory": "src/client/bower_components"
"directory": "src/client/bower_components",
"allow_root": true
}
91 changes: 42 additions & 49 deletions Dockerfile
@@ -1,73 +1,66 @@
FROM ubuntu:14.04
MAINTAINER Zsolt Lattmann <zsolt.lattmann@gmail.com>

# This dockerfile is intended to build a docker image on a clean copy of the webgme repository.
#
# Use the following steps to build and start-up your dockerized webgme:
# (assuming that you have docker properly installed on your machine)
# 1. go to the directory where this file exists
# 2. docker build -t webgme .
# 3. docker run -d -p 8888:8888 --name=webgme webgme
#
# The result of your last command will be the hash id of your container. After successful startup,
# you should be able to connect to your dockerized webgme on the 8888 port of your docker daemon machine
# (the default ip address of the daemon is 192.168.99.100).
#
# Useful commands
# checking the status of your docker containers: docker ps -a
# restart your docker container: docker restart webgme
# stop your container: docker stop webgme
# removing your container: docker rm webgme
# removing your image: docker rmi webgme



FROM ubuntu:14.04.3
MAINTAINER Tamas Kecskes <tamas.kecskes@vanderbilt.edu>

# Replace shell with bash so we can source files
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

# Set debconf to run non-interactively
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B9316A7BC7917B12 #44A334DA # 87374F5D
# Install base dependencies
RUN apt-get -qq update && apt-get install -y -q --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
curl \
git \
libssl-dev \
python \
rsync \
software-properties-common \
wget \
mongodb-server \
moreutils \
unzip \
&& rm -rf /var/lib/apt/lists/*
# install necessary packages
RUN apt-get -qq update --fix-missing
RUN apt-get install -y -q curl
RUN sudo apt-get install -y -q build-essential libssl-dev mongodb-server git

ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 0.10.38
ENV NODE_VERSION 4.4.4

# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash \
# NVM
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash \
&& source $NVM_DIR/nvm.sh \
&& nvm install $NODE_VERSION \
&& nvm alias default $NODE_VERSION \
&& nvm use default

ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH

ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

RUN mkdir /usr/app

RUN echo smallfiles = true >> /etc/mongodb.conf

RUN mkdir -p /project
ADD package.json /project/package.json
WORKDIR /usr/app

# mount the current project workspace under /project inside the container
ADD . /project
# copy app source
ADD . /usr/app/

VOLUME ["/project"]
WORKDIR /project
# Install app dependencies
RUN npm install --unsafe-perm

RUN npm install
# create startup script
# TODO find a way to execute with different configuraitons
RUN echo '/etc/init.d/mongodb start' >> /root/run.sh &&\
echo 'npm start' >> /root/run.sh

RUN echo '#!/bin/bash -ex' >> /root/run.sh &&\
echo '/etc/init.d/mongodb start' >> /root/run.sh &&\
echo 'npm install' >> /root/run.sh &&\
echo 'npm start' >> /root/run.sh

EXPOSE 8888

CMD ["bash", "-xe", "/root/run.sh"]

# docker build -t webgme .
# docker kill webgme; docker rm webgme
# docker run --rm --name webgme -e 'NODE_VERSION=0.10' -t webgme
# docker run -d -p 0.0.0.0:8888:8888 --name webgme -t webgme
# docker logs -f webgme
# docker ps
# docker exec webgme mongorestore

CMD ["bash", "-xe", "/root/run.sh"]
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -106,7 +106,7 @@
"test_ci": "node ./node_modules/mocha/bin/mocha -R dot --timeout 10000 --recursive test",
"test_cover": "node ./node_modules/istanbul/lib/cli.js --hook-run-in-context cover node_modules/mocha/bin/_mocha -- -R spec --timeout 10000 --recursive test",
"test_browser": "node ./node_modules/karma/bin/karma start karma.conf.js --browsers Firefox --single-run --no-auto-watch",
"postinstall": "node -e \"require('bower').commands.install();\" && node ./utils/postinstall.js -c jsdoc_conf.json",
"postinstall": "bower install && node ./utils/postinstall.js -c jsdoc_conf.json",
"apply": "node ./src/bin/apply.js",
"diff": "node ./src/bin/diff.js",
"export": "node ./src/bin/export.js",
Expand Down

0 comments on commit b0d5c39

Please sign in to comment.