Skip to content

Commit 385ecca

Browse files
Merge pull request #141 from datajoint/docs/production-deployment
docs: add production deployment how-to guide
2 parents cb14686 + 44454b4 commit 385ecca

File tree

3 files changed

+45
-26
lines changed

3 files changed

+45
-26
lines changed

scripts/gen_api_pages.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
"datajoint.blob",
2525
"datajoint.hash_registry",
2626
"datajoint.jobs",
27-
"datajoint.admin",
2827
"datajoint.migrate",
2928
]
3029

@@ -44,7 +43,6 @@
4443
"datajoint.blob": ("Blob", "Binary serialization"),
4544
"datajoint.hash_registry": ("Hash Registry", "Content hashing for external storage"),
4645
"datajoint.jobs": ("Jobs", "Job queue for AutoPopulate"),
47-
"datajoint.admin": ("Admin", "Administrative functions"),
4846
"datajoint.migrate": ("Migrate", "Schema migration utilities"),
4947
}
5048

src/how-to/deploy-production.md

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,17 @@ ephys_schema = dj.Schema(prefix + 'ephys') # myproject_ephys
144144

145145
```sql
146146
-- Grant access to all schemas with prefix
147-
GRANT ALL PRIVILEGES ON `myproject\_%`.* TO 'developer'@'%';
147+
GRANT ALL PRIVILEGES ON `myproject_%`.* TO 'developer'@'10.0.0.%';
148148

149149
-- Read-only access to another project
150-
GRANT SELECT ON `otherproject\_%`.* TO 'developer'@'%';
150+
GRANT SELECT ON `otherproject_%`.* TO 'developer'@'10.0.0.%';
151151
```
152152

153+
!!! warning "Restrict Host Access"
154+
Avoid using `'%'` for the host in production GRANT statements—this allows
155+
connections from any IP address. Use specific IP addresses or subnet patterns
156+
like `'10.0.0.%'` to limit access to your internal network.
157+
153158
## Environment-Based Configuration
154159

155160
Use different configurations for development, staging, and production.
@@ -200,20 +205,49 @@ export DJ_SAFEMODE=false
200205

201206
### Docker/Kubernetes Example
202207

208+
DataJoint automatically loads credentials from `/run/secrets/datajoint/` when that directory exists (standard Docker/Kubernetes secrets mount point).
209+
203210
```yaml
204211
# docker-compose.yaml
205212
services:
206213
worker:
207214
image: my-pipeline:latest
208215
environment:
209216
- DJ_HOST=db.example.com
210-
- DJ_USER_FILE=/run/secrets/db_user
211-
- DJ_PASS_FILE=/run/secrets/db_password
212217
- DJ_CREATE_TABLES=false
213218
- DJ_SCHEMA_PREFIX=prod_
214-
secrets:
215-
- db_user
216-
- db_password
219+
volumes:
220+
# Mount secrets directory
221+
- type: bind
222+
source: ./secrets
223+
target: /run/secrets/datajoint
224+
read_only: true
225+
```
226+
227+
Create the secrets directory with credential files:
228+
229+
```bash
230+
mkdir -p secrets
231+
echo "prod_user" > secrets/database.user
232+
echo "prod_password" > secrets/database.password
233+
chmod 600 secrets/*
234+
```
235+
236+
For Kubernetes, use a Secret mounted to `/run/secrets/datajoint/`:
237+
238+
```yaml
239+
# kubernetes deployment
240+
spec:
241+
containers:
242+
- name: worker
243+
volumeMounts:
244+
- name: dj-secrets
245+
mountPath: /run/secrets/datajoint
246+
readOnly: true
247+
volumes:
248+
- name: dj-secrets
249+
secret:
250+
secretName: datajoint-credentials
217251
```
218252
219253
## Complete Production Configuration

src/tutorials/basics/06-object-storage.ipynb

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"cell_type": "code",
24-
"execution_count": 1,
24+
"execution_count": null,
2525
"id": "cell-1",
2626
"metadata": {
2727
"execution": {
@@ -31,21 +31,8 @@
3131
"shell.execute_reply": "2026-01-24T03:27:42.261846Z"
3232
}
3333
},
34-
"outputs": [
35-
{
36-
"name": "stderr",
37-
"output_type": "stream",
38-
"text": [
39-
"[2026-01-23 21:27:42,256][INFO]: DataJoint 2.1.0a7 connected to postgres@127.0.0.1:5432\n"
40-
]
41-
}
42-
],
43-
"source": [
44-
"import datajoint as dj\n",
45-
"import numpy as np\n",
46-
"\n",
47-
"schema = dj.Schema('tutorial_oas')"
48-
]
34+
"outputs": [],
35+
"source": "import datajoint as dj\nimport numpy as np\n\nschema = dj.Schema('tutorial_oas')\n\n# Clean slate: drop existing schema if re-running\nschema.drop(prompt=False)\nschema = dj.Schema('tutorial_oas')"
4936
},
5037
{
5138
"cell_type": "markdown",
@@ -1807,4 +1794,4 @@
18071794
},
18081795
"nbformat": 4,
18091796
"nbformat_minor": 5
1810-
}
1797+
}

0 commit comments

Comments
 (0)