How can you run this server with more than one schema version? #131
-
The schema server hosted at https://schema.ocsf.io/ allows you to pick from multiple schema versions in the upper left corner, however I'm not following how to set this up in the same way when I run this locally in docker. I'm just seeing v1.3.0-dev as the only option. I also noticed there is an environment property SCHEMA_HOME - wasn't sure whether that's what is needed or not, couldn't find examples of it being used online or in the docs here. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
@rmouritzen-splunk - sorry to @ you here, but I see you've pushed several commits lately and I'm unsure how else to reach out to anyone about this. |
Beta Was this translation helpful? Give feedback.
-
The public server supports multiple version by fronting all traffic through Nginx. Requests are proxied to Docker images based on the request URL, with each Docker image configured to use a specific schema, as well as a base directory containing all of the schemas, where each schema is a Here is a snippet of the Nginx configuration showing how the redirection is working, with 1.4.0 and 1.5.0-dev mapped:
Here's an example how how to clone the repos: mkdir -p /opt/ocsf/schemas
cd /opt/ocsf/schemas
branch=v1.4.0
git clone --single-branch --branch $branch https://github.com/ocsf/ocsf-schema.git $branch
branch=main
git clone --single-branch --branch $branch https://github.com/ocsf/ocsf-schema.git $branch Here a script that launches the Docker images. I regularly push new images to my own work account's Docker hub profile. This script is assumes the schemas are in
#!/bin/bash
# Note: this is a bash-specific test for running as root or sudo
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
set -x
# Stop existing containers
docker ps -aq | xargs docker stop | xargs docker rm
# The above stop / cleanup fails when there are no containers running,
# so we wait until after that step to force an exit on error.
set -e
# Start new containers
container=rmouritzen388/ocsf-server:2.77.3
function run_server() {
name=$1
schema_dir=$2
web_schema_path=$3
localhost_port=$4
docker run --name "${name}" -d --restart unless-stopped \
-v /opt/ocsf/schemas:/app/schemas \
-e SCHEMA_HOME=/app/schemas \
-e SCHEMA_DIR=/app/schemas/"${schema_dir}" \
-e SCHEMA_PATH=/"${web_schema_path}" \
-e HOST=schema.ocsf.io \
-p 127.0.0.1:"${localhost_port}":8080/tcp \
$container
}
# run_server rc2 v1.0.0-rc.2 1.0.0-rc.2 8000
# run_server rc3 v1.0.0-rc.3 1.0.0-rc.3 8001
# run_server 1.0 v1.0.0 1.0.0 8002
# run_server 1.1 v1.1.0 1.1.0 8003
# run_server 1.2 v1.2.0 1.2.0 8004
# run_server 1.3 v1.3.0 1.3.0 8005
run_server 1.4 v1.4.0 1.4.0 8006
run_server dev main 1.5.0-dev 8007
# Cleanup Docker
# https://docs.docker.com/config/pruning/#prune-everything
docker system prune --volumes -a -f Note that these aren't instructions to build this up a Linux server from scratch.
|
Beta Was this translation helpful? Give feedback.
The public server supports multiple version by fronting all traffic through Nginx. Requests are proxied to Docker images based on the request URL, with each Docker image configured to use a specific schema, as well as a base directory containing all of the schemas, where each schema is a
git clone
of different branches of theocsf/ocsf-schema
repo.Here is a snippet of the Nginx configuration showing how the redirection is working, with 1.4.0 and 1.5.0-dev mapped: