add Dockerfile and docker-compose.yml

This commit is contained in:
Josh 2018-06-20 15:24:39 -04:00
parent 8790640fb0
commit 78976f3f51
4 changed files with 73 additions and 0 deletions

23
.dockerignore Normal file
View File

@ -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

30
Dockerfile Normal file
View File

@ -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"]

6
bin/start Executable file
View File

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

14
docker-compose.yml Normal file
View File

@ -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