-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from solo-io/charlesthebird/readOnlyFilesystemFix
Charlesthebird/read only filesystem fix
- Loading branch information
Showing
15 changed files
with
871 additions
and
21 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
**/node_modules/* | ||
*.local | ||
dist | ||
dist | ||
.DS_Store |
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
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,7 @@ | ||
changelog: | ||
- type: FIX | ||
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/18336 | ||
description: >- | ||
Adds a server with a view engine to the project, which only is used to | ||
serve the UI and insert configuration from environment variables. | ||
Also fixes a yarn audit issue with axios. |
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,33 @@ | ||
var express = require("express"); | ||
var path = require("path"); | ||
|
||
// Express and view engine setup | ||
var app = express(); | ||
app.set("views", path.join(__dirname, "public", "dist")); | ||
app.set("view engine", "ejs"); | ||
|
||
// The environment variables that we will pass through to the React app. | ||
var variablesInit = ` | ||
const insertedEnvironmentVariables = ${JSON.stringify( | ||
Object.fromEntries( | ||
Object.entries(process.env).filter(([key, _value]) => | ||
key.startsWith("VITE_") | ||
) | ||
) | ||
)}; | ||
`; | ||
|
||
// This renders the index.ejs file | ||
app.get("/", (_req, res) => { | ||
res.render("index.ejs", { VariablesInit: variablesInit }); | ||
}); | ||
|
||
// This serves all static assets. | ||
app.use(express.static(__dirname + "/public/dist")); | ||
|
||
// Any fallthrough routes go to index.ejs. | ||
app.get("*", (_req, res) => { | ||
res.render("index.ejs", { VariablesInit: variablesInit }); | ||
}); | ||
|
||
module.exports = app; |
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,89 @@ | ||
/** | ||
* This file was pulled from the Express generator's pug template, and does the following: | ||
* - Creates an http server on the requested port, using the Express app from `../app.js`. | ||
* - Adds some logging messages for different statuses. | ||
*/ | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var app = require("../app"); | ||
var http = require("http"); | ||
|
||
/** | ||
* Get port from environment and store in Express. | ||
*/ | ||
|
||
var port = normalizePort(process.env.PORT || "4000"); | ||
app.set("port", port); | ||
|
||
/** | ||
* Create HTTP server. | ||
*/ | ||
|
||
var server = http.createServer(app); | ||
|
||
/** | ||
* Listen on provided port, on all network interfaces. | ||
*/ | ||
|
||
server.listen(port); | ||
server.on("error", onError); | ||
server.on("listening", onListening); | ||
|
||
/** | ||
* Normalize a port into a number, string, or false. | ||
*/ | ||
|
||
function normalizePort(val) { | ||
var port = parseInt(val, 10); | ||
|
||
if (isNaN(port)) { | ||
// named pipe | ||
return val; | ||
} | ||
|
||
if (port >= 0) { | ||
// port number | ||
return port; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "error" event. | ||
*/ | ||
|
||
function onError(error) { | ||
if (error.syscall !== "listen") { | ||
throw error; | ||
} | ||
|
||
var bind = typeof port === "string" ? "Pipe " + port : "Port " + port; | ||
|
||
// handle specific listen errors with friendly messages | ||
switch (error.code) { | ||
case "EACCES": | ||
console.error(bind + " requires elevated privileges"); | ||
process.exit(1); | ||
break; | ||
case "EADDRINUSE": | ||
console.error(bind + " is already in use"); | ||
process.exit(1); | ||
break; | ||
default: | ||
throw error; | ||
} | ||
} | ||
|
||
/** | ||
* Event listener for HTTP server "listening" event. | ||
*/ | ||
|
||
function onListening() { | ||
var addr = server.address(); | ||
var bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port; | ||
console.log("Listening on " + bind); | ||
} |
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,15 @@ | ||
{ | ||
"name": "server", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "./bin/www", | ||
"scripts": { | ||
"start": "node ./bin/www" | ||
}, | ||
"dependencies": { | ||
"ejs": "^3.1.10", | ||
"express": "^4.19.2", | ||
"http": "^0.0.1-security", | ||
"path": "^0.12.7" | ||
} | ||
} |
Oops, something went wrong.