From d7aed751a2a911dc52b055ff788aa6791032c530 Mon Sep 17 00:00:00 2001 From: Jackson Millard Date: Mon, 6 Feb 2023 12:58:12 -0600 Subject: [PATCH 1/3] consolidate to one server --- Dockerfile | 7 ++++--- README.md | 2 +- packages/graph-explorer-proxy-server/node-server.js | 13 ++++++++----- packages/graph-explorer/.env | 3 ++- packages/graph-explorer/package.json | 1 + 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 646381fea..9be5fbe38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,6 +21,7 @@ RUN openssl x509 -req -in ./server.csr -CA ./rootCA.crt -CAkey ./rootCA.key -CAc ### END CERT CREATION WORKDIR /graph-explorer/ ENV HOME=/graph-explorer -EXPOSE 5173 -EXPOSE 8182 -CMD ["pnpm", "dev"] +RUN pnpm build +EXPOSE 443 +EXPOSE 80 +CMD ["pnpm", "start:proxy-server"] diff --git a/README.md b/README.md index 246158335..8b5bb2722 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ There are many ways to deploy the Graph Explorer application. The following inst 1. To download the source project, run `git clone https://github.com/aws/graph-explorer/`. Navigate to the newly created `graph-explorer` directory. 2. To build the image, run `docker build --build-arg host={hostname-or-ip-address} -t graph-explorer .` from the root directory. If you receive an error relating to the docker service not running, run `service docker start`. -3. Run `docker run -p 5173:5173 -p 8182:8182 graph-explorer` to run the docker container. +3. Run `docker run -p 80:80 -p 443:443 graph-explorer` to run the docker container. 4. Now, open a browser and type in the public URL of your EC2 instance on port `5173` (e.g., `https://ec2-1-2-3-4.us-east-1.compute.amazonaws.com:5173`). You will receive a warning as the SSL certificate used is self-signed. 5. Since the application is set to use HTTPS by default and contains a self-signed certificate, you will need to add the Graph Explorer certificates to the trusted certificates directory and manually trust them. See [HTTPS Connections](#https-connections) section. 6. After completing the trusted certification step and refreshing the browser, you should now see the Connections UI. See below description on Connections UI to configure your first connection to Amazon Neptune. diff --git a/packages/graph-explorer-proxy-server/node-server.js b/packages/graph-explorer-proxy-server/node-server.js index 738823a93..d47a5ee0b 100644 --- a/packages/graph-explorer-proxy-server/node-server.js +++ b/packages/graph-explorer-proxy-server/node-server.js @@ -8,6 +8,7 @@ const AWS = require("aws-sdk"); const { RequestSig } = require("./RequestSig.js"); const https = require("https"); const fs = require("fs"); +const path = require("path"); const getCredentials = async () => { let accessKey = ""; @@ -36,13 +37,15 @@ const getCredentials = async () => { }; dotenv.config({ path: "../graph-explorer/.env" }); - + (async () => { let creds = await getCredentials(); let requestSig; app.use(cors()); + app.use("/explorer", express.static(path.join(__dirname, "dist"))); + async function getRequestObjects(endpoint_input, region_input) { if (endpoint_input) { endpoint_url = new URL(endpoint_input); @@ -143,12 +146,12 @@ dotenv.config({ path: "../graph-explorer/.env" }); }, app ) - .listen(8182, async () => { - console.log(`\tProxy server located at https://localhost:8182`); + .listen(443, async () => { + console.log(`\tProxy server located at https://localhost`); }); } else { - app.listen(8182, async () => { - console.log(`\tProxy server located at http://localhost:8182`); + app.listen(80, async () => { + console.log(`\tProxy server located at http://localhost`); }); } })(); diff --git a/packages/graph-explorer/.env b/packages/graph-explorer/.env index 2629d8276..367fb74e2 100644 --- a/packages/graph-explorer/.env +++ b/packages/graph-explorer/.env @@ -1,2 +1,3 @@ PROXY_SERVER_HTTPS_CONNECTION=true -GRAPH_EXP_HTTPS_CONNECTION=true \ No newline at end of file +GRAPH_EXP_HTTPS_CONNECTION=true +GRAPH_EXP_ENV_ROOT_FOLDER=/explorer \ No newline at end of file diff --git a/packages/graph-explorer/package.json b/packages/graph-explorer/package.json index 14cc56f52..12002a4b4 100644 --- a/packages/graph-explorer/package.json +++ b/packages/graph-explorer/package.json @@ -6,6 +6,7 @@ "engines": { "node": ">=16.15.1" }, + "type": "module", "scripts": { "format": "prettier --write './src/**/*.{css,ts,tsx}'", "lint": "eslint src --fix", From b1fe24fab256772e777f87e4c3b5f2d2b95afc4a Mon Sep 17 00:00:00 2001 From: Jackson Millard Date: Wed, 8 Feb 2023 15:13:42 -0600 Subject: [PATCH 2/3] remove typo in package.json --- packages/graph-explorer/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/graph-explorer/package.json b/packages/graph-explorer/package.json index 12002a4b4..14cc56f52 100644 --- a/packages/graph-explorer/package.json +++ b/packages/graph-explorer/package.json @@ -6,7 +6,6 @@ "engines": { "node": ">=16.15.1" }, - "type": "module", "scripts": { "format": "prettier --write './src/**/*.{css,ts,tsx}'", "lint": "eslint src --fix", From f7d84ff665fbaf462dddd66c3b79e5a97a823e4c Mon Sep 17 00:00:00 2001 From: Jackson Millard Date: Thu, 9 Feb 2023 10:48:29 -0600 Subject: [PATCH 3/3] Update README and add missing piece to static path --- README.md | 6 +++--- packages/graph-explorer-proxy-server/node-server.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 8b5bb2722..b4ee3112d 100644 --- a/README.md +++ b/README.md @@ -8,14 +8,14 @@ To get started, you can deploy Graph Explorer on a local machine using [Docker D ## Getting Started -This project contains the code needed to create a Docker image of the Graph Explorer. The image will create the Graph Explorer application to communicate through port `5173` and a proxy server through port `8182`. The proxy server will be created automatically, but will only be necessary if you are connecting to Neptune. Gremlin-Server and BlazeGraph can be connected to directly. Additionally, the image will create a self-signed certificate that can be optionally used. +This project contains the code needed to create a Docker image of the Graph Explorer. The image will create the Graph Explorer application and proxy server that will be served over the standard HTTP or HTTPS ports (HTTPS by default). The proxy server will be created automatically, but will only be necessary if you are connecting to Neptune. Gremlin-Server and BlazeGraph can be connected to directly. Additionally, the image will create a self-signed certificate that can be optionally used. There are many ways to deploy the Graph Explorer application. The following instructions detail how to deploy graph-explorer onto an Amazon EC2 instance and use it as a proxy server with SSH tunneling to connect to Amazon Neptune. Note that this README is not an official recommendation on network setups as there are many ways to connect to Amazon Neptune from outside of the VPC, such as setting up a load balancer or VPC peering. ### Prerequisites: * Provision an Amazon EC2 instance that will be used to host the application and connect to Neptune as a proxy server. For more details, see instructions [here](https://github.com/aws/graph-notebook/tree/main/additional-databases/neptune). -* Ensure the Amazon EC2 instance can send and receive on ports `22` (SSH), `8182` (Neptune), and `5173` (graph-explorer). +* Ensure the Amazon EC2 instance can send and receive on ports `22` (SSH), `8182` (Neptune), and `443` or `80` depending on protocol used (graph-explorer). * Open an SSH client and connect to the EC2 instance. * Download and install the necessary command line tools such as `git` and `docker`. @@ -24,7 +24,7 @@ There are many ways to deploy the Graph Explorer application. The following inst 1. To download the source project, run `git clone https://github.com/aws/graph-explorer/`. Navigate to the newly created `graph-explorer` directory. 2. To build the image, run `docker build --build-arg host={hostname-or-ip-address} -t graph-explorer .` from the root directory. If you receive an error relating to the docker service not running, run `service docker start`. 3. Run `docker run -p 80:80 -p 443:443 graph-explorer` to run the docker container. -4. Now, open a browser and type in the public URL of your EC2 instance on port `5173` (e.g., `https://ec2-1-2-3-4.us-east-1.compute.amazonaws.com:5173`). You will receive a warning as the SSL certificate used is self-signed. +4. Now, open a browser and type in the public URL of your EC2 instance accessing the explorer endpoint (e.g., `https://ec2-1-2-3-4.us-east-1.compute.amazonaws.com/explorer`). You will receive a warning as the SSL certificate used is self-signed. 5. Since the application is set to use HTTPS by default and contains a self-signed certificate, you will need to add the Graph Explorer certificates to the trusted certificates directory and manually trust them. See [HTTPS Connections](#https-connections) section. 6. After completing the trusted certification step and refreshing the browser, you should now see the Connections UI. See below description on Connections UI to configure your first connection to Amazon Neptune. diff --git a/packages/graph-explorer-proxy-server/node-server.js b/packages/graph-explorer-proxy-server/node-server.js index d47a5ee0b..822cad338 100644 --- a/packages/graph-explorer-proxy-server/node-server.js +++ b/packages/graph-explorer-proxy-server/node-server.js @@ -44,7 +44,7 @@ dotenv.config({ path: "../graph-explorer/.env" }); app.use(cors()); - app.use("/explorer", express.static(path.join(__dirname, "dist"))); + app.use("/explorer", express.static(path.join(__dirname, "../graph-explorer/dist"))); async function getRequestObjects(endpoint_input, region_input) { if (endpoint_input) {