Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 22 additions & 2 deletions samples/traderx/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ help:
.score-compose/state.yaml:
score-compose init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml
--patch-templates https://raw.githubusercontent.com/score-spec/community-patchers/refs/heads/main/score-compose/microcks.tpl \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml \
--provisioners ./score-provisioners/compose/10-endpoint-with-microcks.provisioners.yaml

compose.yaml: account-service/score.yaml database/score.yaml ingress/score.yaml people-service/score.yaml position-service/score.yaml reference-data/score.yaml trade-feed/score.yaml trade-processor/score.yaml trade-service/score.yaml web-frontend/score.yaml .score-compose/state.yaml Makefile
score-compose generate \
Expand Down Expand Up @@ -42,6 +44,23 @@ compose-test: compose-up
sleep 5
curl $$(score-compose resources get-outputs 'dns.default#ingress.dns' --format '{{ .host }}:8080')

compose-mock.yaml: database/score.yaml ingress/score.yaml position-service/score.yaml trade-feed/score.yaml trade-processor/score.yaml trade-service/score.yaml web-frontend/score.yaml .score-compose/state.yaml Makefile
score-compose generate \
database/score.yaml \
position-service/score.yaml \
trade-feed/score.yaml \
trade-processor/score.yaml \
trade-service/score.yaml \
web-frontend/score.yaml
score-compose generate \
ingress/score.yaml \
--build 'ingress={"context":"ingress/","dockerfile":"Dockerfile.mock","tags":["ingress:local"]}'

## Generate a compose.yaml file from the score specs and launch it.
.PHONY: compose-up
compose-mock-up: compose-mock.yaml
docker compose up --build -d --remove-orphans

## Delete the containers running via compose down.
.PHONY: compose-down
compose-down:
Expand All @@ -50,7 +69,8 @@ compose-down:
.score-k8s/state.yaml:
score-k8s init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml \
--provisioners ./score-provisioners/k8s/10-endpoint-with-microcks-cli.provisioners.yaml

manifests.yaml: account-service/score.yaml database/score.yaml ingress/score.yaml people-service/score.yaml position-service/score.yaml reference-data/score.yaml trade-feed/score.yaml trade-processor/score.yaml trade-service/score.yaml web-frontend/score.yaml .score-k8s/state.yaml Makefile
score-k8s generate \
Expand Down
1 change: 0 additions & 1 deletion samples/traderx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ flowchart TD
trade-processor-->trade-feed
trade-processor-->database
trade-service-->account-service
trade-service-->database
trade-service-->people-service
trade-service-->reference-data
trade-service-->trade-feed
Expand Down
13 changes: 13 additions & 0 deletions samples/traderx/ingress/Dockerfile.mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM nginx:alpine-slim

EXPOSE 8080
ARG NGINX_HOST="localhost"
ENV NGINX_HOST=$NGINX_HOST

# This is a workaround for the dollar sign in the envsubst command
ARG DOLLAR="$"
ENV DOLLAR=$DOLLAR

COPY nginx.traderx-mock.conf.template /etc/nginx/conf.d/nginx.traderx.conf.template

RUN envsubst < /etc/nginx/conf.d/nginx.traderx.conf.template > /etc/nginx/conf.d/default.conf
59 changes: 59 additions & 0 deletions samples/traderx/ingress/nginx.traderx-mock.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
server {
listen 8080;
server_name $NGINX_HOST;

location /db-web/ {
proxy_pass http://database-database:18084/;
}
location /reference-data/ {
proxy_pass http://localhost:9090/rest/FINOS+TraderX+Reference+Data/1.0/;
}

location /ng-cli-ws {
proxy_pass http://web-frontend-web-frontend:18093/ng-cli-ws;
proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";
}

location /trade-feed/ {
proxy_set_header X-Forwarded-For ${DOLLAR}proxy_add_x_forwarded_for;
proxy_set_header Host ${DOLLAR}http_host;

proxy_pass http://trade-feed-trade-feed:18086/;

proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";
}

location /socket.io/ {
proxy_set_header X-Forwarded-For ${DOLLAR}proxy_add_x_forwarded_for;
proxy_set_header Host ${DOLLAR}http_host;

proxy_pass http://trade-feed-trade-feed:18086/socket.io/;

proxy_http_version 1.1;
proxy_set_header Upgrade ${DOLLAR}http_upgrade;
proxy_set_header Connection "upgrade";
}

location /people-service/ {
proxy_pass http://localhost:9090/rest/FINOS+TraderX+People+Service/v1/;
}
location /account-service/ {
proxy_pass http://localhost:9090/rest/FINOS+TraderX+Account+Service/0.1.0;
}
location /position-service/ {
proxy_pass http://position-service-position-service:18090/;
}
location /trade-service/ {
proxy_pass http://trade-service-trade-service:18092/;
}
location /trade-processor/ {
proxy_pass http://trade-processor-trade-processor:18091/;
}
location / {
proxy_pass http://web-frontend-web-frontend:18093/;
}
}
12 changes: 6 additions & 6 deletions samples/traderx/ingress/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ service:
port: 8080
targetPort: 8080
resources:
people-service:
type: service
#people-service:
# type: service
trade-service:
type: service
account-service:
type: service
reference-data:
type: service
#account-service:
# type: service
#reference-data:
# type: service
trade-feed:
type: service
trade-processor:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Custom updates for now, will need to contribute back to the community provisioners repository later on.
- uri: template://custom-provisioners/endpoint-with-microcks
type: endpoint
description: Outputs an endpoint URL for connecting to an other workload (a Microcks mock is generated if not found).
init: |
hostname: {{ splitList "." .Id | last }}
{{ $artifacts := .Params.artifacts | splitList "," }}
{{ $parsedPath := $artifacts | first | splitList "/" }}
{{ if eq (len $parsedPath) 0 }}
resourcesPath: "."
{{ else }}
resourcesPath: {{ trimSuffix (last $parsedPath) (first $artifacts) | trimSuffix "/" }}
{{ end }}
supported_params:
- port
- artifacts
- name
- version
outputs: |
{{ $w := (index .WorkloadServices .Init.hostname) }}
{{ if or (not $w) (not $w.ServiceName) }}
url: http://localhost:9090/rest/{{ .Params.name | replace " " "+" }}/{{ .Params.version }}
{{ else }}
url: http://{{ .Init.hostname }}:{{ .Params.port }}
{{ end }}
expected_outputs:
- url
services: |
{{ $w := (index .WorkloadServices .Init.hostname) }}
{{ if or (not $w) (not $w.ServiceName) }}
{{ .Init.hostname }}-mock:
image: quay.io/microcks/microcks-cli:latest
restart: always
entrypoint:
- "microcks"
- "import"
- "{{ .Params.artifacts }}"
- "--microcksURL=http://microcks:8080/api"
- "--insecure-tls"
- "--keycloakClientId=foo"
- "--keycloakClientSecret=bar"
cap_drop:
- ALL
read_only: true
user: "65532"
volumes:
- type: bind
source: {{ .Init.resourcesPath }}
target: /{{ .Init.resourcesPath }}
read_only: true
depends_on:
microcks:
condition: service_started
required: true
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Custom updates for now, will need to contribute back to the community provisioners repository later on.
- uri: cmd://bash#endpoint-with-microcks-cli
type: endpoint
description: Outputs an endpoint URL for connecting to an other workload (a Microcks mock is generated if not found).
supported_params:
- port
- artifacts
- name
- version
expected_outputs:
- url
args:
- -c
- |
STDIN=$(cat)
PARAM_PORT=$(echo $STDIN | yq eval -p json '.resource_params.port')
PARAM_NAME=$(echo $STDIN | yq eval -p json '.resource_params.name')
PARAM_VERSION=$(echo $STDIN | yq eval -p json '.resource_params.version')
PARAM_ARTIFACTS=$(echo $STDIN | yq eval -p json '.resource_params.artifacts')
SPEC_FILE=""
if [ "$PARAM_ARTIFACTS" != "" ]; then
SPEC_FILE=$(echo $STDIN | yq eval -p json '.resource_params.artifacts | split(",") | .[0]')
fi
WORKLOAD=$(echo $STDIN | yq eval -p json '.resource_id | split(".") | .[-1]')
WORKLOAD_EXISTS=$(echo $STDIN | WORKLOAD=${WORKLOAD} yq eval -p json '.workload_services | has(strenv(WORKLOAD))')
URL_HOSTNAME=${WORKLOAD}:${PARAM_PORT}
URL_SCHEME="http"
URL_PATH=""
if [ "$WORKLOAD_EXISTS" != "true" ]; then
URL_HOSTNAME="microcks.127.0.0.1.nip.io"
URL_SCHEME="https"
URL_PATH=/rest/$(cat $SPEC_FILE | yq eval '.info.title' | yq '. |= sub(" ", "+")')
set -eu -o pipefail
microcks import ${PARAM_ARTIFACTS} --microcksURL=https://${URL_HOSTNAME} --insecure-tls --keycloakClientId=foo --keycloakClientSecret=bar >&2
fi
OUTPUTS='{"resource_outputs":{"url":"%s://%s%s"},"manifests":[]}'
printf "$OUTPUTS" "$URL_SCHEME" "$URL_HOSTNAME" "$URL_PATH"
31 changes: 16 additions & 15 deletions samples/traderx/trade-service/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ containers:
trade-service:
image: ghcr.io/finos/traderx/trade-service:latest
variables:
DATABASE_TCP_HOST: "${resources.database.name}"
PEOPLE_SERVICE_HOST: "${resources.people-service.name}"
ACCOUNT_SERVICE_HOST: "${resources.account-service.name}"
REFERENCE_DATA_HOST: "${resources.reference-data.name}"
TRADING_SERVICE_PORT: '18092'
PEOPLE_SERVICE_URL: "${resources.people-service.url}"
ACCOUNT_SERVICE_URL: "${resources.account-service.url}"
REFERENCE_DATA_SERVICE_URL: "${resources.reference-data.url}"
TRADE_FEED_HOST: "${resources.trade-feed.name}"
service:
ports:
Expand All @@ -21,22 +21,23 @@ resources:
people-service:
type: endpoint
params:
port: 8181
openapi_file: ../api-mocks/people-service-openapi.json
openapi_title: FINOS TraderX People Service
port: 18090
artifacts: api-mocks/people-service-openapi.json:true,api-mocks/people-service-metadata.yaml:false,api-mocks/people-service-examples.yaml:false
name: FINOS TraderX People Service
version: v1
trade-feed:
type: service
account-service:
type: endpoint
params:
port: 8181
openapi_file: ../api-mocks/account-service-openapi.json
openapi_title: FINOS TraderX Account Service
port: 18088
artifacts: api-mocks/account-service-openapi.json:true,api-mocks/account-service-examples.yaml:false
name: FINOS TraderX Account Service
version: 0.1.0
reference-data:
type: endpoint
params:
port: 8181
openapi_file: ../api-mocks/reference-data-openapi.json
openapi_title: FINOS TraderX Reference Data
database:
type: service
port: 18085
artifacts: api-mocks/reference-data-openapi.json:true,api-mocks/reference-data-examples.yaml:false
name: FINOS TraderX Reference Data
version: '1.0'
Loading