Skip to content

Commit

Permalink
Demo-app: Nginx to Node.js
Browse files Browse the repository at this point in the history
  • Loading branch information
gilhanan committed Feb 5, 2024
1 parent a9f8e80 commit e08bf4b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 12 deletions.
1 change: 1 addition & 0 deletions demo-app/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deployment/
7 changes: 5 additions & 2 deletions demo-app/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
FROM nginx
COPY index.html /usr/share/nginx/html
FROM node:18-bullseye-slim

COPY . .

CMD [ "node", "server.js" ]
2 changes: 1 addition & 1 deletion demo-app/deployment/container-app.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource containerApp 'Microsoft.App/containerapps@2023-05-02-preview' = {
activeRevisionsMode: 'multiple'
ingress: {
external: true
targetPort: 80
targetPort: 3000
traffic: productionRevision == 'none' ? [
{
latestRevision: true
Expand Down
19 changes: 11 additions & 8 deletions demo-app/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
Expand All @@ -9,13 +10,15 @@
<title>Lighthouse CI Demo App</title>
</head>
<body>
<h1>Lighthouse CI on Microsoft Azure</h1>
<p>
This Demo page used to run
<a target="_blank" href="https://github.com/gilhanan/lhci-azure">
Lighthouse CI
</a>
audits on it.
</p>
<main>
<h1>Lighthouse CI on Microsoft Azure</h1>
<p>
This Demo page used to run
<a target="_blank" href="https://github.com/gilhanan/lhci-azure">
Lighthouse CI
</a>
audits on it.
</p>
</main>
</body>
</html>
2 changes: 2 additions & 0 deletions demo-app/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /
28 changes: 28 additions & 0 deletions demo-app/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { createServer } = require("node:http");
const { createReadStream } = require("node:fs");
const { pipeline } = require("node:stream");

const { PORT = 3000 } = process.env;

const router = {
"/robots.txt": {
headers: { "Content-Type": "text/plain" },
file: "robots.txt",
},
};

const index = {
headers: {
"Content-Type": "text/html",
"Content-Security-Policy": "default-src 'none'",
},
file: "index.html",
};

createServer((request, response) => {
const { headers, file } = router[request.url] || index;
response.writeHead(200, headers);
pipeline(createReadStream(file), response, () => {});
}).listen(PORT, () => {
console.log(`Server running at http://localhost:${PORT}/`);
});
3 changes: 2 additions & 1 deletion lighthouse-ci/client/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.lighthouseci
3 changes: 3 additions & 0 deletions lighthouse-ci/client/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module.exports = {
chromeFlags: "--no-sandbox --disable-dev-shm-usage",
},
},
assert: {
preset: "lighthouse:no-pwa",
},
upload: {
target: "lhci",
serverBaseUrl: LHCI_SERVER,
Expand Down

0 comments on commit e08bf4b

Please sign in to comment.