Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
ocm-engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
svdh
ocm-engine
Commits
a9bef78b
Commit
a9bef78b
authored
1 year ago
by
Alexey Lunin
Browse files
Options
Downloads
Patches
Plain Diff
Added multiple agent generator for demo purpose
parent
9752c02c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!20
Didgram
Pipeline
#63154
failed
1 year ago
Stage: lint
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compose/gen-docker.js
+237
-0
237 additions, 0 deletions
compose/gen-docker.js
with
237 additions
and
0 deletions
compose/gen-docker.js
0 → 100644
+
237
−
0
View file @
a9bef78b
const
fs
=
require
(
'
fs
'
);
// print process.argv
const
[
IDUNION_KEY
,
IDUNION_BASIC_USER
,
IDUNION_BASIC_PASS
]
=
process
.
argv
.
slice
(
2
);
let
startPort
=
8000
;
function
makeid
(
length
)
{
let
result
=
''
;
const
characters
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
'
;
const
charactersLength
=
characters
.
length
;
let
counter
=
0
;
while
(
counter
<
length
)
{
result
+=
characters
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
charactersLength
));
counter
+=
1
;
}
return
result
;
}
const
generateAgent
=
(
agentNum
)
=>
{
const
agentHttpPort
=
startPort
++
;
const
agentWsPort
=
startPort
++
;
const
agentName
=
agentNum
<
10
?
'
0
'
+
agentNum
:
agentNum
;
const
genericName
=
'
agent
'
+
agentName
;
const
agentPort
=
startPort
++
;
const
tcpPort
=
startPort
++
;
const
connectionManagerPort
=
startPort
++
;
const
attestationManagerPort
=
startPort
++
;
const
proofManagerPort
=
startPort
++
;
const
envContent
=
`LEDGERS=IDUNION
IDUNION_KEY=
${
IDUNION_KEY
}
IDUNION_BASIC_USER=
${
IDUNION_BASIC_USER
}
IDUNION_BASIC_PASS=
${
IDUNION_BASIC_PASS
}
AGENT_PEER_URL=http://new.didgram.pro:
${
agentHttpPort
}
,ws://new.didgram.pro:
${
agentWsPort
}
AGENT_NAME=DEV_AGENT_
${
agentName
}
# this should be changed to company name
AGENT_KEY=DEV_AGENT_
${
agentName
}
#example random string
AGENT_DID_SEED=
${
makeid
(
32
)}
#did private key seed min length 32
AGENT_DB_HOST=pg_db:5432
AGENT_DB_USER=postgres
AGENT_DB_PASS=postgres
AGENT_PORT=
${
agentPort
}
AGENT_CONSUMER_NAME=agent_
${
agentName
}
AGENT_IS_REST=false
AGENT_MAX_MESSAGES=10
AGENT_RETE_LIMIT=5
NATS_SERVERS=broker-
${
genericName
}
:4222
NATS_STREAM_NAME=ssi_
${
genericName
}
_stream
NATS_SUBJECTS="connections.*,proofs.*,credentials.*,credentials.definition.*,credentials.offer.*,schemas.*,messages.*"
GATEWAY_HTTP_PORT=
${
agentPort
}
GATEWAY_TCP_PORT=
${
tcpPort
}
GATEWAY_SOCKET_EVENT_NAME=message
GATEWAY_MESSAGE_PATTERN=webhook
GATEWAY_HOST=gateway-
${
genericName
}
CONNECTION_SERVICE_TCP_PORT=
${
connectionManagerPort
}
CONNECTION_SERVICE_HOST=cm-
${
genericName
}
ATTESTATION_SERVICE_TCP_PORT=
${
attestationManagerPort
}
ATTESTATION_SERVICE_HOST=am-
${
genericName
}
PROOF_SERVICE_TCP_PORT=
${
proofManagerPort
}
PROOF_SERVICE_HOST=pm-
${
genericName
}
`
;
const
dockerContent
=
`
#=====================
${
genericName
}
=========================#
gateway-
${
genericName
}
:
profiles:
-
${
genericName
}
container_name: gw-
${
genericName
}
image: node:18.16.0
volumes:
- ./data/node_modules:/app/node_modules
- ./data/dist/apps/gateway:/app/
working_dir: /app
command: node main.js
ports:
- "
${
agentPort
}
:
${
agentPort
}
"
- "
${
tcpPort
}
:
${
tcpPort
}
"
env_file:
- ./env/
${
genericName
}
.env
depends_on:
builder:
condition: service_completed_successfully
cm-
${
genericName
}
:
condition: service_started
agent-
${
genericName
}
:
profiles:
-
${
genericName
}
container_name: agent-
${
genericName
}
image: node:18.16.0
volumes:
- ./data/node_modules:/app/node_modules
- ./data/dist/apps/agent:/app/
working_dir: /app
command: node main.js
ports:
- "
${
agentHttpPort
}
:
${
agentHttpPort
}
"
- "
${
agentWsPort
}
:
${
agentWsPort
}
"
env_file:
- ./env/
${
genericName
}
.env
depends_on:
builder:
condition: service_completed_successfully
cm-
${
genericName
}
:
condition: service_started
cm-
${
genericName
}
:
container_name: cm-
${
genericName
}
image: node:18.16.0
volumes:
- ./data/node_modules:/app/node_modules
- ./data/dist/apps/connection-manager:/app/
working_dir: /app
command: node main.js
profiles:
-
${
genericName
}
env_file:
- ./env/
${
genericName
}
.env
ports:
- "
${
connectionManagerPort
}
"
depends_on:
builder:
condition: service_completed_successfully
broker-
${
genericName
}
:
condition: service_started
am-
${
genericName
}
:
container_name: am-
${
genericName
}
image: node:18.16.0
volumes:
- ./data/node_modules:/app/node_modules
- ./data/dist/apps/attestation-manager:/app/
working_dir: /app
command: node main.js
profiles:
-
${
genericName
}
env_file:
- ./env/
${
genericName
}
.env
ports:
- "
${
attestationManagerPort
}
"
depends_on:
builder:
condition: service_completed_successfully
broker-
${
genericName
}
:
condition: service_started
pm-
${
genericName
}
:
container_name: pm-
${
genericName
}
image: node:18.16.0
volumes:
- ./data/node_modules:/app/node_modules
- ./data/dist/apps/proof-manager:/app/
working_dir: /app
command: node main.js
profiles:
-
${
genericName
}
env_file:
- ./env/
${
genericName
}
.env
ports:
- "
${
proofManagerPort
}
"
depends_on:
builder:
condition: service_completed_successfully
broker-
${
genericName
}
:
condition: service_started
broker-
${
genericName
}
:
profiles:
-
${
genericName
}
command: ["-js", "-sd", "/data", "-m","8222", "-D"]
container_name: broker-
${
genericName
}
image: 'nats:latest'
ports:
- '4222' #Nats server port
- '8222:8222' #Nats server Monitoring port
volumes:
- ./data/
${
genericName
}
/nats/:/data/
`
;
return
{
envContent
,
dockerContent
,
genericName
};
}
// generate agents
const
dockerServices
=
[];
for
(
let
i
=
0
;
i
<
10
;
i
++
)
{
const
{
envContent
,
dockerContent
,
genericName
}
=
generateAgent
(
i
);
dockerServices
.
push
(
dockerContent
);
fs
.
writeFileSync
(
`./env/
${
genericName
}
.env`
,
envContent
);
}
const
dockerContent
=
`version: '3.8'
services:
${
dockerServices
.
join
(
'
\n
'
)}
#===================== INFRA =========================#
builder:
privileged: true
image: node:18.16.0-buster-slim
volumes:
- ./../yarn.lock:/app/yarn.lock
- ./../package.json:/app/package.json
- ./../apps:/app/apps
- ./../libs:/app/libs
- ./../nx.json:/app/nx.json
- ./../tsconfig.base.json:/app/tsconfig.base.json
- ./data/node_modules:/app/node_modules
- ./data/dist:/app/dist
working_dir: /app
command:
- sh
- -c
- |
whoami
apt update -y && apt install python3 git make build-essential -y
yarn install
yarn build:all
exit 0
pg_db:
image: 'postgres:latest'
ports:
- '5433:5432'
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- ./data/db/:/var/lib/postgresql/data/
`
;
fs
.
writeFileSync
(
`./docker-compose-gen.yml`
,
dockerContent
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment