Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate to one server #52

Merged
merged 5 commits into from
Feb 21, 2023
Merged
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
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ 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`.

### Steps to install Graph Explorer:

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.
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.
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 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.

Expand Down
13 changes: 8 additions & 5 deletions packages/graph-explorer-proxy-server/node-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 credentials;
Expand All @@ -31,13 +32,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, "../graph-explorer/dist")));

const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));

async function retryFetch (
Expand Down Expand Up @@ -179,12 +182,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`);
});
}
})();
3 changes: 2 additions & 1 deletion packages/graph-explorer/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
PROXY_SERVER_HTTPS_CONNECTION=true
GRAPH_EXP_HTTPS_CONNECTION=true
GRAPH_EXP_HTTPS_CONNECTION=true
GRAPH_EXP_ENV_ROOT_FOLDER=/explorer