From 11828c2d2ebf8370cbe9d6357a8fb580fd30bff1 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 26 Jan 2015 20:07:01 -0500 Subject: [PATCH] further docker-ify the container definition and add a boot script --- Dockerfile | 64 +++++++++++++++++++++++++++++------------------------- docker-run | 3 +++ 2 files changed, 37 insertions(+), 30 deletions(-) create mode 100755 docker-run diff --git a/Dockerfile b/Dockerfile index 0ebddeb..d19d5bc 100755 --- a/Dockerfile +++ b/Dockerfile @@ -2,33 +2,24 @@ FROM ubuntu:14.04 MAINTAINER Adam Brown "adamarthurryan@gmail.com" -# add a volume from the current folder -# ADD . /data -EXPOSE 8000 -EXPOSE 9000 -EXPOSE 3000 -EXPOSE 35729 - -# add a user -RUN useradd -ms /bin/bash docker # update package sources -RUN apt-get -y update +# and get some basics +RUN apt-get -y update && apt-get -y install \ + build-essential \ + libssl-dev \ + curl \ + git -# get some basics -RUN apt-get -y install build-essential libssl-dev curl -RUN apt-get install -y git # install mongo db RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list -RUN apt-get update -RUN apt-get install -y mongodb-org - +RUN apt-get update && apt-get install -y \ + mongodb-org # install node.js -RUN apt-get -y install curl RUN curl -sL https://deb.nodesource.com/setup | bash - RUN apt-get install -y nodejs @@ -36,29 +27,42 @@ RUN apt-get install -y nodejs RUN apt-get install -y ruby RUN gem install sass - +# add a user +RUN useradd -ms /bin/bash docker # switch to the docker user ENV HOME /home/docker USER docker -RUN mkdir "${HOME}/.npm-packages" +# configure npm to run without sudo permissions +RUN mkdir $HOME/.npm-packages +RUN echo 'prefix=${HOME}/.npm-packages' >> $HOME/.npmrc -RUN echo 'prefix=${HOME}/.npm-packages' >> ${HOME}/.npmrc +ENV NPM_PACKAGES $HOME/.npm-packages +ENV NODE_PATH $NPM_PACKAGES/lib/node_modules:$NODE_PATH +ENV PATH $NPM_PACKAGES/bin:$PATH +ENV MANPATH $NPM_PACKAGES/share/man:$(manpath) -RUN echo '### Begin NPM config:'>> ${HOME}/.bashrc - -RUN echo 'NPM_PACKAGES="${HOME}/.npm-packages"' >> ${HOME}/.bashrc -RUN echo 'NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"' >> ${HOME}/.bashrc -RUN echo 'PATH="$NPM_PACKAGES/bin:$PATH"' >> ${HOME}/.bashrc -RUN echo 'MANPATH="$NPM_PACKAGES/share/man:$(manpath)"' >> ${HOME}/.bashrc - -RUN echo '### End NPM config:'>> ${HOME}/.bashrc # install yeoman tooling and other npm packages -# !!! this should be done for the docker user? -# !!! should configure npm to install to the user folder? RUN npm install -g node-gyp RUN npm install -g yo bower grunt-cli RUN npm install -g generator-webapp generator-angular generator-angular-fullstack +# setup the mongo path +ENV MONGO_DB $HOME/.mongodb +ENV MONGO_LOG $HOME/.mongodb.log +RUN mkdir $MONGO_DB + +# launch mongo +# RUN mongod --dbpath $MONGO_DB --logpath $MONGO_LOG --fork --journal + + +# add a volume from the current folder +# ADD . /data + +# expose the ports +EXPOSE 8000 +EXPOSE 9000 +EXPOSE 3000 +EXPOSE 35729 diff --git a/docker-run b/docker-run new file mode 100755 index 0000000..af91733 --- /dev/null +++ b/docker-run @@ -0,0 +1,3 @@ +#!/bin/bash + +docker run -v ~/docker/data -p=8000:8000 -p=9000:9000 -p=3000:3000 -p=35729:35729 -it adamarthurryan/mean-dev \ No newline at end of file