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

Adds Default Connection Support #108

Merged
merged 25 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c553c99
add acceptance of config file for default connection in the docker ru…
May 9, 2023
2f6043f
add FE support to accept default connection
May 11, 2023
e430197
Add support for providing connection details through docker --env var…
May 12, 2023
cf07a96
Build app during build time and add https environment variable to run…
Jun 1, 2023
f1d17a8
Fix README
Jun 1, 2023
f950b23
Bug fix for Adding default configuration when no graph_connection_url…
Jun 8, 2023
695734a
Fix container failing to start when PROXY_SERVER_HTTPS_CONNECTION is …
michaelnchin Jun 21, 2023
7844020
Update node version in git workflow to fix pnpm install errors
jackson-millard Jul 7, 2023
126b061
Merge branch 'AddDefaultConfiguration' of https://github.com/jackson-…
jackson-millard Jul 7, 2023
18cb0c4
Merge in latest
jackson-millard Jul 7, 2023
99fa172
Update docker-entrypoint.sh
michaelnchin Jul 18, 2023
64befe7
Accept GRAPH_EXP_HTTPS_CONNECTION setting on run, enforce default for…
michaelnchin Jul 19, 2023
3d2fc99
feat: docker ignore node_modules to avoid issues with Esbuild switchi…
agutierrezgit Jul 26, 2023
b686a8d
feat: update graph type name to match with translations used in the r…
agutierrezgit Jul 26, 2023
f7aa6da
feat: add GRAPH_EXP_HTTPS_CONNECTION attribute and format markdown
agutierrezgit Jul 26, 2023
c2a63b3
feat: add readOnly prop to connection config
agutierrezgit Jul 26, 2023
c8fbd05
feat: make file config readonly by default unless indicated otherwise
agutierrezgit Jul 26, 2023
83b65e4
feat: grab config refactor to fix syntax error when defaultConnection…
agutierrezgit Jul 26, 2023
8682d4f
feat: disable edit for read-only configurations
agutierrezgit Jul 26, 2023
12cefa7
feat: create multiple default connections when graph type is not spec…
agutierrezgit Jul 28, 2023
2405126
Merge pull request #1 from jackson-millard/agutierrez/AddDefaultConfi…
agutierrezgit Jul 31, 2023
056b692
Merge remote-tracking branch 'upstream/main' into AddDefaultConfigura…
michaelnchin Aug 2, 2023
505fa6f
Merge branch 'main' of https://github.com/aws/graph-explorer into Add…
michaelnchin Aug 9, 2023
c392caf
update changelog
michaelnchin Aug 9, 2023
794352f
Merge branch 'main' into AddDefaultConfiguration
michaelnchin Aug 15, 2023
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
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ COPY . /graph-explorer/
WORKDIR /graph-explorer
# Keeping all the RUN commands on a single line reduces the number of layers and,
# as a result, significantly reduces the final image size.
RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash - && yum install -y nodejs openssl && npm install -g pnpm && pnpm install && rm -rf /var/cache/yum
RUN curl -sL https://rpm.nodesource.com/setup_16.x | bash - && yum install -y nodejs openssl && npm install -g pnpm && pnpm install && rm -rf /var/cache/yum && chmod a+x ./process-environment.sh
WORKDIR /graph-explorer/
ENV HOME=/graph-explorer
RUN pnpm build
EXPOSE 443
EXPOSE 80
RUN chmod a+x ./docker-entrypoint.sh
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,37 @@ You can search, browse, expand, customize views of your graph data using Graph E
## Connections
The Graph Explorer supports visualizing both **property graphs** and **RDF graphs**. You can connect to Amazon Neptune or you can also connect to open graph databases that implement an Apache TinkerPop Gremlin Server endpoint or the SPARQL 1.1 protocol, such as Blazegraph. For additional details on connecting to different graph databases, see [Connections](./additionaldocs/connections.md).

### Providing a Default Connection
To provide a default connection such that initial loads of the graph explorer always result with the same starting connection, modify the `docker run ...` command to either take in a json configuration or runtime environment variables. A json configuration approach would look like `docker run -p 80:80 -p 443:443 --env HOST={hostname-or-ip-address} -v /path/to/config.json:/graph-explorer/config.json graph-explorer` or create a `config.json` file at the root of the project. An environment variable approach would look like `docker run -p 80:80 -p 443:443 --env HOST={hostname-or-ip-address} --env PUBLIC_OR_PROXY_ENDPOINT=https://public-endpoint --env GRAPH_TYPE=gremlin --env USING_PROXY_SERVER=true --env IAM=false --env GRAPH_CONNECTION_URL=https://cluster-cqmizgqgrsbf.us-west-2.neptune.amazonaws.com:8182 --env AWS_REGION=us-west-2 graph-explorer`. IF you provide both, the json approach will be prioritized.


The set of valid ENV connection variables and their defaults:
* Required:
* PUBLIC_OR_PROXY_ENDPOINT - None
* Optional
* GRAPH_TYPE - PG (Property Graph)
* USING_PROXY_SERVER - False
* IAM - False
* Conditionally Required:
* GRAPH_CONNECTION_URL - None
* Required if USING_PROXY_SERVER=True
* AWS_REGION - None
* Required if USING_PROXY_SERVER=True and IAM=True


