Skip to content

Commit

Permalink
[New] Add support for services and fta-fmea app to run at same path
Browse files Browse the repository at this point in the history
Moreover, it aligns configuration with record-manager-ui/deploy/internal-auth.
  • Loading branch information
blcham committed Apr 27, 2024
1 parent a060d1a commit f52ad59
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 39 deletions.
4 changes: 2 additions & 2 deletions .env.development.internal-auth
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FTA_FMEA_BASENAME=''
FTA_FMEA_API_URL=http://localhost:1235/fta-fmea/services/fta-fmea-server
FTA_FMEA_API_URL=http://localhost:1235/services/fta-fmea-server
FTA_FMEA_ADMIN_REGISTRATION_ONLY=false
FTA_FMEA_TITLE='Development FTA/FMEA Tool'
FTA_FMEA_TITLE='Development FTA/FMEA Tool'
17 changes: 12 additions & 5 deletions deploy/internal-auth/.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Public origin of URL where FTA/FMEA tool UI will run, e.g. https://kbss.fel.cvut.cz, https://kbss.fel.cvut.cz:8080, http://localhost. ! This option can be used only with running reverse proxy pointing to http://localhost:$INTERNAL_HOST_PORT/fta-fmea !
# Prefix for name of all docker containers. By default it is set to "ff".
RECORD_SET_NAME=ff-iauth-demo

# Host machine port that provides main entrypoint for the application. The application will be locally accessible at http://localhost:$INTERNAL_HOST_PORT/$FTA_FMEA_PATH (by default it is set to "1235")
INTERNAL_HOST_PORT=1235

# Public origin of URL where FTA/FMEA tool UI will run, e.g. https://kbss.fel.cvut.cz, https://kbss.fel.cvut.cz:8080, http://localhost. ! This option can be used only with running reverse proxy pointing to http://localhost:$INTERNAL_HOST_PORT !
#PUBLIC_ORIGIN=http://localhost

# Path to root FTA/FMEA tool application (by default it is set to "/fta-fmea") ! This option can be used only with running reverse proxy pointing to http://localhost:$INTERNAL_HOST_PORT/fta-fmea !
#FTA_FMEA_ROOT_PATH=/fta-fmea-demo
# Root path for all applications and services, e.g., "" or "/my-company". By default it is set to "". MUST start with slash and MUST NOT end with slash.
#APP_ROOT_PATH=/ff-demo

# Relative path for root FTA/FMEA tool application starting from APP_ROOT_PATH (by default it is set to "/fta-fmea"). MUST start with slash and MUST NOT end with slash.
#RECORD_MANAGER_PATH=/recordfta-fmea-demo

# Host machine port that provides main entrypoint for the application. The application will be locally accessible at http://localhost:$INTERNAL_HOST_PORT/$FTA_FMEA_ROOT_PATH (by default it is set to "1235")
INTERNAL_HOST_PORT=1235
44 changes: 29 additions & 15 deletions deploy/internal-auth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@ version: "3.9"

# Provide access to fta-fmea-ui that runs locally in dev mode
x-access-for-local-development: &local-dev-env
cors.allowedOrigins: "http://localhost:5173,http://localhost:4173"
cors.allowedOrigins: "http://localhost:4173,http://localhost:5173"

# Provide logging to Java application (e.g. fta-fmea-server)
x-logging-java-application: &logging-java
LOGGING_LEVEL_ROOT: "debug"

# Expose port to access db-server directly, bypassing nginx
x-access-db-server-development-port: &db-server-dev-port
ports:
- "127.0.0.1:${DB_SERVER_DEV_PORT:-7205}:7200"

services:
nginx:
image: nginx:latest
volumes:
- ./nginx/template-variables.conf:/etc/nginx/templates/variables.conf.template:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx/error.html:/usr/share/nginx/html/error.html:ro
container_name: ${RECORD_SET_NAME:-ff}-nginx
ports:
- "127.0.0.1:${INTERNAL_HOST_PORT:-1235}:80"
restart: always
Expand All @@ -19,22 +25,29 @@ services:
- fta-fmea-server
- db-server
environment:
FTA_FMEA_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}"
FTA_FMEA_ROOT_PATH: "${FTA_FMEA_ROOT_PATH:-/fta-fmea}"
NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx
APP_ORIGIN: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}"
APP_ROOT_PATH: "${APP_ROOT_PATH:-}"
FTA_FMEA_PATH: "${FTA_FMEA_PATH:-/fta-fmea}"
volumes:
- ./nginx/nginx.conf:/etc/nginx/templates/nginx.conf.template:ro
- ../shared/nginx/error.html:/usr/share/nginx/html/error.html:ro

fta-fmea:
image: ghcr.io/kbss-cvut/fta-fmea-ui:latest
environment:
FTA_FMEA_API_URL: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}${FTA_FMEA_ROOT_PATH:-/fta-fmea}/services/fta-fmea-server"
FTA_FMEA_ADMIN_REGISTRATION_ONLY: ${ADMIN_REGISTRATION_ONLY:-false}
FTA_FMEA_BASENAME: "${FTA_FMEA_ROOT_PATH:-/fta-fmea}"
container_name: ${RECORD_SET_NAME:-ff}-fta-fmea
expose:
- "80"
depends_on:
- fta-fmea-server
environment:
FTA_FMEA_API_URL: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}${APP_ROOT_PATH:-}/services/fta-fmea-server"
FTA_FMEA_BASENAME: "${APP_ROOT_PATH:-}${FTA_FMEA_PATH:-/fta-fmea}"
FTA_FMEA_ADMIN_REGISTRATION_ONLY: ${ADMIN_REGISTRATION_ONLY:-false}

fta-fmea-server:
image: ghcr.io/kbss-cvut/fta-fmea:latest
container_name: ${RECORD_SET_NAME:-ff}-fta-fmea-server
expose:
- "9999"
depends_on:
Expand All @@ -43,21 +56,22 @@ services:
environment:
<<: *local-dev-env
REPOSITORY_URL: ${REPOSITORY_URL:-http://db-server:7200/repositories/fta-fmea}
#appContext: "${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}${FTA_FMEA_ROOT_PATH:-/fta-fmea}"
server.servlet.context-path: "/fta-fmea"

db-server:
image: ${RECORD_SET_NAME:-fta-fmea}-db-server
<<: *db-server-dev-port
image: ${RECORD_SET_NAME:-ff}-db-server
container_name: ${RECORD_SET_NAME:-ff}-db-server
build:
context: ../shared/db-server
environment:
GDB_JAVA_OPTS: "-Dgraphdb.external-url=${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}${FTA_FMEA_ROOT_PATH:-/fta-fmea}/services/db-server"
GDB_JAVA_OPTS: "-Dgraphdb.external-url=${PUBLIC_ORIGIN:-http://localhost:${INTERNAL_HOST_PORT:-1235}}${APP_ROOT_PATH:-}/services/db-server"
expose:
- "7200"
restart: always
volumes:
- db-server:/opt/graphdb/home
- ../shared/db-server/init-data:/root/graphdb-import:ro
- db-server:/opt/graphdb/home

volumes:
db-server:
18 changes: 8 additions & 10 deletions deploy/internal-auth/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ http {
504 'Gateway Timeout';
}

include /etc/nginx/conf.d/variables.conf;

server {
listen 80;
server_name localhost;
Expand All @@ -44,24 +42,24 @@ http {
root /usr/share/nginx/html;
}

location = /fta-fmea {
return 302 $fta_fmea_origin$fta_fmea_root_path/;
location = ${FTA_FMEA_PATH} {
return 302 ${APP_ORIGIN}${APP_ROOT_PATH}${FTA_FMEA_PATH}/;
}

location /fta-fmea/ {
location ${FTA_FMEA_PATH}/ {
proxy_pass http://fta-fmea/; # keep the trailing slash to cut off matched prefix
}

location /fta-fmea/services/fta-fmea-server/ {
location /services/fta-fmea-server/ {
proxy_pass http://fta-fmea-server:9999/fta-fmea/; # keep the trailing slash to cut off matched prefix
proxy_cookie_path /fta-fmea $fta_fmea_root_path/services;
proxy_cookie_path /fta-fmea ${APP_ROOT_PATH}/services;
}

location = /fta-fmea/services/db-server {
return 302 $fta_fmea_origin$fta_fmea_root_path/services/db-server/;
location = /services/db-server {
return 302 ${APP_ORIGIN}${APP_ROOT_PATH}/services/db-server/;
}

location /fta-fmea/services/db-server/ {
location /services/db-server/ {
proxy_pass http://db-server:7200/; # keep the trailing slash to cut off matched prefix
}

Expand Down
7 changes: 0 additions & 7 deletions deploy/internal-auth/nginx/template-variables.conf

This file was deleted.

File renamed without changes.

0 comments on commit f52ad59

Please sign in to comment.