-
Notifications
You must be signed in to change notification settings - Fork 29
Deploying
Drew Baker edited this page Apr 25, 2021
·
1 revision
This is advice for Funkhaus team only.
Please see the Dropbox Paper guides for better guides.
You are simply deploying a Nuxt project, so any way you can deploy Nuxt will work with this boilerplate. Below I explain how we do it at Funkhaus using Heroku.
We recommended using CloudFlare for your DNS, it's free plan is enough to do everything you need.
- Add a Site
- Connect the GitHub repo (use the Funkhaus account as the "owner", not your personal account)
- Set "Build command" to
npm run generate - Set "Publish directory" to
dist - Under "Advanced build settings" you'll need to define any
.envvariables that are needed. Normally this is justGQL_ENDPOINT.- Be sure to have your API URL be
https://otherwise Netlify will error.
- Be sure to have your API URL be
- Go to "Domain Settings" and change temporary domain to
https://{CLIENT_NAME}-funkhaus.netlify.apporhttps://{CLIENT_NAME}-storybook-funkhaus.netlify.app- If the site is going live, then you should connect a real domain.
- If the site is in development, go to "Visitor access" and set password on the site.
- Make sure the "Netlify Deploy" WordPress plugin is installed and configured. For new sites, leave auto-deploy turned off. Once the site is live, enable auto deploys.
- In Netlify dashboard, go to "Deploy Settings > Build & Deploy > Post Processing" and disable "Form detection". This will decrease build time by 30 seconds.
- Add a Site
- Connect the GitHub repo (use the Funkhaus account as the "owner", not your personal account)
- Set "Build command" to
npm run storybook-build - Set "Publish directory" to
storybook-static
- Connect the GitHub repo (use the Funkhaus account as the "owner", not your personal account)
When you have your app set up, you'll want to add it to a project specific pipeline.
- Name your pipeline
{project-name}-nuxt - Add the corresponding app to production or staging pipelines.
- Make sure you transfer ownership to Funkhaus if you're part of the team.
Follow the instructions here pipelines
If you're comfortable with the command line, install the heroku cli tools.
Otherwise you can do it all through the website Dashboard too.
- Login in to heroku
- Create an App.
- To set up different environments (staging / production) follow the instructions here
- Name it
{project-name}-production - After beta you will create
{project-name}-staging
- Make sure you transfer ownership to Funkhaus if you're part of the team.
- For your Heroku app, go to "Deploy" and connect it to the GitHub repo.
- Generally it's best to not enable automatic deploy, and to use the "Manual deploy" button at the bottom.
- For production apps, we should always deploy form
masterbranch.
- For your Heroku app, go to "Settings" and define all your
Config Vars.- Follow the instructions here to set up your required Nuxt config vars.
- Be sure to add the same config vars that are in you
.envfile too.
- Prep Nuxt to go live.
- Disable Basic Auth on servers
.envfile or settings panel. - Set the environment endpoints to be the new domain names. Probably
https://api.your-site.com/graphql. - If you're using Shopify,
https://shop.your-site.com/api/{version number here}/graphql.json. You may want to use a.envfor these, it helps when dealing with staging setups. - Be sure to turn off Privacy mode in Flywheel.
- Disable Basic Auth on servers
- In Heroku, add your custom domain name to the App. See here. Note the "DNS Target" Heroku gives you, it should be some funny names and a random string like
space-balls-12345drewish.herokudns.com. - Turn on SSL in Heroku using the "Automated Certificate Management" (this only works if you're hosting on a paid Heroku plan, which Funkhaus has).
- In CloudFlare, click "+ Add Site" (top left of screen).
- When it asks for DNS entries, you'll want to set two CNAME's pointing to the "DNS Target" shown in Heroku (mentioned in Step 1).
- One CNAME for
wwwand one CNAME set to@, which CloudFlare will then auto apply "CNAME Flattening", which is good. See here for more. - Add an A-RECORD for your API backend, which is the WordPress install hosted on Flywheel. Generally you want this to be
api.your-site.com.
- Setting up
www.and force SSL redirects in CloudFlare. You want two rules:- Click 'Page Rules'.
- Click 'Add a rule'.
- Match the URL to
*www.your-site.com/*.- Select 'Forwarding URL' from the dropdown menu.
- Choose '301 - Permanent Redirect'.
- Set the redirect URL to
https://your-site.com/$2.
- Match the URL to
http://your-site.com/*- Select 'Forwarding URL' from the dropdown menu.
- Choose '301 - Permanent Redirect'.
- Set the redirect URL to
https://your-site.com/$1.
- In Flywheel, add a new primary domain, this should match the CloudFlare entry you set above, probably
api.your-site.com. When adding the domain ensure that the "Also add www" checkbox is not selected.- Setup the free SSL on Flywheel, and then make sure "Force SSL" is turned on under Advanced.
- Be sure to turn off Privacy mode in Flywheel.
- At this point, you will probably want to redirect your nameservers to point to CloudFlare. Probably these are close to
homer.ns.cloudflare.comandmarge.ns.cloudflare.com. - Confirm that CloudFlare's SSL mode is set to 'Flexible' under 'SSL/TLS' tab. You need to do this, as it conflicts with the auto SSL setup on Flywheel.
- If the site uses Shopify, you'll need to "Add an existing domain". Probably this will be
shop.your-site.com.- In CloudFlare set a CNAME for
shop.your-site.comto point toshops.myshopify.com. - You do not need to setup an A-RECORD if you only want the shop to be on a sub-domain.
- In CloudFlare set a CNAME for
- Login to Heroku, and on the "Deploy" tab on the production app, click the "Manual Deploy" button!