Created
August 4, 2016 20:16
-
-
Save evbruno/a07fc80785222179b1a2cb69bda63ea5 to your computer and use it in GitHub Desktop.
Dockerfile derived from official PostgreSQL with rvm/ruby/rails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Container based on official postgres v9.5.3, with: | |
# * rvm | |
# * ruby 2.2.3 | |
# * rails 4.2.3 | |
### | |
FROM postgres:9.5.3 | |
RUN apt-get update && apt-get install -y curl git libpq-dev | |
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
RUN /bin/bash -l -c "curl -sSL https://get.rvm.io | bash -s stable" | |
RUN /bin/bash -l -c "rvm install 2.2.3" | |
RUN /bin/bash -l -c "rvm use 2.2.3 --default" | |
RUN /bin/bash -l -c "ruby -v" | |
RUN /bin/bash -l -c "gem install bundler" | |
RUN /bin/bash -l -c "gem install rails -v 4.2.3" | |
RUN echo 'source /etc/profile.d/rvm.sh' >> ~/.bashrc | |
### Building: | |
# $ docker build -t pg-rails . | |
### | |
### Running in foreground: | |
# $ docker run --rm -P -p 3000:3000 -p 5432:5432 -v "$(pwd):/webapp" --name pg-rails-test pg-rails | |
# options: | |
# --rm will remove the container when the process ends | |
# -p X:Y forward the port X from container, to Y on host | |
# -v X:Y share (mount) the X folder from host, on Y folder on container | |
# | |
# Running in background: | |
# $ docker run -P -p 3000:3000 -p 5432:5432 -v "$(pwd):/webapp" -d --name pg-rails-test pg-rails | |
# | |
# go to the running container (other shell): | |
# $ docker exec -i -t pg-rails-test '/bin/bash' | |
# (root @ container) | |
# $ cd /webapp | |
# $ rails s -b 0.0.0.0 | |
# | |
# If you are using the gem webconsole to debug, configure your application as described here: | |
# https://github.com/rails/web-console#configweb_consolewhitelisted_ips | |
### | |
### Helpers: | |
# Remove all containers: | |
# $ docker rm $(docker ps -qa) | |
# Remove all untagged images: | |
# $ docker rmi -f $(docker images | grep '^<none>' | awk '{print $3}') | |
### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment