Edgio

Fastboot

This guide shows you how to deploy an Ember Fastboot application to Edgio.

Example

System Requirements

Install Node.js

Sign up for Edgio

Deploying requires an account on Edgio. Sign up here for free.

Getting Started

To prepare your Fastboot app for deployment on the Edgio, run the following command in the root folder of your project:
Bash
1npm i -g @layer0/cli # yarn global add @layer0/cli
20 init
This will automatically add all of the required dependencies and files to your project. These include:
  • The 0/core package - Allows you to declare routes and deploy your application on Edgio
  • The 0/fastboot package - Provides router middleware that automatically adds Fastboot routes to the Edgio router.
  • The 0/prefetch package - Allows you to configure a service worker to prefetch and cache pages to improve browsing speed
  • The 0/react package - Provides a Prefetch component for prefetching pages
  • routes.js - A default routes file that sends all requests to Fastboot. Update this file to add caching or proxy some URLs to a different origin.
  • sw/service-worker.js - The source code for your service worker, which enables prefetching when running on Edgio.
  • layer0.config.js - Contains configuration options for deploying on Edgio.

Adding Edgio Service Worker

To add Edgio service worker to your app, call the install function from 0/prefetch/window hook when the app first loads. For example, you can alter app/app.js as follows:
JavaScript
1import Application from '@ember/application'
2import Resolver from 'ember-resolver'
3import loadInitializers from 'ember-load-initializers'
4import config from './config/environment'
5
6// add this to import Edgio service worker prefetching functionality
7import { install } from '@layer0/prefetch/window'
8
9export default class App extends Application {
10 modulePrefix = config.modulePrefix
11 podModulePrefix = config.podModulePrefix
12 Resolver = Resolver
13}
14
15loadInitializers(App, config.modulePrefix)
16
17// add this to install the service worker when your app loads
18if (typeof navigator != 'undefined') {
19 install()
20}

dependencies vs devDependencies

To reduce serverless cold-start times, limit the packages listed in the dependencies section of your package.json to only those packages used at runtime. The 0/fastboot package must also be included in dependencies. Other packages not used at runtime should be included in devDependencies. Only those packages listed in dependencies are deployed to Edgio along with your application code.

layer0.config.js

Ember fastboot apps should always have the following in layer0.config.js:
JavaScript/layer0.config.js
1module.exports = {
2 connector: '@layer0/fastboot',
3 includeNodeModules: true, // this ensures that package.json dependencies are uploaded to the cloud
4}

Running Locally

Test your app with the Sites on your local machine by running the following command in your project’s root directory:
Bash
10 dev

Simulate edge caching locally

To simulate edge caching locally, run:
Bash
10 dev --cache

Deploying

Deploy your app to the Sites by running the following command in your project’s root directory:
Bash
10 deploy
See deploying for more information.