Code-dot-mil / code.mil

An experiment in open source at the Department of Defense.
https://www.code.mil
MIT License
1.28k stars 122 forks source link

Refactor project to support Netlify deployment and hosting #226

Closed jgarber623-gov closed 6 years ago

jgarber623-gov commented 6 years ago

This pull request refactors the project to allow for deployments to Netlify. This change will allow us to streamline our development workflow, deployment process, and hosting environment.

You can review the Netlify-deployed version of the site at https://code-mil.netlify.com.

Code Changes

I'll document significant changes inline, so check out the Files Changed tab for details (or scroll down this page for the grouped commentary).

Verifying Changes

  1. Clone the repo and git checkout netlify
  2. Install Ruby 2.4.3 (e.g. rvm install 2.4.3) and install Bundler gem install bundler
  3. bundle install
  4. ./scripts/build to build the site or ./scripts/serve to serve the site locally on http://localhost:4000

Workflow Changes

Presuming this pull request is merged and we move forward with Netlify hosting, I recommend we modify our workflow to follow a pattern like:

  1. Developer implements changes in a feature branch
  2. Developer issues a pull request against master
    • Pull requests are picked up by Travis CI and run through the test suite
    • Pull requests are auto-deployed by Netlify to a auto-generated subdomain (e.g. some-long-hash--code-mil.netlify.com)
  3. Successful pull requests are merged into master which Netlify auto-deploys to a staging URL (e.g. beta.code.mil)
  4. Successful review of beta.code.mil results in a promotion of master code to a protected production branch which Netlify auto-deploys to code.mil

Deploys to production would bypass CI, but this seems reasonable given the review process and auto-deployment of branches to URLs.

DNS Changes

We'll want to work with the relevant parties to update DNS entries for code.mil, www.code.mil, beta.code.mil, etc.

But! We may need to contact Netlify support if we want to keep using something like beta.code.mil:

If you need to set up branch subdomains without us managing your DNS, please contact support.

(from https://www.netlify.com/docs/custom-domains/#branch-subdomains)

I'd venture, though, that we could auto-deploy all branches and work with the resulting auto-generated subdomains. This would be a non-issue if/when we control the DNS for code.mil.

WebPageTest Results

Before

After

jordangov commented 6 years ago

I think we should talk about how we're going to roll this out initially... maybe Thursday when I'm back?

jgarber623-gov commented 6 years ago

I think we should talk about how we're going to roll this out initially... maybe Thursday when I'm back?

@jordangov Thursday's good for me!