add Dockerfile and docker-compose.yml

v2
Josh 5 years ago
parent 8790640fb0
commit 78976f3f51
  1. 23
      .dockerignore
  2. 30
      Dockerfile
  3. 6
      bin/start
  4. 14
      docker-compose.yml

@ -0,0 +1,23 @@
# git
.git
.gitignore
README.md
# Rails
.env
sample.env
*.rbc
capybara-*.html
.rspec
log
tmp
/db/**/*.sqlite3
/db/**/*.sqlite3-journal
/db/production
public/system
public/assets
public/gl
coverage/
spec/tmp
.rvmrc
.byebug_history

@ -0,0 +1,30 @@
FROM ruby:2.5
# Install app dependencies.
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
# Set an environment variable for the install location.
ENV RAILS_ROOT /usr/src/app
# Make the directory and set as working.
RUN mkdir -p $RAILS_ROOT
WORKDIR $RAILS_ROOT
# Set environment variables.
ENV RAILS_ENV production
# Adding project files.
COPY . .
# Install gems.
RUN bundle install --without development test --deployment --clean
# Precompile assets.
RUN bundle exec rake assets:clean
RUN bundle exec rake assets:precompile
# Expose port 3000.
EXPOSE 3000
# Start the application.
CMD ["bin/start"]

@ -0,0 +1,6 @@
#!/bin/bash
bundle exec rake db:create
bundle exec rake db:migrate
exec bundle exec puma -C config/puma.rb

@ -0,0 +1,14 @@
version: '3'
services:
app:
entrypoint: [bin/start]
image: joshblind/greenlight:latest
container_name: greenlight-web
env_file: .env
restart: unless-stopped
ports:
- 6000:3000
volumes:
- ./db/production:/usr/src/app/db/production
- ./log:/usr/src/app/log