From 25a802fd916bc1a7577a3ff5a3b0afd5f11bb3b8 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Mon, 10 Jun 2024 10:18:31 +0200 Subject: [PATCH 1/5] chore: fix indentation in the nginx.conf file --- nginx.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nginx.conf b/nginx.conf index 8ab6874..2a47757 100644 --- a/nginx.conf +++ b/nginx.conf @@ -3,11 +3,11 @@ http { include /etc/nginx/mime.types; server{ - listen 80; - root /app; - index index.html; - location / { - try_files $uri$args $uri$args/ /index.html; - } + listen 80; + root /app; + index index.html; + location / { + try_files $uri$args $uri$args/ /index.html; + } } } From ccf021c301684d8509968c43db4e32e87e3e16bb Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Mon, 10 Jun 2024 11:25:31 +0200 Subject: [PATCH 2/5] docker: upgrade nginx to 1.27.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 03ae642..df11f8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ RUN sed -i "s//${VERSION}/" ./projects/blueprint/src/build/build.ts RUN npm run build blueprint # Second step: serve the builded app -FROM nginx:1.23.4-alpine +FROM nginx:1.27.0-alpine RUN mkdir -p /app WORKDIR /app From 2767d126514d62bcc11a24bfcd65b2df6bb55cde Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Mon, 10 Jun 2024 12:36:13 +0200 Subject: [PATCH 3/5] docker: add custom entrypoint script --- Dockerfile | 5 +++++ entrypoint.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index df11f8d..e9801c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,9 +16,14 @@ RUN npm run build blueprint # Second step: serve the builded app FROM nginx:1.27.0-alpine +# Install some tools +RUN apk add --no-cache jq + RUN mkdir -p /app WORKDIR /app COPY nginx.conf /etc/nginx/nginx.conf +COPY entrypoint.sh /docker-entrypoint.d/00-blueprint-entrypoint.sh +RUN chmod +x /docker-entrypoint.d/00-blueprint-entrypoint.sh COPY --from=builder /app/dist/blueprint/browser/ . EXPOSE 80 diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..2e11b18 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,60 @@ +#!/bin/sh + +################################################################## +# Check for required environment variables # +# In case they are not set, use default config.json file instead # +################################################################## + +if [ -z "${ENDPOINT_URL}" ]; then + echo "ENDPOINT_URL is not set, let's keep the current config.json file." + exit 0 +fi + +if [ -z "${SPARQL_CONSOLE_URL}" ]; then + echo "SPARQL_CONSOLE_URL is not set, let's keep the current config.json file." + exit 0 +fi + +if [ -z "${GRAPH_EXPLORER_URL}" ]; then + echo "GRAPH_EXPLORER_URL is not set, let's keep the current config.json file." + exit 0 +fi + +######################################################### +# Set default values for optional environment variables # +######################################################### + +if [ -z "${FULL_TEXT_SEARCH_DIALECT}" ]; then + echo "FULL_TEXT_SEARCH_DIALECT is not set, let's use 'fuseki' as default value." + FULL_TEXT_SEARCH_DIALECT="fuseki" +fi + +if [ -z "${NEPTUNE_FTS_ENDPOINT}" ]; then + # Check if the full-text search endpoint is set to "neptune", and only display the warning message in this case + if [ "${FULL_TEXT_SEARCH_DIALECT}" = "neptune" ]; then + echo "NEPTUNE_FTS_ENDPOINT is not set, let's use 'http://example.com/' as default value." + fi + NEPTUNE_FTS_ENDPOINT="http://example.com/" +fi + +######################################################## +# Generate config.json file from environment variables # +######################################################## + +jq -n \ + --arg endpointUrl "${ENDPOINT_URL}" \ + --arg sparqlConsoleUrl "${SPARQL_CONSOLE_URL}" \ + --arg graphExplorerUrl "${GRAPH_EXPLORER_URL}" \ + --arg fullTextSearchDialect "${FULL_TEXT_SEARCH_DIALECT}" \ + --arg ftsEndpoint "${NEPTUNE_FTS_ENDPOINT}" \ + '{ + "endpointUrl": $endpointUrl, + "sparqlConsoleUrl": $sparqlConsoleUrl, + "graphExplorerUrl": $graphExplorerUrl, + "fullTextSearchDialect": $fullTextSearchDialect, + "neptune": { + "ftsEndpoint": $ftsEndpoint + } + }' > /app/dist/blueprint/browser/config.json + +exit 0 From 56327a1fc3c2ca736974b782c617e0a4649b88a7 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Mon, 10 Jun 2024 13:01:09 +0200 Subject: [PATCH 4/5] docs: env vars --- README.md | 28 ++++++++++++++++++++++++++++ entrypoint.sh | 25 ++++++++++++++++--------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 35ed92a..24a18c3 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,34 @@ In case you are using the `neptune` dialect you need to provide the OpenSearch e } ``` +## Using Docker + +You can use our Docker image to run Blueprint. + +```sh +docker pull ghcr.io/zazuko/blueprint:latest +``` + +It will listen on port 80. + +The following environment variables can be set: + +- `ENDPOINT_URL`: the SPARQL endpoint URL (required) +- `SPARQL_CONSOLE_URL`: the SPARQL console URL (default placeholder value: `http://example.com/sparql/#query`) +- `GRAPH_EXPLORER_URL`: the Graph Explorer URL (default placeholder value: `http://example.com/graph-explorer/?resource`) +- `FULL_TEXT_SEARCH_DIALECT`: the full text search dialect (default value: `fuseki`) +- `NEPTUNE_FTS_ENDPOINT`: the OpenSearch endpoint for the Neptune dialect (in case you are using `neptune` dialect) + +If any of the required environment variables are not set, the container will be started using the development configuration. + +You can also mount a custom configuration file to `/app/config.json`. + +You should make sure that `ENDPOINT_URL`, `SPARQL_CONSOLE_URL` and `GRAPH_EXPLORER_URL` are reachable from the browser. +Make sure that `ENDPOINT_URL` is configured to allow CORS requests. + +You can use [Trifid](https://github.com/zazuko/trifid) to proxy any SPARQL endpoint and to expose a SPARQL console and Graph Explorer. +You can also use it to dereference URIs. + ## Development ### Configuration diff --git a/entrypoint.sh b/entrypoint.sh index 2e11b18..c79c5bb 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -10,20 +10,20 @@ if [ -z "${ENDPOINT_URL}" ]; then exit 0 fi +######################################################### +# Set default values for optional environment variables # +######################################################### + if [ -z "${SPARQL_CONSOLE_URL}" ]; then - echo "SPARQL_CONSOLE_URL is not set, let's keep the current config.json file." - exit 0 + echo "SPARQL_CONSOLE_URL is not set, let's use 'http://example.com/sparql/#query' as default value." + SPARQL_CONSOLE_URL="http://example.com/sparql/#query" fi if [ -z "${GRAPH_EXPLORER_URL}" ]; then - echo "GRAPH_EXPLORER_URL is not set, let's keep the current config.json file." - exit 0 + echo "GRAPH_EXPLORER_URL is not set, let's use 'http://example.com/graph-explorer/?resource' as default value." + GRAPH_EXPLORER_URL="http://example.com/graph-explorer/?resource" fi -######################################################### -# Set default values for optional environment variables # -######################################################### - if [ -z "${FULL_TEXT_SEARCH_DIALECT}" ]; then echo "FULL_TEXT_SEARCH_DIALECT is not set, let's use 'fuseki' as default value." FULL_TEXT_SEARCH_DIALECT="fuseki" @@ -41,6 +41,13 @@ fi # Generate config.json file from environment variables # ######################################################## +echo "Generating config.json file with the following values:" +echo "- ENDPOINT_URL: ${ENDPOINT_URL}" +echo "- SPARQL_CONSOLE_URL: ${SPARQL_CONSOLE_URL}" +echo "- GRAPH_EXPLORER_URL: ${GRAPH_EXPLORER_URL}" +echo "- FULL_TEXT_SEARCH_DIALECT: ${FULL_TEXT_SEARCH_DIALECT}" +echo "- NEPTUNE_FTS_ENDPOINT: ${NEPTUNE_FTS_ENDPOINT}" + jq -n \ --arg endpointUrl "${ENDPOINT_URL}" \ --arg sparqlConsoleUrl "${SPARQL_CONSOLE_URL}" \ @@ -55,6 +62,6 @@ jq -n \ "neptune": { "ftsEndpoint": $ftsEndpoint } - }' > /app/dist/blueprint/browser/config.json + }' > /app/config.json exit 0 From 1d8ac7531307bb32680ce8e98baea0fd91967023 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Mon, 10 Jun 2024 13:01:24 +0200 Subject: [PATCH 5/5] stack: use env vars --- stack/blueprint/config.json | 6 ------ stack/docker-compose.yaml | 8 ++++++-- 2 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 stack/blueprint/config.json diff --git a/stack/blueprint/config.json b/stack/blueprint/config.json deleted file mode 100644 index eba2715..0000000 --- a/stack/blueprint/config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "endpointUrl": "http://127.0.0.1:8080/query", - "sparqlConsoleUrl": "http://127.0.0.1:8080/sparql/#query", - "graphExplorerUrl": "http://127.0.0.1:8080/graph-explorer/?resource", - "fullTextSearchDialect": "fuseki" -} diff --git a/stack/docker-compose.yaml b/stack/docker-compose.yaml index a2b80e1..8051518 100644 --- a/stack/docker-compose.yaml +++ b/stack/docker-compose.yaml @@ -22,10 +22,14 @@ services: build: context: .. dockerfile: Dockerfile - volumes: - - ./blueprint/config.json:/app/config.json:ro ports: - 8081:80 + environment: + # NOTE: 127.0.0.1 is in the context of the browser (frontend), not the server (backend) + - ENDPOINT_URL=http://127.0.0.1:8080/query + - SPARQL_CONSOLE_URL=http://127.0.0.1:8080/sparql/#query + - GRAPH_EXPLORER_URL=http://127.0.0.1:8080/graph-explorer/?resource + - FULL_TEXT_SEARCH_DIALECT=fuseki trifid: image: ghcr.io/zazuko/trifid:v5