diff --git a/.gitignore b/.gitignore index a390c40..37fe30e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,8 @@ target # IDE specific .idea *.iml + +# Data Directories for Docker Compose +# Ignore all files, except the README.md +compas/data/**/*.* +!compas/data/**/README.md diff --git a/README.md b/README.md index a44c3a5..34e06f7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,13 @@ docker-compose -f compas/docker-compose-postgresql.yml down -v The option '-v' also removes the volumes created, so all data is lost with this option. +## Docker Compose (Common) + +### Custom files + +The SCL Validator Service can be extended with custom OCL and NSDOC Files. These can be placed in specific directories, +see [OCL Files](compas/data/ocl/README.md) and [NSDOC Files](compas/data/nsdoc/README.md). + ### Known issue with Docker Compose Using the current configuration with Keycloak and OpenResty (lua-resty-session) sometimes gives an error @@ -76,7 +83,7 @@ Using the current configuration with Keycloak and OpenResty (lua-resty-session) This mostly happens after using logout or the session is expired. The login page is shown, but after login this error is shown. Just open the url [http://localhost/](http://localhost/) again and OpenSCD is shown again, also being logged in. -## Keycloak Demo Configuration +### Keycloak Demo Configuration For demo purposes, a [demo Keycloak configuration](compas/keycloak/keycloak_compas_realm.json) is created which can be imported when running a Keycloak instance. diff --git a/compas/data/nsdoc/README.md b/compas/data/nsdoc/README.md new file mode 100644 index 0000000..5b3ffc3 --- /dev/null +++ b/compas/data/nsdoc/README.md @@ -0,0 +1,15 @@ + + +This directory can be used to add NSDOC Files to be served by the SCL Validator Service for the frontend application. + +For instance +``` +compas/data +└── nsdoc + ├── Official-File73.nsdoc + └── README.md +``` diff --git a/compas/data/ocl/README.md b/compas/data/ocl/README.md new file mode 100644 index 0000000..8498669 --- /dev/null +++ b/compas/data/ocl/README.md @@ -0,0 +1,25 @@ + + +This directory can be used to add custom OCL Files to the validation process. + +You can use subdirectories like `SemanticConstraints` as RiseClipse is doing. +And there is a special filter that when you create a directory `FileSpecifics`. +In this directory you can create for instance a directory `CID` to put constraints specific for an SCL File Type. +Known types are `SSD`, `IID`, `ICD`, `SCD`, `CID`, `SED`, `ISD`, `STD`. + +For instance, + +``` +compas/data +└── ocl + ├── FileSpecifics + │ └── CID + │ └── Busbar.ocl + ├── README.md + └── SemanticConstraints + └── Busbar.ocl +``` diff --git a/compas/docker-compose-basex.yml b/compas/docker-compose-basex.yml index 9d3505e..3f2d225 100644 --- a/compas/docker-compose-basex.yml +++ b/compas/docker-compose-basex.yml @@ -108,10 +108,37 @@ services: depends_on: - keycloak + scl-validator: + labels: + compas: true + image: "lfenergy/compas-scl-validator:0.1.0" + ports: + - "9093:8080" + environment: + - JWT_VERIFY_KEY=http://keycloak:8080/auth/realms/compas/protocol/openid-connect/certs + - JWT_VERIFY_ISSUER=http://${COMPAS_HOSTNAME}/auth/realms/compas + - JWT_VERIFY_CLIENT_ID=scl-validator + - JWT_GROUPS_PATH=resource_access/scl-validator/roles + - USERINFO_WHO_CLAIMNAME=name + deploy: + restart_policy: + condition: on-failure + max_attempts: 3 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/compas-scl-validator/q/health/ready"] + interval: 15s + timeout: 10s + retries: 5 + volumes: + - ./data/ocl:/data/ocl + - ./data/nsdoc:/data/nsdoc + depends_on: + - keycloak + open-scd: labels: compas: true - image: "lfenergy/compas-open-scd:v0.12.0.0" + image: "lfenergy/compas-open-scd:v0.12.0.1" healthcheck: test: ["CMD", "curl", "-f", "http://localhost/"] interval: 30s diff --git a/compas/docker-compose-postgresql.yml b/compas/docker-compose-postgresql.yml index 566a333..516ad75 100644 --- a/compas/docker-compose-postgresql.yml +++ b/compas/docker-compose-postgresql.yml @@ -115,10 +115,37 @@ services: depends_on: - keycloak + scl-validator: + labels: + compas: true + image: "lfenergy/compas-scl-validator:0.1.0" + ports: + - "9093:8080" + environment: + - JWT_VERIFY_KEY=http://keycloak:8080/auth/realms/compas/protocol/openid-connect/certs + - JWT_VERIFY_ISSUER=http://${COMPAS_HOSTNAME}/auth/realms/compas + - JWT_VERIFY_CLIENT_ID=scl-validator + - JWT_GROUPS_PATH=resource_access/scl-validator/roles + - USERINFO_WHO_CLAIMNAME=name + deploy: + restart_policy: + condition: on-failure + max_attempts: 3 + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/compas-scl-validator/q/health/ready"] + interval: 15s + timeout: 10s + retries: 5 + volumes: + - ./data/ocl:/data/ocl + - ./data/nsdoc:/data/nsdoc + depends_on: + - keycloak + open-scd: labels: compas: true - image: "lfenergy/compas-open-scd:v0.12.0.0" + image: "lfenergy/compas-open-scd:v0.12.0.1" healthcheck: test: ["CMD", "curl", "-f", "http://localhost/"] interval: 30s @@ -127,6 +154,8 @@ services: depends_on: - scl-data-service - cim-mapping + - scl-auto-alignment + - scl-validator reverse-proxy: labels: @@ -146,6 +175,8 @@ services: - keycloak - scl-data-service - cim-mapping + - scl-auto-alignment + - scl-validator - open-scd volumes: diff --git a/compas/reverse-proxy/nginx.conf b/compas/reverse-proxy/nginx.conf index 3ef8026..1065951 100644 --- a/compas/reverse-proxy/nginx.conf +++ b/compas/reverse-proxy/nginx.conf @@ -126,6 +126,26 @@ http { proxy_redirect off; } + # Forwarding to the SCL Auto Alignment Service container. + location /compas-scl-validator/ { + include /etc/nginx/include/authenticate.include; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + proxy_set_header Authorization "Bearer ${access_token}"; + + # Added Header back to browser to get JWT Content for Debugging, should not do this in production. + add_header X-Debug-Bearer "Bearer ${access_token}" always; + + proxy_pass http://scl-validator:8080/compas-scl-validator/; + + proxy_set_header Host $http_host; + proxy_cache_bypass $http_upgrade; + proxy_redirect off; + } + # redirect server error pages to the static page /40x.html error_page 404 /404.html; location = /40x.html {