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 @@
1
+Dockerfile
2
+.git/*
3
+.bundle/*
4
+db/*.sqlite
5
+log/*
6
+tmp/*

+ 22
- 0
Dockerfile View File

@@ -0,0 +1,22 @@
1
+FROM aeris/cryptcheck AS builder
2
+MAINTAINER aeris <aeris@imirhil.fr>
3
+
4
+RUN apk add --update make gcc g++ libxml2-dev yaml-dev zlib-dev nodejs
5
+
6
+WORKDIR /cryptcheck-rails/
7
+COPY . /cryptcheck-rails/
8
+
9
+RUN sed -i "/'therubyracer'/d" Gemfile && \
10
+	sed -i "/^  therubyracer$/d" Gemfile.lock && \
11
+	bundle config --local local.cryptcheck ../cryptcheck && \
12
+	bundle install --deployment --without test development && \
13
+	RAILS_ENV=assets bundle exec rails assets:precompile && \
14
+	rm -rf vendor/bundle && \
15
+	RAILS_ENV=production bundle install --deployment --without test development
16
+
17
+FROM aeris/cryptcheck AS frontend
18
+MAINTAINER aeris <aeris@imirhil.fr>
19
+
20
+ENV RAILS_ENV=production
21
+WORKDIR /cryptcheck-rails/
22
+COPY --from=builder /cryptcheck-rails/ /cryptcheck-rails/

+ 2
- 2
Gemfile View File

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

+ 7
- 5
config/puma.rb View File

@@ -14,15 +14,17 @@ unless Rails.root
14 14
 	end
15 15
 end
16 16
 
17
-if env == 'production'
18
-	workers 4
17
+workers 4 if env == 'production'
18
+
19
+port = ENV['PORT']
20
+if port
21
+	port(port)
22
+else
19 23
 	listen = ENV.fetch('LISTEN') { 'unix://' + File.join(Rails.root, 'tmp/sockets/puma.sock') }
20 24
 	bind listen
21
-else
22
-	listen = ENV.fetch('PORT') { 3001 }
23
-	port listen
24 25
 end
25 26
 
27
+
26 28
 pidfile File.join Rails.root, 'tmp/pids/puma.pid'
27 29
 
28 30
 plugin :tmp_restart

+ 32
- 0
docker-compose.yml View File

@@ -0,0 +1,32 @@
1
+x-aliases:
2
+    cryptcheck: &cryptcheck
3
+        image: aeris/cryptcheck-rails
4
+        links:
5
+            - mongo
6
+        depends_on:
7
+            - mongo
8
+        environment:
9
+            PORT: 3000
10
+            MONGO_DATABASE: cryptcheck
11
+            MONGO_URL: mongo:27017
12
+            REDIS_URL: redis://redis:6379/0
13
+            SECRET_KEY_BASE: 19bc5cb3a5265f4eb36634fb784a859a77aa3c270061fcb8522b53a19d01faea171f851fe01943e682f2945488569b9ea508736f959657d05171a358286d121e
14
+
15
+version: "3.4"
16
+services:
17
+    redis:
18
+        image: redis:4.0-alpine
19
+        ports:
20
+            - 6379:6379
21
+    mongo:
22
+        image: mongo:3.2
23
+        ports:
24
+            - 27017:27017
25
+    cryptcheck:
26
+        <<: *cryptcheck
27
+        ports:
28
+            - 3000:3000
29
+        command: bundle exec rails s
30
+    cryptcheck-worker:
31
+        <<: *cryptcheck
32
+        command: bundle exec sidekiq

Loading…
Cancel
Save