From 0a2d5571331f9f29579106c59feeec1b7eeb41eb Mon Sep 17 00:00:00 2001 From: Timo Glastra Date: Sun, 31 Mar 2024 17:04:09 +0200 Subject: [PATCH] feat(rest): add docker and postgres sample Signed-off-by: Timo Glastra --- packages/rest/samples/cliConfig.json | 4 +- packages/rest/samples/docker-compose.yaml | 47 +++++++++++++++++++++++ packages/rest/samples/docker.env.local | 11 ++++++ 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 packages/rest/samples/docker-compose.yaml create mode 100644 packages/rest/samples/docker.env.local diff --git a/packages/rest/samples/cliConfig.json b/packages/rest/samples/cliConfig.json index 4f21302..26a2883 100644 --- a/packages/rest/samples/cliConfig.json +++ b/packages/rest/samples/cliConfig.json @@ -16,8 +16,7 @@ ], "cheqdLedger": [ { - "network": "mainnet", - "cosmosPayerSeed": "bird cage swing" + "network": "mainnet" }, { "network": "testnet" @@ -43,7 +42,6 @@ "outboundTransport": ["http", "ws"], "autoAcceptMediationRequests": false, "connectionImageUrl": "https://image.com/image.png", - "webhookUrl": "https://my-webhook-server", "adminPort": 3000, "multiTenant": true } diff --git a/packages/rest/samples/docker-compose.yaml b/packages/rest/samples/docker-compose.yaml new file mode 100644 index 0000000..225a320 --- /dev/null +++ b/packages/rest/samples/docker-compose.yaml @@ -0,0 +1,47 @@ +version: '3.8' + +volumes: + postgres: + +services: + credo: + image: ghcr.io/openwallet-foundation/credo-rest:0.10.0 + depends_on: + - postgres + ports: + # Admin API + - 3000:3000 + + # DIDComm + - 5000:5000 + - 5001:5001 + + # Use the local config file in the container + volumes: + - ./cliConfig.json:/cliConfig.json + command: ['--config', '/cliConfig.json'] + + # This dynamically loads the wallet id, wallet key and agent endpoint (so you can use ngrok) + # you also want to dynamically inject postgres connection details in prod + env_file: + - path: docker.env.local + required: true + + environment: + # Configure credo to use postgres as storage + CREDO_REST_POSTGRES_HOST: postgres:5432 + CREDO_REST_POSTGRES_USERNAME: postgres + CREDO_REST_POSTGRES_PASSWORD: postgres + CREDO_REST_STORAGE_TYPE: postgres + + # Postgres (when deploying you probably want to use a managed service for this) + postgres: + image: postgres:15-alpine + ports: + - '5432:5432' + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DATABASE: postgres + volumes: + - postgres:/var/lib/postgresql/data diff --git a/packages/rest/samples/docker.env.local b/packages/rest/samples/docker.env.local new file mode 100644 index 0000000..c26e04d --- /dev/null +++ b/packages/rest/samples/docker.env.local @@ -0,0 +1,11 @@ +CREDO_REST_WALLET_ID=your_wallet_id +CREDO_REST_WALLET_KEY=your_wallet_key + +# You can use ngrok (ngrok http 3001) to expose your local server to the internet +# and interact with Paradym and other agents. +# CREDO_REST_ENDPOINT=https://d297-217-123-18-26.ngrok-free.app +CREDO_REST_ENDPOINT=http://localhost:5001 + +# You can configure credo to send webhooks to your server +# Or, during development e.g. use https://rbaskets.in/web +# CREDO_REST_WEBHOOK_URL=https://webhook.site/fbcd1feb-da81-447b-8888-e34cad509143