Skip to content
This repository was archived by the owner on Jul 8, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builder/Dockerfile.headless
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ RUN yarn install
COPY server.js /
RUN chmod +x /server.js

# Expose port 8080
EXPOSE 8080
# Expose port 8085
EXPOSE 8085

## PART 4: Final setup
## ===================
Expand Down
4 changes: 2 additions & 2 deletions builder/Dockerfile.nonheadless
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ RUN yarn install
COPY server.js /
RUN chmod +x /server.js

# Expose port 8080
EXPOSE 8080
# Expose port 8085
EXPOSE 8085

## PART 4: Final setup
## ===================
Expand Down
7 changes: 7 additions & 0 deletions builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ curl -X POST \
https://builder-dot-lighthouse-ci.appspot.com/ci
```

```bash
curl -i \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X GET 'https://builder-dot-lighthouse-ci.appspot.com/stream?format=json&url=https://staging.example.com'
```

where `format` is one of `json`, `html`.
1 change: 1 addition & 0 deletions builder/chromeuser-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
nohup google-chrome \
--headless \
--disable-gpu \
--no-sandbox \
--remote-debugging-port=9222 'about:blank' &
2 changes: 1 addition & 1 deletion builder/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# docker build -t lighthouse_ci . --build-arg CACHEBUST=$(date +%d)

# Build for non-headless Chrome version.
docker build -f Dockerfile.nonheadless -t lighthouse_ci . --build-arg CACHEBUST=$(date +%d)
docker build -f Dockerfile.headless -t lighthouse_ci . --build-arg CACHEBUST=$(date +%d)
2 changes: 1 addition & 1 deletion builder/docker_run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

docker run -d -p 8080:8080 --cap-add=SYS_ADMIN lighthouse_ci
docker run -it -p 8085:8085 --cap-add=SYS_ADMIN lighthouse_ci
9 changes: 5 additions & 4 deletions builder/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const spawn = require('child_process').spawn;
const bodyParser = require('body-parser');

const API_KEY_HEADER = 'X-API-KEY';
const PORT = 8080;
const PORT = 8085;

// Handler for CI.
function runLH(url, format = 'domhtml', res, next) {
Expand All @@ -17,8 +17,9 @@ function runLH(url, format = 'domhtml', res, next) {

const extension = format === 'domhtml' ? 'html' : format;
const file = `report.${Date.now()}.${extension}`;
const fileSavePath = './reports/';

const args = [`--output-path=${file}`, `--output=${format}`, '--port=9222'];
const args = [`--output-path=${fileSavePath + file}`, `--output=${format}`, '--port=9222'];
const child = spawn('lighthouse', [...args, url]);

child.stderr.on('data', data => {
Expand Down Expand Up @@ -61,7 +62,7 @@ function runLighthouseAsEventStream(req, res, next) {
const args = [`--output-path=${fileSavePath + file}`, `--output=${format}`, '--port=9222'];
const child = spawn('lighthouse', [...args, url]);

let log = '';
let log = 'lighthouse ' + args.join(' ') + ' ' + url + '\n';

child.stderr.on('data', data => {
const str = data.toString();
Expand All @@ -70,7 +71,7 @@ function runLighthouseAsEventStream(req, res, next) {
});

child.on('close', statusCode => {
const serverOrigin = `https://${req.host}/`;
const serverOrigin = `http://${req.host}:${PORT}/`;
res.write(`data: done ${serverOrigin + file}\n\n`);
res.status(410).end();
console.log(log);
Expand Down
2 changes: 1 addition & 1 deletion frontend/public/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const startOver = document.querySelector('#startover');
// const params = new URLSearchParams(location.search);
// let setTimeoutId_;
const ENDPOINT_ORIGIN = location.hostname === 'localhost' ?
'http://localhost:8080' : 'https://builder-dot-lighthouse-ci.appspot.com';
'http://localhost:8085' : 'https://builder-dot-lighthouse-ci.appspot.com';

// /**
// * @param {number} score
Expand Down
2 changes: 1 addition & 1 deletion frontend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ app.post('/run_on_chrome', async (req, res) => {
// });
// });

const PORT = process.env.PORT || 8080;
const PORT = process.env.PORT || 8085;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
Expand Down