Configuring an asset host
Clone this wiki locally
For this page, we'll assume your app is example.com, that you're going to have an asset host assets.example.com, and that you use a multistage environment.
This is really easy in Rails. Just update your config/environments files:
Just make sure that your views use the the asset helpers, like:
You need to setup the following A records using example.com's DNS admin:
- assets.example.com -> example.com's IP
- assets.staging.example.com -> staging.example.com's IP address
These probably can be CNAME records too.
It's nearly as simple to setup in moonshine. Your existing config/moonshine/staging.yml might include something like this:
We just need to update this section to look like:
:domain: staging.example.com :domain_alias: - assets.staging.example.com
Now you can deploy and confirm on staging:
cap staging deploy
And if everything is rad, onwards to production!
cap production deploy
Fortunately, the moonshine side is pretty easy too. We're basically going to update the main virtual host for you app to have alias, ie it will respond to another name. It's configured in