Last active
June 17, 2016 18:50
-
-
Save SwamiRama/0b651c2e66dae829a5cd1240b8e529b9 to your computer and use it in GitHub Desktop.
Rails in Docker
This file contains hidden or 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
docker-compose build | |
docker-compose up | |
docker-compose run app rake db:create | |
docker-compose run app rake db:migrate |
This file contains hidden or 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
default: &default | |
adapter: postgresql | |
pool: 5 | |
timeout: 5000 | |
username: postgres | |
host: db | |
port: 5432 | |
development: | |
<<: *default | |
database: app_development | |
# Warning: The database defined as "test" will be erased and | |
# re-generated from your development database when you run "rake". | |
# Do not set this db to the same as development or production. | |
test: | |
<<: *default | |
database: app_test | |
production: | |
<<: *default | |
database: app |
This file contains hidden or 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
app: | |
build: . | |
command: rails server -p 3000 -b '0.0.0.0' | |
volumes: | |
- .:/app | |
ports: | |
- "3000:3000" | |
links: | |
- db | |
db: | |
image: postgres:9.5 | |
ports: | |
- "5432" |
This file contains hidden or 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
FROM ruby:2.3 | |
MAINTAINER [email protected] | |
# Install apt based dependencies required to run Rails as | |
# well as RubyGems. As the Ruby image itself is based on a | |
# Debian image, we use apt-get to install those. | |
RUN apt-get update && \ | |
apt-get install -y \ | |
build-essential \ | |
nodejs | |
# Configure the main working directory. This is the base | |
# directory used in any further RUN, COPY, and ENTRYPOINT | |
# commands. | |
RUN mkdir -p /app | |
WORKDIR /app | |
# Copy the Gemfile as well as the Gemfile.lock and install | |
# the RubyGems. This is a separate step so the dependencies | |
# will be cached unless changes to one of those two files | |
# are made. | |
COPY Gemfile Gemfile.lock ./ | |
RUN gem install bundler && bundle install --jobs 20 --retry 5 | |
# Copy the main application. | |
COPY . ./ | |
# Expose port 3000 to the Docker host, so we can access it | |
# from the outside. | |
EXPOSE 3000 | |
# Configure an entry point, so we don't need to specify | |
# "bundle exec" for each of our commands. | |
ENTRYPOINT ["bundle", "exec"] | |
# The main command to run when the container starts. Also | |
# tell the Rails dev server to bind to all interfaces by | |
# default. | |
CMD ["rails", "server", "-b", "0.0.0.0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment