added Dockerfile and docker-compose.yml

This commit is contained in:
Daniel
2017-11-14 04:33:05 -06:00
parent bd30862a78
commit 3e42182551
4 changed files with 72 additions and 4 deletions

37
Dockerfile Normal file
View File

@@ -0,0 +1,37 @@
# # Select ubuntu as the base image
FROM coreapps/ruby2.3
# Install essential Linux packages
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev postgresql-client nodejs
# Define where our application will live inside the image
ENV RAILS_ROOT /var/www/consul
# Create application home. App server will need the pids dir so just create everything in one shot
RUN mkdir -p $RAILS_ROOT/tmp/pids
# Set our working directory inside the image
WORKDIR $RAILS_ROOT
# Use the Gemfiles as Docker cache markers. Always bundle before copying app src.
# (the src likely changed and we don't want to invalidate Docker's cache too early)
# http://ilikestuffblog.com/2014/01/06/how-to-skip-bundle-install-when-deploying-a-rails-app-to-docker/
COPY Gemfile Gemfile
COPY Gemfile.lock Gemfile.lock
# Prevent bundler warnings; ensure that the bundler version executed is >= that which created Gemfile.lock
RUN gem install bundler
# Finish establishing our Ruby enviornment
RUN bundle install --full-index
# Copy the Rails application into place
COPY . .
# Define the script we want run once the container boots
# Use the "exec" form of CMD so our script shuts down gracefully on SIGTERM (i.e. `docker stop`)
#CMD [ "config/containers/app_cmd.sh" ]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"]

View File

@@ -92,4 +92,5 @@ group :development do
gem 'web-console', '~> 3.3.0'
end
eval_gemfile './Gemfile_custom'
#this is crashing with the Dockerfile
#eval_gemfile './Gemfile_custom'

View File

@@ -1,10 +1,12 @@
default: &default
adapter: postgresql
encoding: unicode
host: localhost
#host: localhost
host: database #<--the name of the db in the docker-compose
pool: 5
username:
password:
port: 5432
username: postgres
password: <%= ENV['POSTGRES_PASSWORD'] %>
development: &development
<<: *default

28
docker-compose.yml Normal file
View File

@@ -0,0 +1,28 @@
# service configuration for our database
database:
# use the preferred version of the official Postgres image
# see https://hub.docker.com/_/postgres/
image: postgres:9.4.5
# persist the database between containers by storing it in a volume
volumes:
- docker-example-postgres:/var/lib/postgresql/data
# service configuration for our dockerized Rails app
app:
# use the Dockerfile next to this file
build: .
# rely on the RAILS_ENV value of the host machine
# environment:
#RAILS_ENV: $RAILS_ENV
# makes the app container aware of the DB container
links:
- database
# expose the port we configured Unicorn to bind to
ports:
- "3000:3000"