Skip to content

Commit 90d6329

Browse files
committed
chore(sandbox): simplify the local dev workspace setup
1 parent 16600e6 commit 90d6329

File tree

4 files changed

+41
-173
lines changed

4 files changed

+41
-173
lines changed

docker-compose/docker-compose.yml

Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ x-n8n-env: &n8n-env
3232
N8N_DISABLED_MODULES: "external-secrets,mcp,chat-hub"
3333
N8N_ENCRYPTION_KEY: ${N8N_ENCRYPTION_KEY}
3434
N8N_USER_MANAGEMENT_JWT_SECRET: ${N8N_USER_MANAGEMENT_JWT_SECRET}
35-
N8N_CUSTOM_EXTENSIONS: /home/node/.n8n/nodes
3635
OLLAMA_HOST: ${OLLAMA_HOST:-ollama:11434}
3736
N8N_PORT: '5678'
3837
NODE_ENV: production
38+
N8N_PROTOCOL: 'http'
3939
N8N_TRUST_PROXY: 'true'
4040
N8N_PROXY_HOPS: "1"
4141
# OIDC
@@ -47,8 +47,6 @@ x-n8n-env: &n8n-env
4747
OIDC_USERINFO_ENDPOINT: http://keycloak:8080/realms/starter/protocol/openid-connect/userinfo
4848
OIDC_REDIRECT_URI: http://localhost:5678/rest/auth/oidc/callback
4949
OIDC_ROLES_CLAIM: client_roles
50-
EXTERNAL_HOOK_FILES: /home/node/.n8n/external-hooks/oidc.cjs:/home/node/.n8n/external-hooks/test.cjs:/home/node/.n8n/external-hooks/custom-api.cjs
51-
EXTERNAL_FRONTEND_HOOKS_URLS: /assets/oidc-frontend-hook.js
5250
N8N_ADDITIONAL_NON_UI_ROUTES: auth
5351

5452
services:
@@ -123,27 +121,33 @@ services:
123121
keycloak:
124122
condition: service_started
125123

126-
n8n-import:
124+
n8n-provision:
127125
<<: *common-props
128-
container_name: n8n-import
126+
container_name: n8n-provision
129127
restart: 'no'
130128
build:
131-
context: .
132-
dockerfile: dockerfiles/n8n.Dockerfile
129+
context: ..
130+
dockerfile: Dockerfile
133131
environment: *n8n-env
134132
volumes:
135133
- n8n_storage:/home/node/.n8n
136134
- ./n8n/demo-data:/demo-data
137-
- ../community-nodes:/community-nodes
138135
entrypoint: /bin/sh
139136
command: >
140137
-c "if [ -z \"$$(n8n list:workflow --onlyId)\" ]; then
141138
n8n import:credentials --separate --input=/demo-data/credentials &&
142139
n8n import:workflow --separate --input=/demo-data/workflows;
143140
fi;
144141
145-
cd "$N8N_CUSTOM_EXTENSIONS" &&
146-
npm install /community-nodes"
142+
echo 'Installing community nodes';
143+
mkdir -p /home/node/.n8n/nodes;
144+
cd /home/node/.n8n/nodes && npm install /community-nodes;
145+
146+
echo 'Installing external hooks';
147+
cd /external-hooks && node migrate.cjs;
148+
149+
echo 'n8n provision completed!';
150+
"
147151
depends_on:
148152
postgres:
149153
condition: service_healthy
@@ -152,54 +156,17 @@ services:
152156
<<: *common-props
153157
container_name: n8n
154158
build:
155-
context: .
156-
dockerfile: dockerfiles/n8n.Dockerfile
159+
context: ..
160+
dockerfile: Dockerfile
157161
environment: *n8n-env
158162
ports:
159163
- '5678:5678'
160164
volumes:
161165
- n8n_storage:/home/node/.n8n
162-
- ./n8n/demo-data:/demo-data
163-
- ../community-nodes:/community-nodes
164-
- ../external-hooks/dist/oidc.cjs:/home/node/.n8n/external-hooks/oidc.cjs
165-
- ../external-hooks/dist/test.cjs:/home/node/.n8n/external-hooks/test.cjs
166-
- ../external-hooks/dist/custom-api.cjs:/home/node/.n8n/external-hooks/custom-api.cjs
167-
- ../external-hooks/drizzle:/home/node/.n8n/external-hooks/drizzle
168166
depends_on:
169167
postgres:
170168
condition: service_healthy
171169
keycloak:
172170
condition: service_started
173-
n8n-import:
171+
n8n-provision:
174172
condition: service_completed_successfully
175-
176-
qdrant:
177-
<<: *common-props
178-
container_name: qdrant
179-
image: qdrant/qdrant:latest
180-
ports:
181-
- '6333:6333'
182-
volumes:
183-
- qdrant_storage:/qdrant/storage
184-
185-
# OLLAMA CONFIGURATIONS (Profiles)
186-
# ollama:
187-
# <<: *common-props
188-
# container_name: ollama
189-
# image: ollama/ollama:latest
190-
# volumes:
191-
# - ollama_storage:/root/.ollama
192-
# ports:
193-
# - '11434:11434'
194-
195-
# ollama-pull-llama:
196-
# <<: *common-props
197-
# container_name: ollama-pull-llama
198-
# restart: 'no'
199-
# image: ollama/ollama:latest
200-
# environment:
201-
# OLLAMA_HOST: ollama:11434
202-
# entrypoint: /bin/sh
203-
# command: -c "sleep 5; ollama pull llama3.2"
204-
# depends_on:
205-
# - ollama

docker-compose/dockerfiles/n8n.Dockerfile

