Merge pull request #2060 from scott/update-compose

Switch compose to use puma, nginx closes #1926 closes #1909 closes #1702
This commit is contained in:
Scott Miller
2021-10-20 15:50:55 -06:00
committed by GitHub
7 changed files with 99 additions and 15 deletions

View File

@@ -46,4 +46,6 @@ USER $HELPY_USER
COPY docker/database.yml $HELPY_HOME/config/database.yml
EXPOSE 3000
CMD ["/bin/bash", "/helpy/docker/run.sh"]

View File

@@ -211,7 +211,8 @@ end
group :production do
# Uncomment this gem for Heroku:
# gem 'rails_12factor'
gem 'unicorn'
gem 'unicorn' #kept for backwards compatibility
gem 'puma'
end
ruby '>= 2.2', '< 3.0'

View File

@@ -339,7 +339,7 @@ GEM
kaminari-i18n (0.5.0)
kaminari
rails
kgio (2.11.3)
kgio (2.11.4)
launchy (2.5.0)
addressable (~> 2.7)
less (2.6.0)
@@ -388,6 +388,7 @@ GEM
mustermann-grape (1.0.1)
mustermann (>= 1.0.0)
netrc (0.11.0)
nio4r (2.5.8)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oauth (0.5.4)
@@ -448,6 +449,8 @@ GEM
byebug (~> 10.0)
pry (~> 0.10)
public_suffix (4.0.6)
puma (5.5.0)
nio4r (~> 2.0)
rack (1.6.13)
rack-accept (0.4.5)
rack (>= 0.4)
@@ -489,7 +492,7 @@ GEM
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
raindrops (0.19.1)
raindrops (0.19.2)
rake (13.0.1)
ranked-model (0.4.1)
activerecord (>= 3.1.12)
@@ -605,7 +608,7 @@ GEM
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (1.7.0)
unicorn (5.7.0)
unicorn (6.0.0)
kgio (~> 2.6)
raindrops (~> 0.7)
warden (1.2.7)
@@ -714,6 +717,7 @@ DEPENDENCIES
premailer-rails
pry
pry-byebug
puma
rack-cors
rails (= 4.2.11.1)
rails-i18n (~> 4.0.9)

9
config/puma.rb Normal file
View File

@@ -0,0 +1,9 @@
environment ENV.fetch 'RAILS_ENV', 'production'
threads 0, 16
bind 'tcp://0.0.0.0:3000'
on_worker_boot do
ActiveRecord::Base.establish_connection
end

View File

@@ -2,20 +2,16 @@ version: '2'
services:
frontend:
image: webwurst/caddy
image: nginx:1.15
container_name: nginx
volumes:
- ./docker/Caddyfile:/etc/caddy/Caddyfile
- ./certs:/etc/caddy/certs
volumes_from:
- helpy:ro
- ./docker/nginx.conf:/etc/nginx/nginx.conf
ports:
- "80:80"
- "443:443"
- 80:80
- 443:443
networks:
- front
restart: always
depends_on:
- helpy
helpy:
build: .
restart: always
@@ -27,6 +23,8 @@ services:
env_file: docker/.env
depends_on:
- postgres
ports:
- "3000:3000"
postgres:
image: postgres:9.4
restart: always

70
docker/nginx.conf Normal file
View File

@@ -0,0 +1,70 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
#include /etc/nginx/mime.types;
#default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
server {
listen 80;
location / {
proxy_pass http://helpy:3000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}

View File

@@ -29,8 +29,8 @@ if [[ "$RUN_PREPARE" = "false" ]]
bundle exec rake db:seed || echo "db is already seeded"
fi
echo "starting unicorn"
echo "starting puma"
mkdir -p log
touch log/production.log
exec bundle exec unicorn -E production -c config/unicorn.rb
exec bundle exec puma -C config/puma.rb