This repository contains a Docker Compose configuration to run both the Masumi Registry Service and Masumi Payment Service together and configure the databases
- Docker and Docker Compose installed
- A Blockfrost API key (get one from blockfrost.io)
-
Copy the environment file template and fill in your values:
cp .env.example .env
-
Edit the
.envfile and set the following variables:ADMIN_KEY: A minimum 15-character secure admin key for both servicesENCRYPTION_KEY: A minimum 20-character encryption key for the payment service databaseBLOCKFROST_API_KEY_PREPROD: Your Blockfrost API key for preprod network
Optionally
PURCHASE_WALLET_PREPROD_MNEMONIC: The mnemonic of the wallet used to purchase any agent requests. This needs to have sufficient funds to pay, or be topped up. If you do not provide a mnemonic, a new one will be generated. Please ensure you export them immediately after creation and store them securely.SELLING_WALLET_PREPROD_MNEMONIC: The mnemonic of the wallet used to interact with the smart contract. This only needs minimal funds, to cover the CARDANO Network fees. If you do not provide a mnemonic, a new one will be generated. Please ensure you export them immediately after creation and store them securely.COLLECTION_WALLET_PREPROD_ADDRESS: The wallet address of the collection wallet. It will receive all payments after a successful and completed purchase (not refund). It does not need any funds, however it is strongly recommended to create it via a hardware wallet or ensure its secret is stored securely. If you do not provide an address, the SELLING_WALLET will be used.
-
Start the services:
docker compose up -d
The services will automatically:
- Create the required databases
- Run database migrations
- Seed the databases (only if they are empty)
- Start the services
- Registry Service: Available at http://localhost:3000/docs (for Open-API)
- Payment Service: Available at http://localhost:3001/docs (for Open-API) or http://localhost:3001/admin (for an admin dashboard)
- PostgreSQL: Available at localhost:5432
- Username: postgres
- Password: postgres
- Databases: masumi_registry, masumi_payment
The setup includes several features to ensure data persistence:
-
Named Volume:
- Database data is stored in a named volume
masumi_postgres_data - This volume persists even when containers are removed
- Data survives container restarts and updates
- Database data is stored in a named volume
-
Automatic Restart:
- All services are configured with
restart: unless-stopped - Services will automatically restart if they crash
- Services will restart when the system reboots
- All services are configured with
-
Database Initialization:
- Existing data is preserved during container restarts
- Seeding only occurs on empty databases
The services automatically handle database setup:
- The PostgreSQL database is initialized with the required databases
- Prisma migrations are run automatically
- The seeding script checks if each database is empty:
- If empty, it runs the seed script
- If not empty, it skips seeding, therefore preserving existing data. If you want to reset, remove the volumes and start the services again.
- The services start and is ready to use
To backup your database:
docker exec masumi-postgres pg_dumpall -U postgres > backup.sqlTo restore from a backup:
cat backup.sql | docker exec -i masumi-postgres psql -U postgresTo stop all services (data is preserved):
docker compose downTo stop and remove volumes (this will delete all data):
docker compose down -v