Skip to content

Commit 345174a

Browse files
committed
feat: docker setup
1 parent 3ba6d62 commit 345174a

11 files changed

Lines changed: 365 additions & 25 deletions

File tree

QUICKSTART.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Quick start: registry + evault-core + dev-sandbox
2+
3+
Run Postgres and Neo4j in Docker, then start the core services and dev-sandbox with one script.
4+
5+
## Prerequisites
6+
7+
- **Docker** (for Postgres and Neo4j)
8+
- **Node.js 18+** and **pnpm**
9+
- **.env** in the repo root (copy from `.env.example` if present, or set the variables below)
10+
11+
## Environment
12+
13+
Create or edit `.env` in the repo root. Minimum for this stack:
14+
15+
```bash
16+
# Postgres (used by registry)
17+
POSTGRES_USER=postgres
18+
POSTGRES_PASSWORD=postgres
19+
REGISTRY_DATABASE_URL=postgresql://postgres:postgres@localhost:5432/registry
20+
21+
# Neo4j (used by evault-core)
22+
NEO4J_USER=neo4j
23+
NEO4J_PASSWORD=your-password
24+
25+
# So the sandbox and evault-core can talk to registry/provisioner
26+
PUBLIC_REGISTRY_URL=http://localhost:4321
27+
PUBLIC_PROVISIONER_URL=http://localhost:3001
28+
REGISTRY_SHARED_SECRET=dev-secret-change-me
29+
PUBLIC_EVAULT_SERVER_URI=http://localhost:4000
30+
```
31+
32+
## One-command start
33+
34+
From the repo root:
35+
36+
```bash
37+
pnpm install
38+
pnpm dev:core
39+
```
40+
41+
Or run the script directly: `chmod +x scripts/start-dev.sh && ./scripts/start-dev.sh`
42+
43+
This will:
44+
45+
1. Start **Postgres** (port 5432) and **Neo4j** (7474, 7687) via `docker-compose.databases.yml`
46+
2. Wait for Postgres to be ready
47+
3. Start **registry** (4321), **evault-core** (3001 provisioning, 4000 GraphQL), and **dev-sandbox** (8080) in parallel
48+
49+
Stop with `Ctrl+C`. To stop only the databases: `pnpm docker:core:down`.
50+
51+
## Ports
52+
53+
| Service | Port(s) | Notes |
54+
|----------------|---------|--------------------------|
55+
| Postgres | 5432 | |
56+
| Neo4j HTTP | 7474 | |
57+
| Neo4j Bolt | 7687 | |
58+
| Registry | 4321 | |
59+
| evault-core | 3001, 4000 | Provisioning + GraphQL |
60+
| **Dev sandbox**| **8080**| W3DS dev sandbox UI |
61+
62+
Open **http://localhost:8080** for the dev sandbox (provision, w3ds flows, sign).
63+
64+
## Optional: databases only
65+
66+
To run only Postgres and Neo4j (e.g. you run the app services yourself):
67+
68+
```bash
69+
pnpm docker:core
70+
```
71+
72+
Or: `docker compose -f docker-compose.databases.yml up -d`. Stop with `pnpm docker:core:down`.
73+
74+
## Troubleshooting
75+
76+
**Neo4j "encryption setting" or connection refused:** The stack uses **Neo4j 4.4** (unencrypted Bolt by default). If you previously used Neo4j 5.x, remove the old data and recreate:
77+
78+
```bash
79+
docker compose -f docker-compose.databases.yml down
80+
docker volume rm metastate_neo4j_data 2>/dev/null || true
81+
docker compose -f docker-compose.databases.yml up -d
82+
pnpm dev:core
83+
```
84+
85+
Otherwise ensure `.env` has `NEO4J_URI=bolt://127.0.0.1:7687` and matching `NEO4J_USER` / `NEO4J_PASSWORD`.
86+
87+
---
88+
89+
For full Docker setups and all platform services, see the main [README](README.md).

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
**[Documentation](https://docs.w3ds.metastate.foundation)** — Getting started with W3DS and the MetaState prototype.
44

5+
**Quick start (registry + evault-core + dev-sandbox):** see **[QUICKSTART.md](QUICKSTART.md)** — one script to run Postgres + Neo4j in Docker and the core services locally. Dev sandbox runs at **http://localhost:8080**.
6+
57
## Docker Development Environment
68

79
### Port Assignments
@@ -26,7 +28,7 @@
2628
- **1111** - Pictique API
2729

2830
#### Frontend Services
29-
- **8080** - Blabsy Frontend
31+
- **8080** - Dev sandbox (W3DS) / Blabsy Frontend
3032
- **5173** - Pictique Frontend
3133
- **3004** - Group Charter Manager Frontend
3234
- **3005** - eVoting Frontend

docker-compose.core.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ services:
118118
- NEO4J_PASSWORD=${NEO4J_PASSWORD:-neo4j}
119119
- EVAULT_PUBLIC_KEY=${EVAULT_PUBLIC_KEY:-}
120120
- W3ID=${W3ID:-}
121+
- PUBLIC_EVAULT_SERVER_URI=${PUBLIC_EVAULT_SERVER_URI:-http://localhost:4000}
121122
depends_on:
122123
postgres:
123124
condition: service_healthy
@@ -130,6 +131,32 @@ services:
130131
<<: *common-host-access
131132
restart: unless-stopped
132133

134+
# Dev sandbox (provision + w3ds flows against registry + evault-core)
135+
sandbox:
136+
profiles:
137+
- core
138+
build:
139+
context: .
140+
dockerfile: ./docker/Dockerfile.dev-sandbox
141+
network: host
142+
container_name: metastate-sandbox
143+
ports:
144+
- "5173:3000"
145+
environment:
146+
- NODE_ENV=${NODE_ENV:-production}
147+
- PORT=3000
148+
- PUBLIC_REGISTRY_URL=${PUBLIC_REGISTRY_URL:-http://localhost:4321}
149+
- PUBLIC_PROVISIONER_URL=${PUBLIC_PROVISIONER_URL:-http://localhost:3001}
150+
depends_on:
151+
registry:
152+
condition: service_started
153+
evault-core:
154+
condition: service_started
155+
networks:
156+
- metastate-core-network
157+
<<: *common-host-access
158+
restart: unless-stopped
159+
133160
volumes:
134161
postgres_data:
135162
driver: local

docker-compose.databases.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Postgres + Neo4j only. Use with scripts/start-dev.sh for local DX.
2+
# Loads .env for POSTGRES_USER, POSTGRES_PASSWORD, NEO4J_USER, NEO4J_PASSWORD.
3+
4+
services:
5+
postgres:
6+
image: postgres:15-alpine
7+
container_name: metastate-postgres
8+
ports:
9+
- "5432:5432"
10+
environment:
11+
- POSTGRES_USER=${POSTGRES_USER:-postgres}
12+
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
13+
- POSTGRES_MULTIPLE_DATABASES=registry
14+
volumes:
15+
- postgres_data:/var/lib/postgresql/data
16+
- ./db/init-multiple-databases.sh:/docker-entrypoint-initdb.d/init-multiple-databases.sh
17+
healthcheck:
18+
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
19+
interval: 5s
20+
timeout: 3s
21+
retries: 5
22+
23+
neo4j:
24+
# 4.4 defaults to unencrypted Bolt; 5.x often requires TLS and env var naming is brittle
25+
image: neo4j:4.4
26+
container_name: metastate-neo4j
27+
ports:
28+
- "7474:7474"
29+
- "7687:7687"
30+
environment:
31+
- NEO4J_AUTH=${NEO4J_USER:-neo4j}/${NEO4J_PASSWORD:-neo4j}
32+
- NEO4J_USER=${NEO4J_USER:-neo4j}
33+
- NEO4J_PASSWORD=${NEO4J_PASSWORD:-neo4j}
34+
- NEO4J_dbms_connector_bolt_listen__address=0.0.0.0:7687
35+
- NEO4J_dbms_connector_http_listen__address=0.0.0.0:7474
36+
volumes:
37+
- neo4j_data:/var/lib/neo4j/data
38+
healthcheck:
39+
test: ["CMD-SHELL", "cypher-shell -u ${NEO4J_USER:-neo4j} -p ${NEO4J_PASSWORD:-neo4j} 'RETURN 1' || exit 1"]
40+
interval: 10s
41+
timeout: 5s
42+
retries: 10
43+
start_period: 30s
44+
45+
volumes:
46+
postgres_data:
47+
neo4j_data:

docker/Dockerfile.dev-sandbox

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM node:20-alpine AS base
2+
RUN apk add --no-cache libc6-compat python3 make g++
3+
WORKDIR /app
4+
5+
ENV CI=true
6+
ENV PYTHON=/usr/bin/python3
7+
RUN ln -sf python3 /usr/bin/python
8+
9+
# ---
10+
FROM base AS prepare
11+
RUN npm install -g pnpm@10.25.0 turbo@^2
12+
COPY . .
13+
RUN turbo prune dev-sandbox --docker
14+
15+
# ---
16+
FROM base AS builder
17+
RUN npm install -g pnpm@10.25.0
18+
COPY --from=prepare /app/out/json/ .
19+
RUN pnpm install --frozen-lockfile
20+
COPY --from=prepare /app/out/full/ .
21+
RUN pnpm turbo build --filter=dev-sandbox
22+
23+
# ---
24+
FROM base AS runner
25+
COPY --from=builder /app/package.json ./
26+
COPY --from=builder /app/pnpm-workspace.yaml ./
27+
COPY --from=builder /app/pnpm-lock.yaml ./
28+
COPY --from=builder /app/packages/wallet-sdk ./packages/wallet-sdk
29+
COPY --from=builder /app/infrastructure/dev-sandbox/build ./infrastructure/dev-sandbox/build
30+
COPY --from=builder /app/infrastructure/dev-sandbox/package.json ./infrastructure/dev-sandbox/
31+
COPY --from=builder /app/infrastructure/dev-sandbox/node_modules ./infrastructure/dev-sandbox/node_modules
32+
COPY --from=builder /app/node_modules ./node_modules
33+
34+
WORKDIR /app/infrastructure/dev-sandbox
35+
36+
ENV PORT=3000
37+
ENV HOST=0.0.0.0
38+
EXPOSE 3000
39+
40+
CMD ["node", "build"]

docs/docs/Post Platform Guide/getting-started.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ getOffer = async (req: Request, res: Response) => {
5555
}
5656
```
5757

58-
The client opens this URL in a w3ds-compatible client (like the [eID Wallet](/docs/Infrastructure/eID-Wallet)), which handles the user's signature and redirects back to your platform.
58+
The client opens this URL in a w3ds-compatible client (like the [eID Wallet](/docs/Infrastructure/eID-Wallet)), which handles the user's signature and redirects back to your platform. For local development and testing you can use the [Dev Sandbox](/docs/Post%20Platform%20Guide/dev-sandbox) instead of the eID wallet — it runs in the browser and lets you provision test identities and complete auth/sign flows against your platform.
5959

6060
#### 2. Login Endpoint (`POST /api/auth`)
6161

@@ -223,6 +223,7 @@ PUBLIC_REGISTRY_URL=https://registry.example.com
223223
- [Authentication](/docs/W3DS%20Protocol/Authentication) — w3ds://auth protocol
224224
- [Signing](/docs/W3DS%20Protocol/Signing) — Signature creation and verification
225225
- [Signature Formats](/docs/W3DS%20Protocol/Signature-Formats) — Cryptographic details
226+
- [Using the Dev Sandbox](/docs/Post%20Platform%20Guide/dev-sandbox) — Test auth and sign flows without the eID wallet
226227
- [Webhook Controller](/docs/Post%20Platform%20Guide/webhook-controller) — Receiving webhooks
227228
- [Mapping Rules](/docs/Post%20Platform%20Guide/mapping-rules) — Schema mapping
228229
- [eVault](/docs/Infrastructure/eVault) — Storage and key binding

infrastructure/dev-sandbox/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default defineConfig({
1010
},
1111
},
1212
server: {
13-
port: 5174,
13+
port: 8080,
1414
open: true,
1515
},
1616
});

infrastructure/evault-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ let provisioningService: ProvisioningService | undefined;
7474
const initializeEVault = async (
7575
provisioningServiceInstance?: ProvisioningService,
7676
) => {
77-
const uri = process.env.NEO4J_URI || "bolt://localhost:7687";
77+
const uri = process.env.NEO4J_URI || "bolt://127.0.0.1:7687";
7878
const user = process.env.NEO4J_USER || "neo4j";
7979
const password = process.env.NEO4J_PASSWORD || "neo4j";
8080

package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,28 @@
1010
"check-format": "turbo run check-format",
1111
"check": "turbo run check",
1212
"check-types": "turbo run check-types",
13+
"dev:core": "./scripts/start-dev.sh",
1314
"dev:docker": "docker compose -f dev-docker-compose.yaml up --watch",
1415
"dev:docker:down": "docker compose -f dev-docker-compose.yaml down",
1516
"dev:docker:all": "docker compose -f dev-docker-compose.yaml --profile all up --watch",
1617
"dev:docker:socials": "docker compose -f dev-docker-compose.yaml --profile socials up --watch",
1718
"dev:docker:charter-blabsy": "docker compose -f dev-docker-compose.yaml --profile charter-blabsy up --watch",
1819
"dev:docker:neo4j": "docker compose -f neo4j-compose.yaml up",
1920
"dev:docker:neo4j:down": "docker compose -f neo4j-compose.yaml down",
20-
"docker:core": "docker compose -f docker-compose.core.yml --profile core up",
21-
"docker:core:build": "docker compose -f docker-compose.core.yml --profile core build",
22-
"docker:core:down": "docker compose -f docker-compose.core.yml --profile core down",
23-
"docker:core:up": "docker compose -f docker-compose.core.yml --profile core up -d",
24-
"docker:core:rebuild": "docker compose -f docker-compose.core.yml --profile core up --build --force-recreate",
21+
"docker:core": "docker compose -f docker-compose.databases.yml up -d",
22+
"docker:core:down": "docker compose -f docker-compose.databases.yml down",
23+
"docker:core:stack": "docker compose -f docker-compose.core.yml --profile core up",
24+
"docker:core:stack:build": "docker compose -f docker-compose.core.yml --profile core build",
25+
"docker:core:stack:down": "docker compose -f docker-compose.core.yml --profile core down",
26+
"docker:core:stack:up": "docker compose -f docker-compose.core.yml --profile core up -d",
27+
"docker:core:stack:rebuild": "docker compose -f docker-compose.core.yml --profile core up --build --force-recreate",
2528
"docker:socials": "docker compose -f docker-compose.socials.yml --profile socials up",
2629
"docker:socials:build": "docker compose -f docker-compose.socials.yml --profile socials build",
2730
"docker:socials:down": "docker compose -f docker-compose.socials.yml --profile socials down",
2831
"docker:socials:up": "docker compose -f docker-compose.socials.yml --profile socials up -d"
2932
},
3033
"devDependencies": {
34+
"concurrently": "^9.1.0",
3135
"@biomejs/biome": "^1.9.4",
3236
"@types/react": "18.3.27",
3337
"@types/react-dom": "18.3.7",

0 commit comments

Comments
 (0)