From 8b2f36fbc50a46422c91671b6b577dfce4f3fe31 Mon Sep 17 00:00:00 2001 From: Julian Date: Wed, 11 Apr 2018 11:24:34 +0630 Subject: [PATCH] Docker Setup --- .code2lab.env | 1 + .dockerignore | 2 ++ Dockerfile | 12 ++++++++++++ config/application.rb | 2 ++ config/puma.rb.production | 5 +++-- docker-compose.yml | 31 +++++++++++++++++++++++++++++++ 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 .code2lab.env create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/.code2lab.env b/.code2lab.env new file mode 100644 index 00000000..0a6c7f0b --- /dev/null +++ b/.code2lab.env @@ -0,0 +1 @@ +RAILS_ENV=production diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6be8c8f3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +.dockerignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..69f0f58e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:2.4.1 +RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs +RUN mkdir /sxrestaurant +RUN mkdir -p /sxrestaurant/tmp/puma +ENV RAILS_ENV production +WORKDIR /sxrestaurant +COPY Gemfile /sxrestaurant/Gemfile +COPY Gemfile.lock /sxrestaurant/Gemfile.lock +RUN bundle install --without development test +RUN bundle exec rails assets:precompile +COPY . /sxrestaurant + diff --git a/config/application.rb b/config/application.rb index 0e75d195..382661d3 100755 --- a/config/application.rb +++ b/config/application.rb @@ -3,6 +3,8 @@ require_relative 'boot' require 'csv' require 'rails/all' # require 'iconv' +require 'openssl' +OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/config/puma.rb.production b/config/puma.rb.production index e88031af..cd3f0829 100755 --- a/config/puma.rb.production +++ b/config/puma.rb.production @@ -1,6 +1,7 @@ -application_path = '/home/superuser/Application/sxrestaurant' +application_path="#{File.expand_path("../..", __FILE__)}" directory application_path -environment ENV.fetch("RAILS_ENV") { "production" } +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" pidfile "#{application_path}/tmp/puma/pid" state_path "#{application_path}/tmp/puma/state" stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..34ee2324 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,31 @@ +version: '3' +services: + code2lab: + build: . + links: + - redis + command: bundle exec puma -C config/puma.rb + volumes: + - .:/sxrestaurant + env_file: + - .code2lab.env + ports: + - '8081:62158' + environment: + - REDIS_URL=redis://redis:6379/0 + sidekiq: + build: . + command: bundle exec sidekiq -C config/sidekiq.yml + links: + - redis + volumes: + - .:/sxrestaurant + environment: + - REDIS_URL=redis://redis:6379/0 + + redis: + image: redis + ports: + - '6379:6379' + volumes: + - ../data/redis:/data