diff --git a/docs/guides/local-development.md b/docs/guides/local-development.md index 512cf25b..a5afa399 100644 --- a/docs/guides/local-development.md +++ b/docs/guides/local-development.md @@ -45,6 +45,7 @@ services: image: junobuild/satellite:latest ports: - 5987:5987 + - 5999:5999 volumes: - my_dapp:/juno/.juno - ./juno.dev.config.json:/juno/juno.dev.config.json @@ -94,7 +95,11 @@ Modify the following information of the `docker-compose.yml` file to tweak the c ### Ports -The default port is 5987. If, for example, you would like to use port 8080, modify the value `5987:5987` to `8080:5987`. The latter is the port exposed by the container. +The default port `5987` is used for communication with the locally deployed satellites and other modules in the local environment (replica). This is the primary port for interaction with the application. + +The container also exposes a small admin server for internal management on port `5999`. + +If you want to use a different port, such as 8080, update for example the mapping from `5987:5987` to `8080:5987`, where the first value (8080) is the port you can call, and the second (5987) is the actual container port. ### Volumes @@ -114,6 +119,7 @@ services: image: junobuild/satellite:latest ports: - 5987:5987 + - 5999:5999 volumes: - hello_world:/juno/.juno # <-------- hello_world modified here - ./juno.dev.config.json:/juno/juno.dev.config.json @@ -148,6 +154,7 @@ export interface Rule { maxSize?: number; maxCapacity?: number; mutablePermissions: boolean; + maxTokens?: number; } export type SatelliteDevDbCollection = Omit< @@ -184,37 +191,39 @@ export interface JunoDevConfig { If, for example, we want to configure a "metadata" collection in the Datastore, a "content" collection in the Storage, and provide an additional controller, we could use the following configuration: -```json title="juno.dev.config.json" -{ - "satellite": { - "collections": { - "db": [ +```typescript title="juno.dev.config.ts" +import { defineDevConfig } from "@junobuild/config"; + +export default defineDevConfig(() => ({ + satellite: { + collections: { + db: [ { - "collection": "metadata", - "read": "managed", - "write": "managed", - "memory": "stable", - "mutablePermissions": true + collection: "metadata", + read: "managed", + write: "managed", + memory: "stable", + mutablePermissions: true } ], - "storage": [ + storage: [ { - "collection": "content", - "read": "public", - "write": "public", - "memory": "stable", - "mutablePermissions": true + collection: "content", + read: "public", + write: "public", + memory: "stable", + mutablePermissions: true } ] }, - "controllers": [ + controllers: [ { - "id": "535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe", - "scope": "admin" + id: "535yc-uxytb-gfk7h-tny7p-vjkoe-i4krp-3qmcl-uqfgr-cpgej-yqtjq-rqe", + scope: "admin" } ] } -} +})); ``` ### Path and name @@ -227,6 +236,7 @@ services: image: junobuild/satellite:latest ports: - 5987:5987 + - 5999:5999 volumes: - my_dapp:/juno/.juno - /your/custom/path/your_config_file.json:/juno/juno.dev.config.json # <-------- Modify location and file name of the left hand part @@ -274,3 +284,33 @@ await initSatellite({ container: true }); ``` + +--- + +## Tips and Tricks + +The admin server running on port `5999` provides a variety of internal management. Below are some tips and example scripts to make use of this little server. + +### Example: Get ICP + +You might want to transfer some ICP from the ledger to a specified principal, which can be particularly useful when you're just getting started developing your app and no users currently own ICP. This can be achieved by querying: + +``` +http://localhost:5999/ledger/transfer/?to=$PRINCIPAL +``` + +For example, you can use the following script: + +```bash +#!/usr/bin/env bash + +# Check if a principal is passed as an argument; otherwise, prompt for it +if [ -z "$1" ]; then + read -r -p "Enter the Wallet ID (owner account, principal): " PRINCIPAL +else + PRINCIPAL=$1 +fi + +# Make a transfer request to the admin server +curl "http://localhost:5999/ledger/transfer/?to=$PRINCIPAL" +```