Lines changed: 0 additions & 25 deletions
This file was deleted.

docs/development-setup/sandbox.md

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,60 +28,47 @@ If you are using the Docker CLI without the Desktop GUI, ensure your environment
2828
<br> `ln -s $HOMEBREW_PREFIX/lib/docker/cli-plugins/docker-compose ~/.docker/cli-plugins/docker-compose` |
2929
| **Windows** | Follow the [WSL2 + Native Docker Guide](https://gist.github.com/martinsam16/4492957e3bbea34046f2c8b49c3e5ac0) |
3030

31-
---
32-
3331
## Getting Started
3432

35-
### 1. Environment Configuration
36-
37-
Ensure you have a `.env` file in the root directory with the following variables defined (referencing the Compose file):
38-
39-
- `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`
40-
- `KEYCLOAK_ADMIN`, `KEYCLOAK_ADMIN_PASSWORD`
41-
- `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`
42-
- `N8N_ENCRYPTION_KEY`, `N8N_USER_MANAGEMENT_JWT_SECRET`
33+
### Spin Up the Sandbox
4334

44-
### 2. Spin Up the Sandbox
35+
Launch the environment. The setup includes automated provisioning for Keycloak and n8n custom nodes and external endpoints.
4536

46-
Launch the environment. The setup includes automated provisioning for Keycloak and n8n demo data.
37+
In `docker-compose` directory, run:
4738

4839
```bash
49-
docker-compose up --build -d
40+
docker compose --env-file .env.example up --build
5041

5142
```
5243

53-
## ⚙️ Service Catalog
44+
## Service Catalog
5445

5546
Once the containers are healthy, the following services are available:
5647

57-
| Service | Description | Local Access |
58-
| ------------ | --------------------------------------------- | ------------------------------------------------------------------------------ |
59-
| **Keycloak** | Identity & Access Management (Custom Build) | [http://localhost:8080](https://www.google.com/search?q=http://localhost:8080) |
60-
| **n8n** | Workflow Automation (with OIDC & AI enabled) | [http://localhost:5678](https://www.google.com/search?q=http://localhost:5678) |
61-
| **Postgres** | Primary DB (v18.0) - Shared by n8n & Keycloak | `localhost:5432` |
62-
| **Qdrant** | Vector Database for AI/RAG | [http://localhost:6333](https://www.google.com/search?q=http://localhost:6333) |
63-
| **Ollama** | Local LLM Runner (Optional/Commented Out) | `localhost:11434` |
48+
| Service | Description | Local Access |
49+
| ------------ | ---------------------------- | ------------------------------------------------------------------------------ |
50+
| **Keycloak** | Identity & Access Management | [http://localhost:8080](https://www.google.com/search?q=http://localhost:8080) |
51+
| **n8n** | Workflow Automation | [http://localhost:5678](https://www.google.com/search?q=http://localhost:5678) |
52+
| **Postgres** | Primary DB (v18.0) | `localhost:5432` |
53+
| **Ollama** | Local LLM Runner (Optional) | `localhost:11434` |
54+
| **Qdrant** | Vector Database (Optional) | `localhost:6333` |
6455

65-
---
56+
## Automated Provisioning Details
6657

67-
## 🛠️ Automated Provisioning
58+
The sandbox uses a "Dependency Chain" to ensure services configure themselves in the correct order:
6859

69-
The sandbox includes "Run-Once" containers that handle the heavy lifting of environment setup:
60+
1. **Postgres (`initdb`)**: Creates the initial schemas. **Note:** Ensure your `./initdb` folder contains a script to create the `keycloak` database, as Postgres only creates the one defined in `POSTGRES_DB` by default.
61+
2. **Keycloak Provisioning**: The `keycloak-provision` service uses the Keycloak Admin CLI or API to create the `starter` realm and the OIDC client.
62+
3. **n8n Provisioning**:
7063

71-
- **`keycloak-provision`**: Automatically configures the `starter` realm and OIDC clients after Keycloak starts.
72-
- **`n8n-import`**:
73-
- Checks if workflows exist; if not, imports credentials and workflows from `./n8n/demo-data`.
74-
- Installs community nodes from `../community-nodes`.
75-
76-
- **`initdb`**: The Postgres service automatically executes scripts located in `./initdb` on first boot.
64+
- **Idempotency**: Checks if workflows exist before importing to avoid duplicates.
65+
- **Custom Nodes**: Injects community nodes into the `/home/node/.n8n/nodes` directory.
66+
- **Hooks**: Runs `migrate.cjs` to set up external hooks (e.g., custom logging or auditing).
7767

7868
## 💾 Persistence & Volumes
7969

80-
Data is persisted across restarts using named Docker volumes:
81-
82-
- `n8n_storage`: Config, nodes, and local binary data.
83-
- `postgres_storage`: All relational data (n8n & Keycloak tables).
84-
- `qdrant_storage`: Vector collections and indexes.
85-
- `ollama_storage`: Downloaded LLM models (e.g., Llama 3.2).
70+
Data is persisted across restarts using named Docker volumes. If you need to **wipe the environment**, run `docker-compose down -v`.
8671

87-
> **Note on AI Features:** Ollama is currently commented out in the `docker-compose.yaml`. To use local AI nodes in n8n, uncomment the `ollama` and `ollama-pull-llama` services.
72+
- `n8n_storage`: Stores the `.n8n` folder, including SQLite (if used), binary data, and installed nodes.
73+
- `postgres_storage`: Stores the physical database files for both n8n and Keycloak.
74+
- `ollama_storage` / `qdrant_storage`: (Reserved) Stores downloaded AI models and vector embeddings.

docs/sandbox.md

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)