diff --git a/.env.example b/.env.example index d3b2c45..49a8759 100644 --- a/.env.example +++ b/.env.example @@ -1,19 +1,33 @@ -RACK_ENV= -RAILS_ENV= -APP_SECRET= +RACK_ENV=production +RAILS_ENV=production +APP_SECRET=randomstringhere -DEPLOY_PATH= +DEPLOY_PATH=/var/www -PUMA_WORKERS=1 +PUMA_WORKERS=5 PUMA_MIN_THREADS=1 PUMA_MAX_THREADS=16 PUMA_PORT=4000 PUMA_TIMEOUT=30 +# Docker adds mysql to hosts +MYSQL_HOST=mysql + +# This is used by both rails + mysql MYSQL_DATABASE=ensl -MYSQL_USERNAME= -MYSQL_PASSWORD= -MYSQL_CONNECTION_POOL=8 + +# Add to allow docker image to connect +MYSQL_ROOT_HOST=% + +# FIXME: Use root since normal user does not work. atm. +MYSQL_ROOT_PASSWORD=randomstringhere + +# These variables are for ensl +MYSQL_USERNAME=root +MYSQL_PASSWORD=randomstringhere + +# More MySQL vars +MYSQL_CONNECTION_POOL=32 NEW_RELIC_APP_NAME=ENSL NEW_RELIC_LICENSE_KEY= diff --git a/.gitignore b/.gitignore index b782149..0f649c3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ /log/* /tmp/* /spec/tmp/* -/env/* +/env/production.sh +/env/development.sh .ruby-version .ruby-gemset .env diff --git a/Makefile b/Makefile index 08c8123..2ce0741 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PROJECT ?= abevoelker/example_rails_docker_ci +PROJECT ?= ensl/ensl.org TAG ?= latest ifdef REGISTRY diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..4a2665c --- /dev/null +++ b/circle.yml @@ -0,0 +1,4 @@ +database: + override: + - mv config/database.circle.yml config/database.yml + - bundle exec rake db:create db:schema:load --trace diff --git a/entry.sh b/entry.sh index 1523ba4..50b1908 100755 --- a/entry.sh +++ b/entry.sh @@ -1,6 +1,7 @@ #!/bin/bash -env|grep -i MYSQL +env cd /var/www +source .env bundle exec rake assets:precompile bundle exec puma -C config/puma.rb diff --git a/env/test.sh b/env/test.sh new file mode 100755 index 0000000..897d48f --- /dev/null +++ b/env/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +export RACK_ENV=test +export RAILS_ENV=test +export APP_SECRET=e0cdcb729c4b21d5259e957a2ffc13a3 + +export DEPLOY_PATH=/var/www + +export PUMA_WORKERS=1 +export PUMA_MIN_THREADS=1 +export PUMA_MAX_THREADS=16 +export PUMA_PORT=3000 +export PUMA_TIMEOUT=30 + +#export MYSQL_HOST="${MYSQL_PORT_3306_TCP_ADDR:-localhost}" +export MYSQL_DATABASE=ensl +export MYSQL_USER=root +export MYSQL_HOST="mysql" +export MYSQL_USERNAME=root +export MYSQL_ROOT_PASSWORD=test +export MYSQL_PASSWORD=test +export MYSQL_ROOT_HOST=172.% +export MYSQL_CONNECTION_POOL=32 + +exec "$@" diff --git a/fig.yml b/fig.yml index a178931..8250920 100644 --- a/fig.yml +++ b/fig.yml @@ -2,7 +2,8 @@ web: image: ensl volumes: - "/srv/ensl/public:/var/www/public" - ports: "4000:4000" + ports: + - "4000:4000" links: - mysql # - redis diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..e8fe1ed --- /dev/null +++ b/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +# Undo the `bundle --deployment --without development test` +# settings baked into the prod-ready Docker image's .bundle/config +bundle config --delete without +bundle config --delete frozen + +# Install gems in development and test groups +bundle + +# Ensure database exists and has latest migrations +bundle exec rake db:create +bundle exec rake db:migrate + +# Run tests +bundle exec rake