Giter Club home page Giter Club logo

ember-deployment-guide's Introduction

General Assembly Logo

Ember Deployment Guide

Use this guide to deploy Ember apps based on our Ember Template to GitHub Pages.

Prerequisites

Objectives

By the end of this, developers should be able to:

  • Deploy an Ember app to GitHub Pages

Deployment to Github

  1. If you haven't already, run npm install and bower install.
  2. Make sure that everything is named consistently (i.e. ember-template -> <% NAME OF YOUR CLIENT %>). (Search via command+shift+f)
  3. You need to tell your Ember client to point to your deployed API. Update config/environment.js to follow below:

Important:

-Note that if you do not see the apiHost line, you will need to add it now as seen below.

module.exports = function(environment) {
  var ENV = {
    modulePrefix: '<% NAME OF YOUR CLIENT will be here %>',
    environment: environment,
    rootURL: '/',
    locationType: 'auto',
    apiHost: 'http://localhost:3000/',
    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

Yes, user var for ENV. Do not use const. Do not use let.

AND FURTHER DOWN IN config/environment.js:

if (environment === 'production') {
  ENV.rootURL = '/<name-of-git-repo>';
  ENV.locationType = 'hash';
  ENV.apiHost = '<% replace with the URL to your deployed API %>';
}
  1. Now change the value of ENV.rootURL to be the name of your git repository; e.g. in the case of this repository it would be ENV.rootURL = '/ember-deployment-guide'

Important:

-Note that rootURL is NOT camelcase. For example, rootUrl will not work.

  1. Now you have to ensure you have your adapters/application.js and ajax files import the apiHost link.

In adapters/application.js file:

import ActiveModelAdapter from 'active-model-adapter';
import ENV from '<% ember-deployment-example name %>/config/environment';

export default ActiveModelAdapter.extend({
  host: ENV.apiHost,
  ...
  ...
  ...
});

IF/WHEN you have a services/ember-ajax file:

import AjaxService from 'services/ember-ajax';
import ENV from '<% ember-deployment-example name %>/config/environment';

export default AjaxService.extend({
  host: ENV.apiHost,
  ...
  ...
  ...
});
  1. Make sure all work is committed and working on your master branch.
  2. Create a gh-pages branch locally via git checkout -b gh-pages.
  3. DO NOT PUSH TO GH-PAGES YET
  4. Remove /dist from .gitignore by adding a '#' before it.
  5. Add and commit this change. (git add dist/)why?
  6. Run ember build --environment=production.
  7. git status and add all files changed (mainly dist/) and some other changes; Then commit all changes.
  8. Use "subtree push" to create a new gh-pages branch on GitHub composed only of the dist directory by using:
git subtree push --prefix dist origin gh-pages
  1. Go check to your github page site and ensure all requests are working and appear the same as on localhost:4200.
  2. Congrats, you've successfully deployed your Ember App! Zoey and Tomster are proud of you!
Adding dist/

You just said remove, why am I adding again? This is because you just removed dist/ from the gitignore, which means that git is now aware of it and will track it if added. We want to track dist on the gh-pages branch, so we add and commit it here.

  1. All content is licensed under a CC­BY­NC­SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

ember-deployment-guide's People

Contributors

bengitscode avatar laurenfazah avatar payne-chris-r avatar raq929 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ember-deployment-guide's Issues

`application/adapter` has been changed to `adapters/application`

Carefully confirm all depodification filenames/locations have been updated in this guide.

In updating ember-template from the depodofication, application/adapterneeds to be changed to app/adapters/application.js

I know for a fact the above example is wrong, more may be as well.

Consider Heroku Deployment for Ember Apps

I just deployed my capstone project to Heroku, and it was quite simple, and makes redeployment (as far as I can tell) much easier.

I followed the instructions to create this buildpack and deploy:
https://github.com/tonycoco/heroku-buildpack-ember-cli

And I had to follow the instructions referenced in this issue to set up environment variables.

You can test whether or not the app will deploy successfully by seeing if Ember build runs--I was having a merge conflict that prevented this from working, but once I solved that it deployed like a charm.

Anyway point is, Heroku seems about as easy or possibly easier than gh-pages for Ember app deployment; something to consider for future cohorts.

Need to confirm use of var, let, const in `config/environment.js`

see 315cf02

We're not yet sure if something in the browsers or Broccoli has changed that seems to allow us to deploy successfully using any of those declarations.

I went with keeping var to introduce less significant change and stick with what has worked up to this point. It may be perfectly okay to use const or let but we should confirm that officially before changing anything. The change made in the above commit allows us to keep ember-template the way it is while we confirm this or not as it pertains to deployment specifically.

Emphasize spelling and capitalization for (all, but especially) particular property names

851924d#diff-04c6e90faac2675aa89e2176d2eec7d8R29

In this general vicinity, I'd like to re-iterate that the spelling and capitalization of the following property names are crucial:

  • apiHost
  • rootURL

The above are correct. Many, many, many of my hours are lost in each cohort to people incorrectly using apiHosts and rootUrl (both of these are incorrect). The second one is especially pernicious, since @gaand has convinced me that rootUrl is correct by convention, and it is a fact that Ember disagrees.

Put apiHost in backtics

#### Important:

--Note that if you do not see the apiHost line, you will need to add it now as seen below.
+-Note that if you do not see the `apiHost:` line, you will need to add it now as seen below. 

Deployment Guide Lacks Instruction (see body)

The deployment guide lacks instructions about how to get the deployed ember application to talk to our deployed back end for CRUD actions and authentication actions. We handled this previously by running ember server --proxy address.

Format to match guide-template

Guide-template does not yet exist, but it should by the time someone other than me updates this.

As of right this moment, the express-api-deployment-guide matches the intended format closer than this before 016's update (reads much more like a check list)

Whoever closes this issue should open similar issues on the other guides, as long as the guide-template is completed.

dist/ is in global gitignore file

Heads up to other developers: you'll either need to comment out /dist from your global gitignore file (~/.gitignore) in addition to the .gitignore file in your gh-pages branch to track the dist directory here or forcibly add files within that directory to your repo (git add -f).

(This was an issue with deploying Rails apps to Heroku as well. It looks like this has already been addressed in the installfest.)

BaseUrl vs rootUrl

The updated rails API template has a different variable name for the baseUrl, supposed to be rootUrl

improve clarity with dist removal from gitignore

To avoid confusion.

Make explicitly clear that removing dist/ from .gitignore will make git start tracking it—which means the .gitignore change needs to be committed, as well as the dist/ directory that is no longer being ignored. This was an issue in 015 with some developers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.