The config.json file should provide values for the attributes at the top level as in the example below:

```
{
"PUBLIC_OR_PROXY_ENDPOINT": "https://public-endpoint",
"GRAPH_CONNECTION_URL": "https://cluster-cqmizgqgrsbf.us-west-2.neptune.amazonaws.com:8182",
"USING_PROXY_SERVER": true, (Can be string or boolean)
"IAM": true, (Can be string or boolean)
"AWS_REGION": "us-west-2",
"GRAPH_TYPE": "gremlin" (Possible Values: "gremlin" or "sparql")
}
```

## Development
For development guidance, see [Development](./additionaldocs/development.md).

Expand Down
5 changes: 5 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

./process-environment.sh

if [ $(grep -e 'GRAPH_EXP_HTTPS_CONNECTION' ./packages/graph-explorer/.env | cut -d "=" -f 2) ]; then

if [ $HOST ]; then
Expand All @@ -25,5 +27,8 @@ else
echo "SSL disabled. Skipping self-signed certificate generation."
exit 1
fi

echo "Building graph explorer..."
pnpm -w build
echo "Starting graph explorer..."
pnpm -w start:proxy-server
12 changes: 6 additions & 6 deletions packages/graph-explorer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ if (params.configFile) {
import.meta.env.GRAPH_EXP_CONNECTION_NAME ||
import.meta.env.GRAPH_EXP_CONNECTION_URL,
connection: {
url: import.meta.env.GRAPH_EXP_CONNECTION_URL,
queryEngine:
(import.meta.env.GRAPH_EXP_CONNECTION_ENGINE as
| "gremlin"
| "sparql"
| undefined) || "gremlin",
url: import.meta.env.GRAPH_EXP_PUBLIC_OR_PROXY_ENDPOINT || "",
queryEngine: (import.meta.env.GRAPH_EXP_GRAPH_TYPE.toLowerCase() === "gremlin" || import.meta.env.GRAPH_EXP_GRAPH_TYPE.toLowerCase() === "sparql") ? import.meta.env.GRAPH_EXP_GRAPH_TYPE.toLowerCase() : "gremlin",
proxyConnection: (import.meta.env.GRAPH_EXP_USING_PROXY_SERVER.toUpperCase() === "TRUE") ? true : false,
graphDbUrl: import.meta.env.GRAPH_EXP_CONNECTION_URL || "",
awsAuthEnabled: (import.meta.env.GRAPH_EXP_IAM.toUpperCase() === "TRUE") ? true : false,
awsRegion: import.meta.env.GRAPH_EXP_AWS_REGION || "",
},
};
}
Expand Down
39 changes: 39 additions & 0 deletions process-environment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

if [ -f "./config.json" ]; then

json=$(cat ./config.json)

PUBLIC_OR_PROXY_ENDPOINT=$(echo "$json" | grep -o '"PUBLIC_OR_PROXY_ENDPOINT":[^,}]*' | cut -d '"' -f 4)
GRAPH_TYPE=$(echo "$json" | grep -o '"GRAPH_TYPE":[^,}]*' | cut -d '"' -f 4)
USING_PROXY_SERVER=$(echo "$json" | grep -o '"USING_PROXY_SERVER":[^,}]*' | cut -d ':' -f 2 | tr -d '[:space:]' | sed 's/"//g')
IAM=$(echo "$json" | grep -o '"IAM":[^,}]*' | cut -d ':' -f 2 | tr -d '[:space:]' | sed 's/"//g')
GRAPH_CONNECTION_URL=$(echo "$json" | grep -o '"CONNECTION_URL":[^,}]*' | cut -d '"' -f 4)
AWS_REGION=$(echo "$json" | grep -o '"AWS_REGION":[^,}]*' | cut -d '"' -f 4)
fi

# Update the .env file with the configuration values
if [ -n "$PUBLIC_OR_PROXY_ENDPOINT" ]; then
echo -e "\nGRAPH_EXP_PUBLIC_OR_PROXY_ENDPOINT=${PUBLIC_OR_PROXY_ENDPOINT}" >> ./packages/graph-explorer/.env

if [ -n "$GRAPH_TYPE" ]; then
echo "GRAPH_EXP_GRAPH_TYPE=${GRAPH_TYPE}" >> ./packages/graph-explorer/.env
else
echo "GRAPH_EXP_GRAPH_TYPE=PG" >> ./packages/graph-explorer/.env
fi

if [ -n "$USING_PROXY_SERVER" ]; then
echo "GRAPH_EXP_USING_PROXY_SERVER=${USING_PROXY_SERVER}" >> ./packages/graph-explorer/.env
else
echo "GRAPH_EXP_USING_PROXY_SERVER=false" >> ./packages/graph-explorer/.env
fi

if [ -n "$IAM" ]; then
echo "GRAPH_EXP_IAM=${IAM}" >> ./packages/graph-explorer/.env
else
echo "GRAPH_EXP_IAM=false" >> ./packages/graph-explorer/.env
fi

echo "GRAPH_EXP_CONNECTION_URL=${GRAPH_CONNECTION_URL}" >> ./packages/graph-explorer/.env
echo "GRAPH_EXP_AWS_REGION=${AWS_REGION}" >> ./packages/graph-explorer/.env
fi