Installation/Heroku: Difference between revisions
Sean Tilley (talk | contribs) No edit summary |
(This environment is unsupported.) |
||
(14 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
== | {{UnsupportedEnvironment}} | ||
{{Note|These instructions are tested on Unix based operating systems only. If you're on Windows you better get a virtual machine.}} | |||
== First deploy == | |||
We start with building a minimal pod entirely hosted on Heroku. | We start with building a minimal pod entirely hosted on Heroku. | ||
It's good to have an RVM installation locally to leave your local system clean(er). | It's good to have an RVM installation locally to leave your local system clean(er). | ||
Fork Diaspora and clone your fork to your local machine. | Fork Diaspora and clone your fork to your local machine. | ||
There checkout a custom branch for your pod, we'll name it | There checkout a custom branch for your pod, we'll name it <tt>heroku</tt> here. | ||
< | <syntaxhighlight lang="bash"> | ||
cd diaspora | |||
git checkout -b heroku origin/master | git checkout -b heroku origin/master | ||
</ | </syntaxhighlight> | ||
We need to switch the <tt>Gemfile.lock</tt> to PostgreSQL. Edit <tt>Gemfile</tt> and change <tt>ENV['DB'] ||= 'mysql'</tt> to <tt>ENV['DB'] ||= 'postgres'</tt>. Then run: | |||
< | <syntaxhighlight lang="bash"> | ||
bundle --without development test heroku production assets | |||
git add Gemfile.lock | git add Gemfile Gemfile.lock | ||
git commit -m "switch Gemfile.lock to pg exclusivly" | git commit -m "switch Gemfile.lock to pg exclusivly" | ||
</ | </syntaxhighlight> | ||
[ | Install the [https://toolbelt.heroku.com/ Heroku toolbelt]. | ||
< | Create an app, you must replace <tt>diasporadev</tt> here and in all following cases with something unique: | ||
<syntaxhighlight lang="bash"> | |||
heroku apps:create diasporadev | |||
</syntaxhighlight> | |||
< | |||
Enable required the addons: | Enable required the addons: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku addons:add redistogo:nano | heroku addons:add redistogo:nano | ||
heroku addons:add heroku-postgresql | heroku addons:add heroku-postgresql | ||
</ | </syntaxhighlight> | ||
And make the database available, replace the | And make the database available, replace the <tt>REPLACEME</tt> with corresponding part of <tt>HEROKU_POSTGRESQL_REPLACEME_URL</tt> that the last command gave you (or look it up with <tt>heroku config</tt>): | ||
< | <syntaxhighlight lang="bash"> | ||
heroku pg:promote HEROKU_POSTGRESQL_REPLACEME | |||
</syntaxhighlight> | |||
Set some basic configuration, remember to replace | Set some basic configuration, remember to replace <tt>diasporadev</tt>: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:set HEROKU=true DB=postgres ENVIRONMENT_URL=https://diasporadev.herokuapp.com/ ENVIRONMENT_ASSETS_SERVE=true SERVER_EMBED_SIDEKIQ_WORKER=true ENVIRONMENT_CERTIFICATE_AUTHORITIES=/usr/lib/ssl/certs/ca-certificates.crt | |||
</syntaxhighlight> | |||
You can now already go through | You can now already go through <tt>config/diaspora.yml.example</tt> and add the settings you want to differ from the defaults, converting them to environment variables as described at the top of the file. | ||
Set a secure token: | Set a secure token: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:add SECRET_TOKEN=$(curl -s "https://www.random.org/cgi-bin/randbyte?nbytes=40&format=h" | tr -d " \n") | |||
</syntaxhighlight> | |||
Now | Now deploy: | ||
< | <syntaxhighlight lang="bash"> | ||
git push -u heroku heroku:master | |||
</syntaxhighlight> | |||
And load the schema: | And load the schema: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku run rake db:schema:load | |||
</syntaxhighlight> | |||
Restart to ensure you're not in the crashed state from the deploy with a unpopulated database: | Restart to ensure you're not in the crashed state from the deploy with a unpopulated database: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku restart | |||
</syntaxhighlight> | |||
That should give you a basic pod, to open it in your browser run | That should give you a basic pod, to open it in your browser run | ||
< | <syntaxhighlight lang="bash"> | ||
heroku open | |||
</syntaxhighlight> | |||
== Custom landing page == | == Custom landing page == | ||
Edit | Edit <tt>.gitignore</tt> and remove the following line: | ||
<pre>app/views/home/_show.*</pre> | <pre> | ||
app/views/home/_show.* | |||
</pre> | |||
Create your landing page as described in [[ | Create your landing page as described in [[Custom Splash Page]]. Add it to your branch: | ||
< | <syntaxhighlight lang="bash"> | ||
git add app/views/home/ | git add app/views/home/ | ||
git commit -m "custom landing page" | git commit -m "custom landing page" | ||
</ | </syntaxhighlight> | ||
Deploy it: | Deploy it: | ||
< | <syntaxhighlight lang="bash"> | ||
git push heroku heroku:master | |||
</syntaxhighlight> | |||
== S3 Image and asset hosting == | == Amazon S3 Image and asset hosting == | ||
To enable image hosting, first set your S3 data: | To enable image hosting, first set your S3 data: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:add ENVIRONMENT_S3_ENABLE=true ENVIRONMENT_S3_KEY=changeme ENVIRONMENT_S3_SECRET=changeme ENVIRONMENT_S3_BUCKET=changeme ENVIRONMENT_IMAGE_REDIRECT_URL=https://changeme.s3.amazonaws.com/ | heroku config:add ENVIRONMENT_S3_ENABLE=true ENVIRONMENT_S3_KEY=changeme ENVIRONMENT_S3_SECRET=changeme ENVIRONMENT_S3_BUCKET=changeme ENVIRONMENT_IMAGE_REDIRECT_URL=https://changeme.s3.amazonaws.com/ | ||
</ | </syntaxhighlight> | ||
Change your region if it's different from the default: | Change your region if it's different from the default: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:add ENVIRONMENT_S3_REGION=eu-west-1 | |||
</syntaxhighlight> | |||
To enable uploading assets to S3 and serving them from it: | To enable uploading assets to S3 and serving them from it: | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:add ENVIRONMENT_ASSETS_UPLOAD=true ENVIRONMENT_ASSETS_HOST=https://changeme.s3.amazonaws.com | |||
</syntaxhighlight> | |||
The assets should be uploaded with the next deploy. If that's not working run the following afterwards: | |||
< | <syntaxhighlight lang="bash"> | ||
heroku run 'rails runner "AssetSync.sync"' | |||
</syntaxhighlight> | |||
== RDS Database hosting == | == Amazon RDS Database hosting == | ||
< | <syntaxhighlight lang="bash"> | ||
heroku config:set DB=mysql | |||
</syntaxhighlight> | |||
Grab commit SHA: | Grab commit SHA from switch to PostgreSQL and revert it: | ||
< | <syntaxhighlight lang="bash"> | ||
git log --grep "switch Gemfile.lock to pg exclusivly" | git log --grep "switch Gemfile.lock to pg exclusivly" | ||
git revert <commit-sha from previous command> | git revert <commit-sha from previous command> | ||
</ | </syntaxhighlight> | ||
Follow | Follow https://devcenter.heroku.com/articles/amazon_rds | ||
Deploy. | Deploy. | ||
[[Category:Podmin]] | [[Category:Podmin]] | ||
[[Category:Installation]] | [[Category:Installation]] | ||
[[Category:Github transfer done]] |
Latest revision as of 14:57, 17 October 2018
First deploy
We start with building a minimal pod entirely hosted on Heroku. It's good to have an RVM installation locally to leave your local system clean(er).
Fork Diaspora and clone your fork to your local machine. There checkout a custom branch for your pod, we'll name it heroku here.
cd diaspora
git checkout -b heroku origin/master
We need to switch the Gemfile.lock to PostgreSQL. Edit Gemfile and change ENV['DB'] ||= 'mysql' to ENV['DB'] ||= 'postgres'. Then run:
bundle --without development test heroku production assets
git add Gemfile Gemfile.lock
git commit -m "switch Gemfile.lock to pg exclusivly"
Install the Heroku toolbelt.
Create an app, you must replace diasporadev here and in all following cases with something unique:
heroku apps:create diasporadev
Enable required the addons:
heroku addons:add redistogo:nano
heroku addons:add heroku-postgresql
And make the database available, replace the REPLACEME with corresponding part of HEROKU_POSTGRESQL_REPLACEME_URL that the last command gave you (or look it up with heroku config):
heroku pg:promote HEROKU_POSTGRESQL_REPLACEME
Set some basic configuration, remember to replace diasporadev:
heroku config:set HEROKU=true DB=postgres ENVIRONMENT_URL=https://diasporadev.herokuapp.com/ ENVIRONMENT_ASSETS_SERVE=true SERVER_EMBED_SIDEKIQ_WORKER=true ENVIRONMENT_CERTIFICATE_AUTHORITIES=/usr/lib/ssl/certs/ca-certificates.crt
You can now already go through config/diaspora.yml.example and add the settings you want to differ from the defaults, converting them to environment variables as described at the top of the file.
Set a secure token:
heroku config:add SECRET_TOKEN=$(curl -s "https://www.random.org/cgi-bin/randbyte?nbytes=40&format=h" | tr -d " \n")
Now deploy:
git push -u heroku heroku:master
And load the schema:
heroku run rake db:schema:load
Restart to ensure you're not in the crashed state from the deploy with a unpopulated database:
heroku restart
That should give you a basic pod, to open it in your browser run
heroku open
Custom landing page
Edit .gitignore and remove the following line:
app/views/home/_show.*
Create your landing page as described in Custom Splash Page. Add it to your branch:
git add app/views/home/
git commit -m "custom landing page"
Deploy it:
git push heroku heroku:master
Amazon S3 Image and asset hosting
To enable image hosting, first set your S3 data:
heroku config:add ENVIRONMENT_S3_ENABLE=true ENVIRONMENT_S3_KEY=changeme ENVIRONMENT_S3_SECRET=changeme ENVIRONMENT_S3_BUCKET=changeme ENVIRONMENT_IMAGE_REDIRECT_URL=https://changeme.s3.amazonaws.com/
Change your region if it's different from the default:
heroku config:add ENVIRONMENT_S3_REGION=eu-west-1
To enable uploading assets to S3 and serving them from it:
heroku config:add ENVIRONMENT_ASSETS_UPLOAD=true ENVIRONMENT_ASSETS_HOST=https://changeme.s3.amazonaws.com
The assets should be uploaded with the next deploy. If that's not working run the following afterwards:
heroku run 'rails runner "AssetSync.sync"'
Amazon RDS Database hosting
heroku config:set DB=mysql
Grab commit SHA from switch to PostgreSQL and revert it:
git log --grep "switch Gemfile.lock to pg exclusivly"
git revert <commit-sha from previous command>
Follow https://devcenter.heroku.com/articles/amazon_rds
Deploy.