CoolTeamGraceShopper / GraceShopper

0 stars 1 forks source link

Boilermaker

Good things come in pairs

Looking to mix up a backend with express/sequelize and a frontend with react/redux? That's boilermaker!

Follow along with the workshop to make your own! This canonical version can serve as a reference, or a starting point all on its own.

Setup

To use this boilerplate, you'll need to take the following steps:

git remote add boilermaker https://github.com/FullstackAcademy/boilermaker.git
git fetch boilermaker
git merge boilermaker/master

Why did we do that? Because every once in a while, boilermaker may be updated with additional features or bug fixes, and you can easily get those changes from now on by entering:

git fetch boilermaker
git merge boilermaker/master

Customize

Now that you've got the code, follow these steps to get acclimated:

Linting

Linters are fundamental to any project - they ensure that your code has a consistent style, which is critical to writing readable code.

Boilermaker comes with a working linter (ESLint, with eslint-config-fullstack) "out of the box." However, everyone has their own style, so we recommend that you and your team work out yours and stick to it. Any linter rule that you object to can be "turned off" in .eslintrc.json. You may also choose an entirely different config if you don't like ours:

Start

npm run start-dev will make great things happen!

If you want to run the server and/or webpack separately, you can also npm run start-server and npm run build-client.

From there, just follow your bliss.

Deployment

Ready to go world wide? Here's a guide to deployment!

Prep

  1. Set up the Heroku command line tools
  2. heroku login
  3. Add a git remote for heroku:

    • If you're creating a new app...

      1. heroku create or heroku create your-app-name if you have a name in mind.
      2. heroku addons:create heroku-postgresql:hobby-dev to add ("provision") a postgres database to your heroku dyno
    • If you already have a Heroku app...

      1. heroku git:remote your-app-name You'll need to be a collaborator on the app.

When you're ready to deploy

  1. Make sure that all your work is fully committed and pushed to your master branch on Github.
  2. If you currently have an existing branch called "deploy", delete it now (git branch -d deploy). We're going to use a dummy branch with the name "deploy" (see below), so if you have one lying around, the script below will error
  3. npm run deploy - this will cause the following commands to happen in order:
    • git checkout -b deploy: checks out a new branch called "deploy". Note that the name "deploy" here isn't magical, but it needs to match the name of the branch we specify when we push to our heroku remote.
    • webpack -p: webpack will run in "production mode"
    • git add -f public/bundle.js public/bundle.js.map: "force" add the otherwise gitignored build files
    • git commit --allow-empty -m 'Deploying': create a commit, even if nothing changed
    • git push --force heroku deploy:master: push your local "deploy" branch to the "master" branch on heroku
    • git checkout master: return to your master branch
    • git branch -D deploy: remove the deploy branch

Now, you should be deployed!

Why do all of these steps? The big reason is because we don't want our production server to be cluttered up with dev dependencies like webpack, but at the same time we don't want our development git-tracking to be cluttered with production build files like bundle.js! By doing these steps, we make sure our development and production environments both stay nice and clean!