Skip to content

Instantly share code, notes, and snippets.

@arkokoley
Created January 27, 2018 07:18
Show Gist options
  • Save arkokoley/4867229cc180d49ee25352842cb3cea6 to your computer and use it in GitHub Desktop.
Save arkokoley/4867229cc180d49ee25352842cb3cea6 to your computer and use it in GitHub Desktop.
Docker Deployment files for Rails with Solr
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite
/db/*.sqlite-journal
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
/node_modules
/yarn-error.log
.byebug_history
/public/packs
/public/assets
/public/packs-test
/node_modules
/solr
REDIS_URL=redis://redis:6379/
DB_USERNAME=postgres
DB_PASSWORD=password
RAILS_ENV=production
NODE_ENV=production
SECRET_KEY_BASE=
SMTP_ADDRESS=
SMTP_USERNAME=
SMTP_PASSWORD=
VIRTUAL_HOST=
RAILS_SERVE_STATIC_FILES=true
gem: --no-rdoc --no-ri
version: '3'
services:
web:
build: .
ports:
- "3000:3000"
dns: "8.8.8.8"
volumes:
- ".:/app"
env_file: .env
links:
- db:db
- solr:solr
# In production instead add external_links for db
command: bash -c "bin/rake assets:precompile && bin/rake db:create && bin/rake db:migrate && bin/rails s"
# In production remove this and add an external link in web
db:
image: postgres:latest
environment:
- POSTGRES_PASSWORD=password
volumes:
- ./database:/var/lib/postgresql
solr:
image: solr:7.0.1
ports:
- "8983:8983"
volumes:
- data:/opt/solr/server/solr/mycores
entrypoint:
- docker-entrypoint.sh
- solr-precreate
- mycore
links:
- db:db
volumes:
data: {}
FROM ruby:2.4-alpine
RUN apk --update add --virtual\
build-dependencies build-base libev libev-dev postgresql-dev nodejs bash\
tzdata sqlite-dev git curl
#RUN apt-get update -qq && apt-get install -y build-essential apt-transport-https apt-utils
# for yarn
RUN npm install -g yarn
WORKDIR /app
ADD .gemrc /app
ADD Gemfile /app/
ADD Gemfile.lock /app/
ENV RAILS_ENV=development
ENV NODE_ENV=development
RUN bundle install --jobs 8
ADD package.json /app/
RUN yarn install
ADD . /app
RUN rake db:create && rake db:migrate
EXPOSE 3000
CMD ["bundle", "exec", "rails", "s"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment