diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..82b4ef4d --- /dev/null +++ b/.dockerignore @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1155f08e --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/bin/start b/bin/start new file mode 100755 index 00000000..93c2bb22 --- /dev/null +++ b/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 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..8d5d9e05 --- /dev/null +++ b/docker-compose.yml @@ -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