Browse Source

Dockerization

master
aeris 4 years ago
parent
commit
ce09988973
  1. 6
      .dockerignore
  2. 22
      Dockerfile
  3. 4
      Gemfile
  4. 12
      config/puma.rb
  5. 32
      docker-compose.yml

6
.dockerignore

@ -0,0 +1,6 @@
Dockerfile
.git/*
.bundle/*
db/*.sqlite
log/*
tmp/*

22
Dockerfile

@ -0,0 +1,22 @@
FROM aeris/cryptcheck AS builder
MAINTAINER aeris <aeris@imirhil.fr>
RUN apk add --update make gcc g++ libxml2-dev yaml-dev zlib-dev nodejs
WORKDIR /cryptcheck-rails/
COPY . /cryptcheck-rails/
RUN sed -i "/'therubyracer'/d" Gemfile && \
sed -i "/^ therubyracer$/d" Gemfile.lock && \
bundle config --local local.cryptcheck ../cryptcheck && \
bundle install --deployment --without test development && \
RAILS_ENV=assets bundle exec rails assets:precompile && \
rm -rf vendor/bundle && \
RAILS_ENV=production bundle install --deployment --without test development
FROM aeris/cryptcheck AS frontend
MAINTAINER aeris <aeris@imirhil.fr>
ENV RAILS_ENV=production
WORKDIR /cryptcheck-rails/
COPY --from=builder /cryptcheck-rails/ /cryptcheck-rails/

4
Gemfile

@ -2,7 +2,7 @@ source 'https://rubygems.org'
gem 'rails'
gem 'cryptcheck', '~> 2.0.0', path: File.expand_path(File.join File.dirname(__FILE__), '../cryptcheck')
gem 'cryptcheck', '~> 2.0.0', path: '../cryptcheck'
gem 'dotenv-rails'
gem 'http_accept_language'
@ -22,6 +22,7 @@ group :assets do
gem 'font-awesome-sass'
gem 'jquery-rails'
gem 'sass-rails'
gem 'tzinfo-data'
end
group :development, :test do
@ -38,4 +39,3 @@ group :development, :test do
gem 'rack-livereload'
gem 'guard-rails', require: false
end

12
config/puma.rb

@ -14,15 +14,17 @@ unless Rails.root
end
end
if env == 'production'
workers 4
workers 4 if env == 'production'
port = ENV['PORT']
if port
port(port)
else
listen = ENV.fetch('LISTEN') { 'unix://' + File.join(Rails.root, 'tmp/sockets/puma.sock') }
bind listen
else
listen = ENV.fetch('PORT') { 3001 }
port listen
end
pidfile File.join Rails.root, 'tmp/pids/puma.pid'
plugin :tmp_restart

32
docker-compose.yml

@ -0,0 +1,32 @@
x-aliases:
cryptcheck: &cryptcheck
image: aeris/cryptcheck-rails
links:
- mongo
depends_on:
- mongo
environment:
PORT: 3000
MONGO_DATABASE: cryptcheck
MONGO_URL: mongo:27017
REDIS_URL: redis://redis:6379/0
SECRET_KEY_BASE: 19bc5cb3a5265f4eb36634fb784a859a77aa3c270061fcb8522b53a19d01faea171f851fe01943e682f2945488569b9ea508736f959657d05171a358286d121e
version: "3.4"
services:
redis:
image: redis:4.0-alpine
ports:
- 6379:6379
mongo:
image: mongo:3.2
ports:
- 27017:27017
cryptcheck:
<<: *cryptcheck
ports:
- 3000:3000
command: bundle exec rails s
cryptcheck-worker:
<<: *cryptcheck
command: bundle exec sidekiq
Loading…
Cancel
Save