Skip to content

Commit

Permalink
docs: little admin server on port 5999 (#225)
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker authored Nov 19, 2024
1 parent aa01dc9 commit be331fe
Showing 1 changed file with 61 additions and 21 deletions.
82 changes: 61 additions & 21 deletions docs/guides/local-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -148,6 +154,7 @@ export interface Rule {
maxSize?: number;
maxCapacity?: number;
mutablePermissions: boolean;
maxTokens?: number;
}
export type SatelliteDevDbCollection = Omit<
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"
```

0 comments on commit be331fe

Please sign in to comment.