Browse Source

Dockerization

new-scoring
aeris 1 year ago
parent
commit
ce09988973
5 changed files with 69 additions and 7 deletions
  1. 6
    0
      .dockerignore
  2. 22
    0
      Dockerfile
  3. 2
    2
      Gemfile
  4. 7
    5
      config/puma.rb
  5. 32
    0
      docker-compose.yml

+ 6
- 0
.dockerignore View File

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

+ 22
- 0
Dockerfile View File

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

+ 2
- 2
Gemfile View File

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


+ 7
- 5
config/puma.rb View File

@@ -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
- 0
docker-compose.yml View File

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