From 447692e68feb0ed5a0745e350aae8bd1fa270625 Mon Sep 17 00:00:00 2001 From: Daniil Palagin Date: Tue, 10 Sep 2024 09:48:19 +0200 Subject: [PATCH] [#50] Update README.md. Delete docker-compose-dev.yml. Create .env file. --- .env.custom-script-paths | 1 - README.md | 43 +++++++++++----------- deploy/.env | 4 +++ deploy/docker-compose.yml | 6 ++-- deploy/nginx/nginx.conf | 1 - docker-compose-dev.yml | 76 --------------------------------------- docker-compose.yml | 66 ---------------------------------- 7 files changed, 30 insertions(+), 167 deletions(-) delete mode 100644 .env.custom-script-paths create mode 100644 deploy/.env delete mode 100644 docker-compose-dev.yml delete mode 100644 docker-compose.yml diff --git a/.env.custom-script-paths b/.env.custom-script-paths deleted file mode 100644 index da591a9..0000000 --- a/.env.custom-script-paths +++ /dev/null @@ -1 +0,0 @@ -#SHARED_ROOT=/host_mnt diff --git a/README.md b/README.md index 8e5efa8..f62931a 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,19 @@ There are two ways to run the editor, [using docker-compose](#running-editor-usi #### Running editor using docker-compose To run the editor using `docker-compose`, do the following steps: -- `cd $PROJECT_ROOT` -- if on Windows, create `$PROJECT_ROOT/.env` according to [Configuration of environment variables in Windows](#configuration-of-environment-variables-in-windows) +- `cd $PROJECT_ROOT/deploy +- if on Windows, create `$PROJECT_ROOT/deploy/.env` according to [Configuration of environment variables in Windows](#configuration-of-environment-variables-in-windows) - `docker-compose up` -- open the editor in browser at `http://localhost:3000`. The editor should be showing [example scripts from SPipes repository](https://github.com/kbss-cvut/s-pipes/doc/examples). +- open the editor in browser at `http://localhost:1235`. The editor should be showing [example scripts from SPipes repository](https://github.com/kbss-cvut/s-pipes/doc/examples). #### Run editor using spe script -`spe` script can be used to execute the editor from a command line by specifying one or more directories from which SPipes scripts should be loaded. Internally the script uses [docker-compose.yml](https://github.com/kbss-cvut/s-pipes-editor-ui/blob/master/docker-compose.yml) file and environment variables specified in `$PROJECT_ROOT/.env.custom-script-paths`. +`spe` script can be used to execute the editor from a command line by specifying one or more directories from which SPipes scripts should be loaded. Internally the script uses [docker-compose.yml](https://github.com/kbss-cvut/s-pipes-editor-ui/blob/master/docker-compose.yml) file and environment variables specified in `$PROJECT_ROOT/deploy/.env.custom-script-paths`. To run the editor using `spe` script, do the following steps: -- if on Windows, create `$PROJECT_ROOT/.env.custom-script-paths` according to [Configuration of environment variables in Windows](#configuration-of-environment-variables-in-windows) +- if on Windows, create `$PROJECT_ROOT/deploy/.env.custom-script-paths` according to [Configuration of environment variables in Windows](#configuration-of-environment-variables-in-windows) - `$PROJECT_ROOT/bin/spe.$EXTENSION ` -- open the editor in a browser at `http://localhost:3000`. The editor should show the script from folders specified in and the folder $PROJECT_ROOT/../s-pipes-modules. +- open the editor in a browser at `http://localhost:1235`. The editor should show the script from folders specified in and the folder $PROJECT_ROOT/../s-pipes-modules. Use the correct spe script extension: - Use `spe.sh` if in bash (both linux or wsl distribution). @@ -54,13 +54,13 @@ To make the script executable line endings should be replaced. - `SHARED_ROOT=/mnt/c` -To override default configuration create `$PROJECT_ROOT/.env` and use following variables: +To override default configuration create `$PROJECT_ROOT/deploy/.env` and use following variables: - `CUSTOM_SCRIPT_PATHS` -- to show different SPipes scripts (defaults to `${PROJECT_ROOT}/../s-pipes/doc/examples`). Use separator ";" to add multiple paths. The path must be absolute and the same as in host filesystem. - `SCRIPTRULES` -- to set up different rules to validate SPipes scripts (defaults to `${PROJECT_ROOT}/../s-pipes-editor/src/main/resources/rules`), -- `RDF4J_SERVER_URL` -- to set up different Rdf4j server (defaults to internal docker service at `http://rdf4j:8080/rdf4j-server`). - **Note that this variable must be consistent with variable `RDF4J_PCONFIGURL`**. +- `RDF4J_SERVER_URL` -- to set up different Rdf4j server (defaults to internal docker service at `http://db-server:7200/`). + **Note that this variable must be consistent with variable `RDF4J_PCONFIGURL`**. - `RDF4J_REPOSITORYNAME` -- to set up different Rdf4j repository name where SPipes logs from execution are created (defaults to `s-pipes-hello-world`). **Note that this variable must be consistent with variable `RDF4J_PCONFIGURL`**. @@ -69,7 +69,8 @@ To override default configuration create `$PROJECT_ROOT/.env` and use following variables `RDF4J_SERVER_URL` and `RDF4J_REPOSITORYNAME`**. - `SPIPES_ENGINE` -- to set up different s-pipes engine (defaults to internal docker service `http://s-pipes-engine:8080/s-pipes/`), - `SPIPES_EDITOR_REST` -- to set up different s-pipes-editor backend (defaults to internal docker service `s-pipes-editor-rest:18115`). - +- `INTERNAL_HOST_PORT` -- to set the port number on which application will be accessible within the internal network (defaults to internal docker service `1235`) +- `PUBLIC_ORIGIN` -- to set the base URL or domain where the application is publicly accessible. ### Building @@ -95,10 +96,10 @@ $ npm run dev ## Development with Docker Compose Here is the common procedure to debug individual services of the s-pipes-editor-ui. `` can be replaced by one of the values `s-pipes-editor-ui`, `s-pipes-editor-rest` and `s-pipes-engine`. -1. cd to `$PROJECT_ROOT`. -2. Run `docker-compose -f docker-compose-dev.yml up` if not running already. Otherwise, run -`docker-compose -f docker-compose-dev.yml start`. -3. Stop the service which you want to develop `docker-compose -f docker-compose-dev.yml stop ` +1. cd to `$PROJECT_ROOT/deploy`. +2. Run `docker-compose up` if not running already. Otherwise, run +`docker-compose start`. +3. Stop the service which you want to develop `docker-compose stop ` 4. Start `` in development environment - `s-pipes-editor-ui` - run `npm run dev` - `s-pipes-editor-rest` - start run/debug springboot configuration in IntelliJ IDEA @@ -115,16 +116,16 @@ where denotes the URL where SPipes backend is running. ### Docker-compose You can run editor together with backend using docker orchestration. The docker-compose is composed of 4 services and can be run via `docker-compose up`: -* [chlupnoha/s-pipes-editor-ui:latest](https://hub.docker.com/repository/docker/chlupnoha/s-pipes-editor-ui) - accessible on `http://localhost:3000` -* [chlupnoha/s-pipes-editor-rest:latest](https://hub.docker.com/repository/docker/chlupnoha/s-pipes-editor-rest) - accessible on `http://localhost:18115` with [configuration options](https://github.com/kbss-cvut/s-pipes-editor#dockerization) -* [chlupnoha/spipes-engine:latest](https://hub.docker.com/repository/docker/chlupnoha/spipes-engine) - accessible on `http://localhost:8081` with [configuration options](https://github.com/kbss-cvut/s-pipes#dockerization) -* [eclipse/rdf4j-workbench:amd64-3.5.0](https://hub.docker.com/r/eclipse/rdf4j-workbench) - accessible on `http://localhost:8080/rdf4j-workbench` +* [chlupnoha/s-pipes-editor-ui:latest](https://hub.docker.com/repository/docker/chlupnoha/s-pipes-editor-ui) - accessible on `http://localhost:1235` +* [chlupnoha/s-pipes-editor-rest:latest](https://hub.docker.com/repository/docker/chlupnoha/s-pipes-editor-rest) - accessible on `http://localhost:1235/rest` with +* [chlupnoha/spipes-engine:latest](https://hub.docker.com/repository/docker/chlupnoha/spipes-engine) - accessible on `http://localhost:1235/services/s-pipes` +* [graphdb](https://github.com/kbss-cvut/s-pipes-editor-ui/tree/master/deploy/db-server) - accessible on `http://localhost:1235/services/db-server` **Required manual steps:** * s-pipes-engine - * The service does not automatically create the repository in RDF4J, so manual creation of a repository is required (after running `docker-compose up`). - * First open the RDF4J Workbench: `http://localhost:/rdf4j-workbench` where `` is the RDF4J service port specified in `docker-compose.yml`. - * Then follow these instructions: [Creating a Repository](https://rdf4j.org/documentation/tools/server-workbench/#:~:text=for%20the%20repository.-,Creating%20a%20Repository,-Click%20on%20%E2%80%9CNew) (For repository type use for example Native Store.) + * The service does not automatically create the repository in GraphDB, so manual creation of a repository is required (after running `docker-compose up`). + * First open the GraphDB Workbench: `http://localhost:/services/db-server/repository` where `` is the port specified in `.env`. + * Then follow these [instructions](https://graphdb.ontotext.com/documentation/10.0/creating-a-repository.html). * The logging configuration for RDF4j is hardcoded in the image, but it could override via `_pConfigURL` param. However, it is not a convenient format to work. Also both servies must to share volume or the config has to be exposed. * Notes diff --git a/deploy/.env b/deploy/.env new file mode 100644 index 0000000..2502236 --- /dev/null +++ b/deploy/.env @@ -0,0 +1,4 @@ +#INTERNAL_HOST_PORT=1235 +#PUBLIC_ORIGIN=http://localhost +#SPIPES_ENGINE=http://s-pipes-engine:8080/s-pipes/ +#SPIPES_EDITOR_REST=s-pipes-editor-rest:18115 diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 8698bc5..e5cc7fd 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -4,7 +4,7 @@ services: nginx: image: nginx:latest ports: - - "1235:80" + - "127.0.0.1:${INTERNAL_HOST_PORT:-1235}:80" restart: always depends_on: - s-pipes-engine @@ -12,7 +12,7 @@ services: - db-server - s-pipes-editor-ui environment: - NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx + NGINX_ENVSUBST_OUTPUT_DIR: "/etc/nginx" APP_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}" SERVICE_URL: "${SPIPES_EDITOR_REST:-http://s-pipes-editor-rest:18115}" volumes: @@ -67,6 +67,8 @@ services: context: ./db-server ports: - "7200:7200" + environment: + GDB_JAVA_OPTS: "-Dgraphdb.external-url=${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}/services/db-server" volumes: - ./db-server/init-config:/repo-config:ro - db-server:/opt/graphdb/home diff --git a/deploy/nginx/nginx.conf b/deploy/nginx/nginx.conf index ca64035..e0b1a93 100644 --- a/deploy/nginx/nginx.conf +++ b/deploy/nginx/nginx.conf @@ -40,7 +40,6 @@ http 504 505 506 507 508 510 511 /error.html; location = /error.html { - ssi on; internal; root /usr/share/nginx/html; diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml deleted file mode 100644 index 8ce4014..0000000 --- a/docker-compose-dev.yml +++ /dev/null @@ -1,76 +0,0 @@ -version: "3" - -services: - s-pipes-editor-ui: - image: "ghcr.io/kbss-cvut/s-pipes-editor-ui/s-pipes-editor-ui:latest" - container_name: s-pipes-editor-ui - ports: - - "3000:80" - networks: - - overlay - depends_on: - - s-pipes-editor-rest - environment: - - SERVICE_URL=${SPIPES_EDITOR_REST:-http://host.docker.internal:18115} - - s-pipes-editor-rest: - image: "ghcr.io/kbss-cvut/s-pipes-editor/s-pipes-editor:latest" - container_name: s-pipes-editor-rest - ports: - - ${EDITOR_REST_PORT:-18115}:18115 - expose: - - "18115" - networks: - - overlay - depends_on: - - s-pipes-engine - - rdf4j - environment: - - SCRIPTPATHS=${SCRIPTPATHS:-${PWD}/../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../s-pipes/doc/examples}} - - SCRIPTRULES=${SCRIPTRULES:-${PWD}/../s-pipes-editor/src/main/resources/rules} - - ENGINEURL=${SPIPES_ENGINE:-http://host.docker.internal:8081/s-pipes/} - - RDF4J_REPOSITORYURL=${RDF4J_SERVER_URL:-http://rdf4j:8080/rdf4j-server}/repositories - - RDF4J_REPOSITORYNAME=${RDF4J_REPOSITORYNAME:-s-pipes-hello-world} - - RDF4J_PCONFIGURL=${RDF4J_PCONFIGURL:-../s-pipes/doc/examples/hello-world/config.ttl} - volumes: - - /tmp:/tmp - - ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home} - - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/ - - s-pipes-engine: - image: "ghcr.io/kbss-cvut/s-pipes/s-pipes-engine:latest" - # container_name: s-pipes-engine - ports: - - ${SPIPES_PORT:-8081}:8080 - expose: - - "8080" - networks: - - overlay - depends_on: - - rdf4j - environment: - - CONTEXTS_SCRIPTPATHS=${SCRIPTPATHS:-${PWD}/../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../s-pipes/doc/examples}} - volumes: - - /tmp:/tmp - - ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home} - - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/ - - rdf4j: - image: "eclipse/rdf4j-workbench:3.7.7" - container_name: rdf4j - expose: - - "8080" - networks: - - overlay - environment: - - JAVA_OPTS=-Xms1g -Xmx4g - volumes: - - data:/var/rdf4j - - logs:/usr/local/tomcat/logs - -volumes: - data: - logs: - -networks: - overlay: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 330b37d..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,66 +0,0 @@ -version: "3.9" - -# Expose port to access s-pipes-editor-rest directly -x-access-db-server-development-port: &s-pipes-editor-rest-dev-port - ports: - - "127.0.0.1:${EDITOR_REST_PORT:-18115}:18115" - -services: - s-pipes-editor-ui: - image: "ghcr.io/kbss-cvut/s-pipes-editor-ui/s-pipes-editor-ui:latest" - container_name: s-pipes-editor-ui - ports: - - "127.0.0.1:${INTERNAL_HOST_PORT:-3000}:80" - depends_on: - - s-pipes-editor-rest - environment: - - SERVICE_URL=${SPIPES_EDITOR_REST:-http://s-pipes-editor-rest:18115} - - s-pipes-editor-rest: - # <<: *s-pipes-editor-rest-dev-port - image: "ghcr.io/kbss-cvut/s-pipes-editor/s-pipes-editor:latest" - container_name: s-pipes-editor-rest - expose: - - "18115" - depends_on: - - s-pipes-engine - - db-server - environment: - - SCRIPTPATHS=${SCRIPTPATHS:-${PWD}/../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../s-pipes/doc/examples}} - - SCRIPTRULES=${SCRIPTRULES:-${PWD}/../s-pipes-editor/src/main/resources/rules} - - ENGINEURL=${SPIPES_ENGINE:-http://s-pipes-engine:8080/s-pipes}/ - - RDF4J_REPOSITORYURL=${RDF4J_SERVER_URL:-http://db-server:7200}/repositories - - RDF4J_REPOSITORYNAME=${RDF4J_REPOSITORYNAME:-s-pipes-hello-world} - - RDF4J_PCONFIGURL=${RDF4J_PCONFIGURL:-${PWD}/deploy/s-pipes-engine/config.ttl} - volumes: - - /tmp:/tmp - - ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home} - - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/ - - s-pipes-engine: - image: "ghcr.io/kbss-cvut/s-pipes/s-pipes-engine:latest" - # container_name: s-pipes-engine - expose: - - "8080" - depends_on: - - db-server - environment: - - CONTEXTS_SCRIPTPATHS=${SCRIPTPATHS:-${PWD}/../s-pipes-modules;${CUSTOM_SCRIPT_PATHS:-${PWD}/../s-pipes/doc/examples}} - volumes: - - /tmp:/tmp - - ${SHARED_ROOT:-/home}:${SHARED_ROOT:-/home} - - /usr/local/tomcat/temp/:/usr/local/tomcat/temp/ - - db-server: - build: - context: ./deploy/db-server - expose: - - "7200" - volumes: - - ./deploy/db-server/init-config:/repo-config:ro - - db-server:/opt/graphdb/home - -volumes: - data: - logs: - db-server: