From ab126a1275825e57fe814d76924c14bea47b3600 Mon Sep 17 00:00:00 2001 From: Faizaan Madhani Date: Mon, 9 Mar 2020 21:19:13 -0400 Subject: [PATCH] Test --- Dockerfile | 17 +++++++++++++++++ config/initializers/environment.rb | 2 +- docker-compose.yml | 21 +++++++++++++++++++++ entrypoint.sh | 8 ++++++++ heroku.yml | 12 ++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 docker-compose.yml create mode 100644 entrypoint.sh create mode 100644 heroku.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5c06009 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ruby:2.5.1 +RUN apt-get update -qq && apt-get install -y nodejs postgresql-client +RUN mkdir /myapp +WORKDIR /myapp +COPY Gemfile /myapp/Gemfile +COPY Gemfile.lock /myapp/Gemfile.lock +RUN bundle install +COPY . /myapp + +# Add a script to be executed every time the container starts. +COPY entrypoint.sh /usr/bin/ +RUN chmod +x /usr/bin/entrypoint.sh +ENTRYPOINT ["entrypoint.sh"] +EXPOSE 3000 + +# Start the main process. +CMD ["rails", "server", "-b", "0.0.0.0"] \ No newline at end of file diff --git a/config/initializers/environment.rb b/config/initializers/environment.rb index 3224512..121e042 100644 --- a/config/initializers/environment.rb +++ b/config/initializers/environment.rb @@ -7,7 +7,7 @@ ENV['DB_PASS_DEV'] = 'sdcdev' ENV['DB_USER_DEV'] = 'postgres' ENV['DB_NAME_DEV'] = 'sdc' - ENV['DB_HOST_DEV'] = 'localhost' + ENV['DB_HOST_DEV'] = 'db' ENV['DB_PORT_DEV'] = '5432' ENV['DB_TIMEOUT_DEV'] = '5000' ENV['DB_ADAPTER_DEV'] = 'postgresql' diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fcad1a2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3' +services: + db: + image: postgres + volumes: + - ./tmp/db:/var/lib/postgresql/data + environment: + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=sdcdev + - POSTGRES_DB=sdc + ports: + - "5432:5432" + web: + build: . + command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'" + volumes: + - .:/myapp + ports: + - "3000:3000" + depends_on: + - db \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..0721cd7 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# Remove a potentially pre-existing server.pid for Rails. +rm -f /myapp/tmp/pids/server.pid + +# Then exec the container's main process (what's set as CMD in the Dockerfile). +exec "$@" \ No newline at end of file diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 0000000..a14e21a --- /dev/null +++ b/heroku.yml @@ -0,0 +1,12 @@ +build: + docker: + web: Dockerfile + config: + BUNDLE_INSTALL_ARGS: --jobs 10 --retry=3 --without development test + RAILS_ENV: production +run: + web: bundle exec puma -C config/puma.rb + worker: + command: + - bundle exec rake jobs:work + image: web \ No newline at end of file