diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6a0ecbf..0000000 --- a/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM ruby:2.2.2 - -RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential -RUN apt-get install -y nodejs sqlite3 - -ENV APP_HOME /wrestlingApp -ENV PORT 3000 - -RUN mkdir $APP_HOME - -WORKDIR $APP_HOME - -ADD Gemfile* $APP_HOME/ -RUN bundle install - -ADD . $APP_HOME - -RUN rake db:drop -RUN rake db:migrate RAILS_ENV=test -RUN rake db:migrate RAILS_ENV=development -RUN rake db:seed -RUN rake assets:precompile -RUN rake test - -#CMD rails s puma --binding 0.0.0.0 -CMD bundle exec passenger start -p $PORT --max-pool-size 3 - -EXPOSE 3000 diff --git a/README.rdoc b/README.rdoc index 1650aea..c97e22a 100644 --- a/README.rdoc +++ b/README.rdoc @@ -22,11 +22,9 @@ Development details: Docker instructions: -* Building the image docker build -t wrestling . +* Building and run the image: bash rails-dev.sh wrestlingapp This will mount your local directory to /rails inside the container and will open port 3000 to port 3000 on your local machine. -* Running the image (as development) docker run -it --rm -p 3000:3000 wrestling - -* Developing in docker by mapping your work directory docker run -it -p 3000:3000 -v /Your/path/to/wrestlingApp:/wrestlingApp --rm wrestling /bin/bash +* After running the above script, you'll be presented a shell. You'll need to run bash rails-dev-db.sh to set up the development db's. After those are set up, you can run rake test to run the tests or rails s -b 0.0.0.0 to run a development server. You can also run any other rails commands from here. What the app does now: diff --git a/rails-dev-Dockerfile b/rails-dev-Dockerfile new file mode 100644 index 0000000..27ffff9 --- /dev/null +++ b/rails-dev-Dockerfile @@ -0,0 +1,20 @@ +FROM ruby:2.2.3 + +RUN apt-get update +RUN apt-get -y upgrade + +RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential +RUN apt-get install -y nodejs sqlite3 + +RUN gem install --no-rdoc --no-ri bundler +RUN mkdir /rails +WORKDIR /rails +VOLUME ["/rails"] + +ADD Gemfile* /rails/ +RUN bundle install --without production +ADD . /rails/ + +EXPOSE 3000 + +CMD /bin/bash diff --git a/rails-dev-db.sh b/rails-dev-db.sh new file mode 100755 index 0000000..7b59204 --- /dev/null +++ b/rails-dev-db.sh @@ -0,0 +1,2 @@ +rake db:setup +rake db:migrate RAILS_ENV=test diff --git a/rails-dev.sh b/rails-dev.sh new file mode 100755 index 0000000..03ed3f9 --- /dev/null +++ b/rails-dev.sh @@ -0,0 +1,11 @@ +#!/bin/bash -e + +if [ $# != 1 ]; then + echo "Please enter docker image name for the rails development environment" + exit 1 +fi + +APPPATH="$(pwd)" + +docker build -t $1 -f rails-dev-Dockerfile . +docker run -it -p 3000:3000 -v ${APPPATH}:/rails $1 /bin/bash \ No newline at end of file