This documents explains how to deploy a Rails app to Uberspace as a hosting provider and InternetWorx as a domain registrar.
In the following document, replace ACCOUNT
with your Uberspace account name (e.g. base
), SERVER
with the Uberspace server (e.g. sirius
), PROJECT
with your GitHub repository name (e.g. base
), and PORT
with the Rails app's port (I suggest using one close to but above 3001
)! When you worked through this document, remove this paragraph here, then commit the document.
Notice: the $
sign in code examples indicates a shell prompt! If you copy&pase, don't copy the $
sign!
- Go to the register page and create a new Uberspace account.
- Then add your public SSH key on the Logins page.
- To view your public SSH key, do
$ cat ~/.ssh/id_rsa.pub
.
- To view your public SSH key, do
- You can see the chosen Uberspace server's name in the Datasheet.
- Now you can connect to your account:
$ ssh [email protected]
.- Confirm the question
Are you sure you want to continue connecting?
with a heartlyyes
.
- Confirm the question
- Add your SSH public key to GitHub: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
- Like above, to view your public SSH key, do
$ cat ~/.ssh/id_rsa.pub
.
- Like above, to view your public SSH key, do
- On your local console, execute
ssh -T [email protected]
and confirm.- You should see something like
Hi user! You've successfully authenticated, but GitHub does not provide shell access.
.
- You should see something like
To send Mails using SMTP, we need a mailer email account.
- On Uberspace, execute
$ uberspace mail user add mailer
. - Remember the password for later use!
Create /home/ACCOUNT/rails/shared/config/secrets.yml
and set up a deployment
config according to config/secrets.example.yml
(remove development
and test
configs).
The database info can be found in the file ~/.my.cnf
.
- Edit
config/deploy.rb
and set::application
to something like'Base'
.:repo_url
to something like'[email protected]:jmuheim/base.git'
.:deploy_to
to something like'/home/ACCOUNT/rails'
.:puma_bind
to something like'tcp://0.0.0.0:PORT'
(use the same port asapp_port
insecrets.yml
, e.g.3001
).
- Edit
config/deploy/production.rb
and add a line likeserver "ACCOUNT.uberspace.de", user: "ACCOUNT", roles: %w{web app db}
- Save the files, commit and push the branch.
The first deployment is a special one, as it needs to load the database schema (it is called a "cold" deploy). Any subsequent deployments won't do this; instead they will trigger the database migrations.
On your local console, execute $ cap production deploy_cold
. This could take some minutes (installing and compiling gems).
The Rails app is now running in the background and accepts request on the specified port. To make this port accessible to the outside world, we need to route incoming requests to it.
- On Uberspace, execute
$ uberspace web backend set / --http --port PORT
(use the same port asapp_port
insecrets.yml
, e.g.3001
).- To verify that the server actually is running on the specified port, execute
$ ps aux | grep puma
.
- To verify that the server actually is running on the specified port, execute
- Now go to http://ACCOUNT.uber.space and enjoy your site!
You may now want to update the link to the live project in README.md
. :-)
To populate the database with initial records (seeds), execute $ cap production db_seed
. See db/seeds.rb
for more details about the seed data.
To use existing data (maybe from another running instance, or from your development instance), feel free to simply export the database tables in question and import them into the database.
For any further deployment, simply push all your changes, then run $ cap production deploy
.
Setup of deployment ends here. The following is a collection of additional useful information regarding Uberspace.
For website use, on Uberspace, execute:
$ uberspace web domain add example.com
to add domainexample.com
$ uberspace web domain add www.example.com
to add subdomainwww.example.com
For mail use, on Uberspace, execute:
$ uberspace mail domain add example.com
adds domainexample.com
Add the following records to the DNS for the domain (at your domain registrar's control panel, in our case InternetWorx):
- IPv4:
dig <server>.uberspace.de A +short
- IPv6:
dig <server>.uberspace.de AAAA +short
- Aliases (CNAME):
www
autoconfig
andautodiscover
(for automx support)
- Email (MX):
SERVER.uberspace.de
with priority5
Create account user
in namespace example
:
$ vadduser example-user
Mail sent to [email protected]
will be received by this account.
OSX Mail:
- Go to http://automx.SERVER.uberspace.de and create and download a
.mobileconfig
file - Execute the file
Thunderbird:
- Just add the account in the account settings using user name and password - Thunberbird will automatically detect the correct settings!