From b0d5c392ac9d5867a34a3d9e86e09e50cf190bd2 Mon Sep 17 00:00:00 2001 From: Tamas Kecskes Date: Thu, 26 May 2016 10:22:52 -0500 Subject: [PATCH] Fixed dockerfile so it builds and runs the default configuration (#998) * 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. --- .bowerrc | 3 +- Dockerfile | 91 ++++++++++++++++++++++++---------------------------- package.json | 2 +- 3 files changed, 45 insertions(+), 51 deletions(-) diff --git a/.bowerrc b/.bowerrc index 6b366f8e71..e80c948f23 100644 --- a/.bowerrc +++ b/.bowerrc @@ -1,3 +1,4 @@ { - "directory": "src/client/bower_components" + "directory": "src/client/bower_components", + "allow_root": true } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fa76cb99be..d667aca291 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,73 +1,66 @@ -FROM ubuntu:14.04 -MAINTAINER Zsolt Lattmann - +# 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 # 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"] \ No newline at end of file diff --git a/package.json b/package.json index fb9e17b69d..65acba3f18 100644 --- a/package.json +++ b/package.json @@ -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",