diff --git a/config/database.yml b/config/database.yml index b1f3956..eb8b94f 100644 --- a/config/database.yml +++ b/config/database.yml @@ -27,7 +27,10 @@ test: timeout: 5000 production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 + adapter: mysql2 + encoding: utf8 + database: <%= ENV['WRESTLINGDEV_DB_NAME'] %> + username: <%= ENV['WRESTLINGDEV_DB_USR'] %> + password: <%= ENV['WRESTLINGDEV_DB_PWD'] %> + host: <%= ENV['WRESTLINGDEV_DB_HOST'] %> + port: <%= ENV['WRESTLINGDEV_DB_PORT'] %> diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 2f36199..2282515 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -4,7 +4,7 @@ Devise.setup do |config| # The secret key used by Devise. Devise uses this key to generate # random tokens. Changing this key will render invalid all existing # confirmation, reset password and unlock tokens in the database. - config.secret_key = '2f29d49db6704377ba263f7cb9db085b386bcb301c0cd501126a674686ab1a109754071165b08cd72af03cec4642a4dd04361c994462254dd5d85e9594e8b9aa' + config.secret_key = ENV['WRESTLINGDEV_DEVISE_SECRET_KEY'] if Rails.env.production? # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, diff --git a/deploy/deploy-prod.sh b/deploy/deploy-prod.sh new file mode 100755 index 0000000..2753b03 --- /dev/null +++ b/deploy/deploy-prod.sh @@ -0,0 +1,8 @@ +gpg prod.env.gpg +cd .. +bash rails-prod.sh wrestlingdev +cd deploy +sudo docker-compose -f docker-compose-prod.yml up -d +echo Make sure your local mysql database has a db for wrestlingdev +echo "mysqldump -u guy -ppassword -h host database_name > database.sql" +echo "mysql -u guy -ppassword -h host database_name < database.sql" diff --git a/deploy/deploy-test.sh b/deploy/deploy-test.sh new file mode 100755 index 0000000..533e9ac --- /dev/null +++ b/deploy/deploy-test.sh @@ -0,0 +1,5 @@ +cd .. +bash rails-prod.sh wrestlingdev +cd deploy +sudo docker-compose -f 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 new file mode 100644 index 0000000..6e6b5d4 --- /dev/null +++ b/deploy/docker-compose-common.yml @@ -0,0 +1,21 @@ +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 diff --git a/deploy/docker-compose-prod.yml b/deploy/docker-compose-prod.yml new file mode 100644 index 0000000..70b6f5f --- /dev/null +++ b/deploy/docker-compose-prod.yml @@ -0,0 +1,14 @@ +app: + extends: + file: docker-compose-common.yml + service: app + links: + - db + restart: always + env_file: prod.env +db: + extends: + file: docker-compose-common.yml + service: app + restart: always + env_file: prod.env diff --git a/deploy/docker-compose-test.yml b/deploy/docker-compose-test.yml new file mode 100644 index 0000000..c1837b9 --- /dev/null +++ b/deploy/docker-compose-test.yml @@ -0,0 +1,21 @@ +app: + 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 + links: + - db + restart: always +db: + extends: + file: docker-compose-common.yml + service: app + environment: + - MYSQL_ROOT_PASSWORD=password + restart: always diff --git a/deploy/prod.env.gpg b/deploy/prod.env.gpg new file mode 100644 index 0000000..ade2339 Binary files /dev/null and b/deploy/prod.env.gpg differ diff --git a/rails-prod-Dockerfile b/rails-prod-Dockerfile index 34a9564..d4909f1 100644 --- a/rails-prod-Dockerfile +++ b/rails-prod-Dockerfile @@ -49,7 +49,7 @@ RUN rm -rf /var/www WORKDIR /var/www/ ADD . /var/www/ -RUN RAILS_ENV=production bundle exec rake db:migrate +#RUN RAILS_ENV=production bundle exec rake db:migrate RUN RAILS_ENV=production bundle exec rake assets:precompile diff --git a/rails-prod.sh b/rails-prod.sh index cf23739..db4b8d9 100755 --- a/rails-prod.sh +++ b/rails-prod.sh @@ -6,4 +6,4 @@ if [ $# != 1 ]; then fi docker build -t $1 -f rails-prod-Dockerfile . -sudo docker run -d --restart=always -p 80:80 -p 443:443 $1 \ No newline at end of file +#sudo docker run -d --restart=always -p 80:80 -p 443:443 $1