Add 'docker/' from commit '697f105a275dab12b3cc0200a25b067d1f263e8c'

git-subtree-dir: docker
git-subtree-mainline: f27d91a803
git-subtree-split: 697f105a27
This commit is contained in:
Adam Brown 2015-04-17 13:00:37 -04:00
commit 3bf6223c92
7 changed files with 163 additions and 0 deletions

0
docker/.gitignore vendored Executable file
View File

48
docker/Dockerfile Normal file
View File

@ -0,0 +1,48 @@
# start with docker's base ubuntu image
FROM ubuntu:14.04
MAINTAINER Adam Brown "adamarthurryan@gmail.com"
# update package sources
# and get some basics
RUN apt-get -y update && apt-get -y install \
build-essential \
libssl-dev \
curl \
git
# install node.js
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs
# install ruby
RUN apt-get install -y ruby1.9.1 ruby1.9.1-dev
# add a user
# and make them a sudoer
RUN useradd -ms /bin/bash docker && echo "docker:docker" | chpasswd && adduser docker sudo
# switch to the docker user
ENV HOME /home/docker
USER docker
# configure ruby gems to run from the home directory
ENV PATH $PATH:/home/docker/.gem/ruby/1.9.1/bin
# configure npm to run without sudo permissions
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 $PATH:$NPM_PACKAGES/bin
ENV MANPATH $(manpath):$NPM_PACKAGES/share/man
# the home folder is a volume
# we can mount it to a data volume and then it will be shared with all instances
VOLUME /home/docker
# expose the ports
# EXPOSE 8000
# EXPOSE 9000
# EXPOSE 3000
# EXPOSE 35729

22
docker/LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Adam Brown
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

21
docker/README.md Executable file
View File

@ -0,0 +1,21 @@
# docker-mean-dev
A docker container for developing mean stack applications
Usage
======
Build the container with `docker build -t 'adamarthurryan/mean' .`. Install the `mean` and `start-mongodb` to `~/bin` or some other location in the path.
To run commands from the container, use `mean <command>`. For example, to install a new npm package globally:
mean npm install -g generator-polymer
Or to create a yeoman scaffolding in the current folder:
mean yo polymer
Some default npm and gem packages are specified in `default-packages.sh`. They can be installed with:
mean bash default-packages.sh

View File

@ -0,0 +1,16 @@
#!/bin/bash
# default package installations
echo "run this script with 'mean bash default-packages.sh'"
# install some ruby gems
gem install --user-install sass
gem install --user-install compass
# install yeoman tooling and other npm packages
npm install -g node-gyp
npm install -g yo bower grunt-cli
npm install -g generator-webapp generator-angular generator-angular-fullstack generator-polymer

19
docker/mean Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# launch the mean docker container to execute a single command on the working directory
# the working directory will be mounted as /working in the docker container
# test if the data-docker-home container has been created
if docker inspect -f {{.Name}} data-docker-home > /dev/null
then
echo > /dev/null
else
echo "* creating data-docker-home container"
echo
# The data container has a volume at /home/docker, is named 'data' and is based on busybox
docker create -v /home/docker --name data-docker-home adamarthurryan/mean echo "Data container - docker home"
fi
docker run -it --rm --volumes-from=data-docker-home -v ${PWD}:/working -w /working -p 9000:9000 -p 35729:35729 adamarthurryan/mean $@

37
docker/start-mongodb Executable file
View File

@ -0,0 +1,37 @@
#! /bin/bash
# Start a data container and a mongodb instance
echo
# test if the data-db container has been created
if docker inspect -f {{.Name}} data-db
then
echo "* data-db exists"
else
echo "* creating data-db"
# The data container has a volume at /data/db, is named 'data' and is based on mongo
docker create -v /data/db --name data-db mongo echo "Data container - database"
fi
echo
# test if the mongo db server has been created
if docker inspect -f {{.Name}} mongodb
then
# make sure the server is running
if docker inspect -f {{.State.Running}} mongodb
then
echo "* mongodb exists and is running"
else
echo "* starting mongodb"
docker start mongodb
fi
else
echo "* creating new mongodb server"
# Start a mongo db server as a daemon
# The server will use the data-db container as a volume
docker run -p 27017 --name=mongodb --volumes-from=data-db -d mongo
fi