Hatchbox deployment questions
Im launching my app and using your Hatchbox service to help. I was planning on using digitaloceans managed database and wondering how that works with hatchbox and if I need to change anything in my production credentials to make that work
ok to make sure I got this right, in my database.yml file i have the following:
production:
<<: *default
database: defaultdb
username: ******
password: <%= ENV['LIVINGRECIPE_DATABASE_PASSWORD'] %>
url: <%= ENV['DATABASE_URL'] %>
Then in my credentials/production.yml file I have the following:
#database stuff
LIVINGRECIPE_DATABASE_PASSWORD: **************
DATABASE_URL: ************************************
Both of those taken from digitalocean. I used the private host address for the url as it is on the same data center as my clusters will be.
Like I mentioned, you just need to set the ENV var. You don't have to update the database.yml because the env var will override it.
So ran into a precompile issue with some of my keys. I have all my keys in the production credentials file but its dont recognizing it. I changed the code to reference an ENV variable and added my keys that way thru hatchbox. Does hatchbox not utilize the production credentials file?
Did you forget to add your RAILS_MASTER_KEY env var? That's usually what people forget.
I did, and that is the secret_key_base in the credentials file correct? Still getting use to the new credentials setup
Well got past the key stuff, now I have some issues with yarn. Get this error when trying to install:
ERROR in ./node_modules/select2/dist/css/select2.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Cannot find module '@tailwindcss/custom-forms'
Require stack:
- /home/deploy/livingrecipe/releases/20191231202322/app/javascript/stylesheets/tailwind.config.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/tailwindcss/lib/index.js
- /home/deploy/livingrecipe/releases/20191231202322/postcss.config.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/import-fresh/index.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/cosmiconfig/dist/loaders.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/cosmiconfig/dist/createExplorer.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/cosmiconfig/dist/index.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/cssnano/dist/index.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/optimize-css-assets-webpack-plugin/src/index.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/@rails/webpacker/package/environments/production.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/@rails/webpacker/package/index.js
- /home/deploy/livingrecipe/releases/20191231202322/config/webpack/environment.js
- /home/deploy/livingrecipe/releases/20191231202322/config/webpack/production.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/webpack-cli/bin/utils/convert-argv.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/webpack-cli/bin/cli.js
- /home/deploy/livingrecipe/releases/20191231202322/node_modules/webpack/bin/webpack.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (/home/deploy/livingrecipe/releases/20191231202322/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object. (/home/deploy/livingrecipe/releases/20191231202322/app/javascript/stylesheets/tailwind.config.js:62:5)
at Module._compile (/home/deploy/livingrecipe/releases/20191231202322/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (/home/deploy/livingrecipe/releases/20191231202322/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/tailwindcss/lib/index.js:67:122
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/tailwindcss/lib/processTailwindFeatures.js:32:20
at LazyResult.run (/home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:295:14)
at LazyResult.asyncTick (/home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:208:26)
at LazyResult.asyncTick (/home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:221:14)
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:250:14
at new Promise ()
at LazyResult.async (/home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:246:23)
at LazyResult.then (/home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss/lib/lazy-result.js:127:17)
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss-loader/src/index.js:142:8
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/webpack/lib/NormalModule.js:316:20
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/loader-runner/lib/LoaderRunner.js:233:18
at context.callback (/home/deploy/livingrecipe/releases/20191231202322/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at /home/deploy/livingrecipe/releases/20191231202322/node_modules/postcss-loader/src/index.js:208:9
@ ./app/javascript/packs/application.js 8:283-320
Make sure the node module is in your package.json as a full dependency, not dev dependencies.
Well keep getting further. Now Hatchbox deploys the app successfully but it has this comment:
-----> Restarting server
There are no Phusion Passenger-served applications running whose paths begin with '/home/deploy/livingrecipe/current'.
Branch master (at 8bc3d26710784ffc568517f70ce380a0b3781e32) deployed as release 20191231212424 by deploy
This is the error:
[ E 2019-12-31 21:44:09.9456 15620/Tf age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /home/deploy/livingrecipe/current: The application encountered the following error: Cannot load `Rails.config.active_storage.service`:
expected :endpoint to be a HTTP or HTTPS endpoint (ArgumentError)
Error ID: 328905b0
Error details saved to: /tmp/passenger-error-8ltipm.htm
Found the problem with the storage, didnt have the full endpoint in the storage config for digitalocean. It deploys now and the index page loads but as soon as I navigate to a page that tries and queries the database i get an error like this:
[eabfc969-459b-45d4-9fdd-124d60bd1e02] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "equipment" does not exist
LINE 8: WHERE a.attrelid = '"equipment"'::regclass
^
):
Looks like the database isnt being created initially (which looking at the deploy script it just runs migrate, which my migrations unfortunatley got messed up. so need to run db:setup)
So I tried to SSH in and manually setup the database with the following:
bundle exec rails db:setup DISABLE_DATABASE_ENVIRONMENT_CHECK=1 SAFETY_ASSURED=1
and I get these errors:
FATAL: database "postgres" does not exist
Couldn't create 'defaultdb' database. Please check your configuration.
rails aborted!
ActiveRecord::NoDatabaseError: FATAL: database "postgres" does not exist
My database.yml for production has this production:
and I have the connection string from the digitaloceans postgres settings:
url: <%= ENV['DATABASE_URL'] %>
postgresql://username:password@db-postgresql-sfo2-71324-do-user-6600757-0.db.ondigitalocean.com:25060/dbname?sslmode=require
But it doesnt seem to want to connect
Finally figured it out. The connection was there, just rails db:setup
was failing, but rails db:schema:load
did work.
Thanks again for all your help and quick responses