diff --git a/Gemfile b/Gemfile index 763cb1e..500aed0 100644 --- a/Gemfile +++ b/Gemfile @@ -52,7 +52,8 @@ gem 'cancancan' gem 'round_robin_tournament' gem 'rb-readline' gem 'delayed_job_active_record' -gem 'puma' +#gem 'puma' +gem 'passenger' gem 'travis' group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 14a6d29..806ed73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -151,8 +151,10 @@ GEM parallel (1.12.1) parser (2.5.1.0) ast (~> 2.4.0) + passenger (5.3.3) + rack + rake (>= 0.8.1) powerpack (0.1.2) - puma (3.11.4) pusher-client (0.6.2) json websocket (~> 1.0) @@ -275,7 +277,7 @@ DEPENDENCIES jquery-rails mysql2 newrelic_rpm - puma + passenger rails (= 5.2.0) rails_12factor rb-readline diff --git a/Procfile b/Procfile index 2561a76..bc4cbfd 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,3 @@ worker: bundle exec rake jobs:work -web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development} +#web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development} +web: bundle exec passenger start -p $PORT --max-pool-size 3 diff --git a/deploy/deploy-test.sh b/deploy/deploy-test.sh index c9a59bf..adab91b 100755 --- a/deploy/deploy-test.sh +++ b/deploy/deploy-test.sh @@ -1,7 +1,8 @@ #!/bin/bash project_dir="$(dirname $( dirname $(readlink -f ${BASH_SOURCE[0]})))" -docker build -t wrestlingdev -f ${project_dir}/deploy/rails-prod-Dockerfile ${project_dir} +#docker build -t wrestlingdev:test -f ${project_dir}/deploy/rails-prod-Dockerfile ${project_dir} docker-compose -f ${project_dir}/deploy/docker-compose-test.yml kill +docker-compose -f ${project_dir}/deploy/docker-compose-test.yml build docker-compose -f ${project_dir}/deploy/docker-compose-test.yml up -d echo Make sure your local mysql database has a wrestlingtourney db diff --git a/deploy/docker-compose-common.yml b/deploy/docker-compose-common.yml deleted file mode 100644 index 0de23b1..0000000 --- a/deploy/docker-compose-common.yml +++ /dev/null @@ -1,25 +0,0 @@ -app: - image: wrestlingdev - ports: - - "80:80" - - "443:443" -jobs: - image: wrestlingdev - command: bundle exec rake:jobs -db: - image: mysql:5.5 - ports: - - "3306:3306" - volumes: - - /srv/docker/mysql:/var/lib/mysql - -email: - image: postfix - -memcached: - image: memcached - mem_limit: 64000000 - -worker: - image: wrestlingdev - command: /bin/bash -c "cd /rails && bundle exec rake jobs:work RAILS_ENV=production" diff --git a/deploy/docker-compose-prod-full-stack.yml b/deploy/docker-compose-prod-full-stack.yml index 09430ec..a94f6a9 100644 --- a/deploy/docker-compose-prod-full-stack.yml +++ b/deploy/docker-compose-prod-full-stack.yml @@ -1,36 +1,54 @@ -app: - extends: - file: docker-compose-common.yml - service: app - image: wrestlingdev-prod - links: - - db - restart: always - env_file: - - ./prod.env -db: - extends: - file: docker-compose-common.yml - service: db - restart: always - env_file: - - ./prod.env -worker: - extends: - file: docker-compose-common.yml - service: worker - image: wrestlingdev-prod - links: - - db - restart: always - env_file: - - ./prod.env - healthcheck: - test: ps -ef | grep rake | grep ruby - command: bundle exec rake jobs:work RAILS_ENV=production +version: "3.3" +networks: + database: + caching: -memcached: - extends: - file: docker-compose-common.yml - service: memcached - restart: always +volumes: + mysql: + +services: + app: + image: wrestlingdev-prod + ports: + - "80:80" + - "443:443" + networks: + database: + caching: + restart: always + env_file: + - ./prod.env + healthcheck: + test: curl --insecure https://127.0.0.1/ + + db: + image: mysql:5.5 + ports: + - "3306:3306" + volumes: + - mysql:/var/lib/mysql + restart: always + env_file: + - ./prod.env + networks: + database: + + worker: + image: wrestlingdev-prod + networks: + database: + caching: + restart: always + env_file: + - ./prod.env + healthcheck: + test: ps -ef | grep rake | grep ruby + command: bundle exec rake jobs:work RAILS_ENV=production + + + memcached: + image: memcached + mem_limit: 64000000 + restart: always + networks: + caching: \ No newline at end of file diff --git a/deploy/docker-compose-test.yml b/deploy/docker-compose-test.yml index 5429e85..1142ee3 100644 --- a/deploy/docker-compose-test.yml +++ b/deploy/docker-compose-test.yml @@ -1,59 +1,109 @@ -app: - image: registry:5000/wrestlingdev:dev - extends: - file: docker-compose-common.yml - service: app - environment: - - WRESTLINGDEV_DB_NAME=wrestlingtourney - - WRESTLINGDEV_DB_USR=root - - WRESTLINGDEV_DB_PWD=password - - WRESTLINGDEV_DB_HOST=db - - WRESTLINGDEV_DB_PORT=3306 - - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa - - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 - - MEMCACHIER_SERVERS=memcached:11211 - - MEMCACHIER_USERNAME= - - MEMCACHIER_PASSWORD= - links: - - db - - memcached - restart: always +version: "3.3" +networks: + database: + caching: -db: - extends: - file: docker-compose-common.yml - service: db - environment: - - MYSQL_ROOT_PASSWORD=password - restart: always +volumes: + mysql: + +services: + app: + image: wrestlingdev + build: + context: ../ + dockerfile: ./deploy/rails-prod-Dockerfile + environment: + - WRESTLINGDEV_DB_NAME=wrestlingtourney + - WRESTLINGDEV_DB_USR=root + - WRESTLINGDEV_DB_PWD=password + - WRESTLINGDEV_DB_HOST=db + - WRESTLINGDEV_DB_PORT=3306 + - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa + - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 + - MEMCACHIER_SERVERS=memcached:11211 + - MEMCACHIER_USERNAME= + - MEMCACHIER_PASSWORD= + networks: + database: + caching: + restart: always + ports: + - "80:80" + - "443:443" + deploy: + resources: + limits: + cpus: '0.25' + memory: 512M + reservations: + cpus: '0.25' + memory: 256M + healthcheck: + test: curl --insecure https://127.0.0.1/ -worker: - image: registry:5000/wrestlingdev:dev - extends: - file: docker-compose-common.yml - service: worker - environment: - - WRESTLINGDEV_DB_NAME=wrestlingtourney - - WRESTLINGDEV_DB_USR=root - - WRESTLINGDEV_DB_PWD=password - - WRESTLINGDEV_DB_HOST=db - - WRESTLINGDEV_DB_PORT=3306 - - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa - - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 - - MEMCACHIER_SERVERS=memcached:11211 - - MEMCACHIER_USERNAME= - - MEMCACHIER_PASSWORD= - links: - - db - - memcached - restart: always - healthcheck: - test: ps -ef | grep rake | grep ruby - command: bundle exec rake jobs:work RAILS_ENV=production + db: + image: mysql:5.5 + ports: + - "3306:3306" + volumes: + - mysql:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD=password + restart: always + networks: + database: + deploy: + resources: + limits: + cpus: '0.25' + memory: 512M + reservations: + cpus: '0.25' + memory: 256M -memcached: - extends: - file: docker-compose-common.yml - service: memcached - restart: always + worker: + image: wrestlingdev + build: + context: ../ + dockerfile: ./deploy/rails-prod-Dockerfile + environment: + - WRESTLINGDEV_DB_NAME=wrestlingtourney + - WRESTLINGDEV_DB_USR=root + - WRESTLINGDEV_DB_PWD=password + - WRESTLINGDEV_DB_HOST=db + - WRESTLINGDEV_DB_PORT=3306 + - WRESTLINGDEV_DEVISE_SECRET_KEY=2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa + - WRESTLINGDEV_SECRET_KEY_BASE=077cdbef5c2ccf22543fb17a67339f234306b7fa2e1e4463d851c444c10a5611829a2290b253da78339427f131571fac9a42c83d960b2d25ecc10a4a0a7ce1a2 + - MEMCACHIER_SERVERS=memcached:11211 + - MEMCACHIER_USERNAME= + - MEMCACHIER_PASSWORD= + networks: + database: + caching: + restart: always + healthcheck: + test: ps -ef | grep rake | grep ruby + command: bundle exec rake jobs:work RAILS_ENV=production + deploy: + resources: + limits: + cpus: '0.25' + memory: 512M + reservations: + cpus: '0.25' + memory: 256M + + memcached: + image: memcached + deploy: + resources: + limits: + cpus: '0.10' + memory: 64M + reservations: + cpus: '0.10' + memory: 64M + restart: always + networks: + caching: diff --git a/deploy/rails-prod-Dockerfile b/deploy/rails-prod-Dockerfile index 90f448e..f204733 100644 --- a/deploy/rails-prod-Dockerfile +++ b/deploy/rails-prod-Dockerfile @@ -70,4 +70,5 @@ RUN RAILS_ENV=production bundle exec rake assets:precompile # By default, simply start puma. WORKDIR /rails -CMD bundle exec puma -t 5:5 -b 'ssl://0.0.0.0:443?key=/ssl/server.key&verify_mode=none&cert=/ssl/server.crt' -e production +#CMD bundle exec puma -t 3:3 -b 'ssl://0.0.0.0:443?key=/ssl/server.key&verify_mode=none&cert=/ssl/server.crt' -e production +CMD bundle exec passenger start -p 443 --max-pool-size 3 --environment production --ssl --ssl-certificate /ssl/server.crt --ssl-certificate-key /ssl/server.key \ No newline at end of file