-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Heroku-based LHCI Server | ||
|
||
## Overview | ||
|
||
The LHCI server can be run in any node environment with persistent disk storage or network access to a postgres database. Heroku offers a [free tier of hosting](https://www.heroku.com/pricing) that provides exactly this! | ||
|
||
## Setting Up Your Repo | ||
|
||
```bash | ||
# Create a directory and repo for your heroku project | ||
mkdir lhci-heroku && cd lhci-heroku && git init | ||
# Setup the LHCI files | ||
curl https://raw.githubusercontent.com/GoogleChrome/lighthouse-ci/master/docs/recipes/heroku-server/package.json > package.json | ||
curl https://raw.githubusercontent.com/GoogleChrome/lighthouse-ci/master/docs/recipes/heroku-server/server.js > server.js | ||
# Create the project's first commit | ||
git add -A && git commit -m 'Initial commit' | ||
``` | ||
|
||
## Setting Up Heroku | ||
|
||
This assumes you've already signed up, created a heroku account, and installed the [heroku CLI](https://devcenter.heroku.com/articles/heroku-cli). | ||
|
||
```bash | ||
# Create a new project on heroku | ||
heroku create | ||
# Add a free database to your project | ||
heroku addons:create heroku-postgresql:hobby-dev | ||
# Deploy your code to heroku | ||
git push heroku master | ||
# Ensure heroku is running your app and open the URL | ||
heroku ps:scale web=1 | ||
heroku open | ||
``` | ||
|
||
## Updating LHCI | ||
|
||
Updates are made to the LHCI server from time to time and you'll want to keep up! You can update your LHCI server on Heroku just by pushing a commit. | ||
|
||
```bash | ||
# Update LHCI | ||
npm install --save @lhci/server@latest | ||
# Create a commit with your update | ||
git add -A && git commit -m 'update LHCI' | ||
# Deploy your update to heroku | ||
git push heroku master | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "lhci", | ||
"version": "1.0.0", | ||
"main": "server.js", | ||
"dependencies": { | ||
"@lhci/server": "0.3.x", | ||
"pg": "^7.12.1", | ||
"pg-hstore": "^2.3.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* @license Copyright 2019 Google Inc. All Rights Reserved. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | ||
*/ | ||
'use strict'; | ||
|
||
const {createServer} = require('@lhci/server'); | ||
|
||
console.log('Starting server...'); | ||
createServer({ | ||
port: process.env.PORT, | ||
storage: { | ||
storageMethod: 'sql', | ||
sqlDialect: 'postgres', | ||
sqlConnectionSsl: true, | ||
sqlConnectionUrl: process.env.DATABASE_URL, | ||
}, | ||
}).then(({port}) => console.log('Listening on port', port)); |