geniejars 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/JFILE.md +130 -0
  2. package/README.md +5 -1
  3. package/package.json +5 -2
package/JFILE.md ADDED
@@ -0,0 +1,130 @@
1
+ # JFile
2
+
3
+ A `JFile` (shortedned `GeniejarsFile`), describes how to build a geniejars environment. The syntax mirrors Dockerfile.
4
+
5
+ ## Directives
6
+
7
+ ### `ENV <KEY>=<VALUE>`
8
+ Set an environment variable. Applies to all subsequent `RUN` commands and to the main process started by `CMD`.
9
+
10
+ ```
11
+ ENV NODE_ENV=production
12
+ ENV PORT=3000
13
+ ```
14
+
15
+ ### `WORKDIR <path>`
16
+ Set the working directory for subsequent `RUN` commands and for `CMD`. Relative paths are resolved inside the geniejars's home directory. The directory is created if it does not exist.
17
+
18
+ ```
19
+ WORKDIR app
20
+ ```
21
+
22
+ ### `COPY <src> <dest>`
23
+ Copy files or directories from the manager's filesystem into the geniejars's home. `src` is relative to the `GeniejarsFile`'s directory. `dest` is relative to the geniejars's home (or absolute).
24
+
25
+ ```
26
+ COPY ./myapp app
27
+ COPY ./config/prod.json app/config.json
28
+ ```
29
+
30
+ ### `RUN <command>`
31
+ Execute a shell command as the geniejars during the build phase. Runs via the geniejars's agent socket — no sudo required. Uses the current `WORKDIR` and any `ENV` vars defined above it.
32
+
33
+ ```
34
+ RUN npm install --omit=dev
35
+ RUN mkdir -p logs
36
+ ```
37
+
38
+ ### `ADDPATH <path>`
39
+ Prepend a directory to `PATH` when the main process is started via `CMD`. Multiple `ADDPATH` directives are accumulated in order. Has no effect on `RUN` commands (use `ENV PATH=...` for that).
40
+
41
+ ```
42
+ ADDPATH ${COMMON}/bin
43
+ ADDPATH ${COMMON}/node/bin
44
+ ```
45
+
46
+ ### `IMPORT <KEY>`
47
+ Copy an environment variable from the manager's environment into the geniejars's environment. The value is captured at build time and stored with the geniejars's prepared config. Fails the build if the variable is not set on the manager.
48
+
49
+ ```
50
+ IMPORT ANTHROPIC_API_KEY
51
+ IMPORT MY_SECRET_TOKEN
52
+ ```
53
+
54
+ ### `DEPEND <path>`
55
+ Assert that a path exists on the manager's filesystem before the build proceeds. If the path is missing, the build fails with a clear error. Typically used with `${COMMON}` to validate that a shared tool was installed before trying to use it.
56
+
57
+ ```
58
+ DEPEND ${COMMON}/claude/bin/claude
59
+ DEPEND /opt/my-tool/bin/my-tool
60
+ ```
61
+
62
+ ### `CMD <command>`
63
+ Define the main process to start when `node script/run.mjs <name>` is called. Only the last `CMD` in the file takes effect.
64
+
65
+ Plain string form (runs via `sh -c`):
66
+ ```
67
+ CMD node app/server.js
68
+ ```
69
+
70
+ JSON array form (preferred — no shell interpretation):
71
+ ```
72
+ CMD ["node", "app/server.js", "--port", "3000"]
73
+ ```
74
+
75
+ ## Common directory
76
+
77
+ `${COMMON}` expands to the `commonDir` path from `geniejars.config.json` (default: `/opt/geniejars-common`). This is a shared read-only space where the manager installs tools that geniejars need access to — for example a pinned version of `claude` or shared node modules.
78
+
79
+ ```
80
+ DEPEND ${COMMON}/claude/bin/claude
81
+ COPY ${COMMON}/claude/bin/claude bin/claude
82
+ ```
83
+
84
+ `${COMMON}` is substituted before the file is parsed, so it works in any directive.
85
+
86
+ ## Port allocation
87
+
88
+ Each geniejars is pre-assigned a fixed number of ports at `allocate` time (configured via `portsPerGeniejars` in `geniejars.config.json`). These ports can be referenced in any directive using the `${PORT(n)}` syntax, where `n` is 1-indexed.
89
+
90
+ ```
91
+ ${PORT(1)} # first assigned port
92
+ ${PORT(2)} # second assigned port
93
+ ```
94
+
95
+ Substitution happens before the file is parsed, so `${PORT(n)}` works anywhere — in `ENV`, `RUN`, `COPY`, and `CMD`.
96
+
97
+ At `run` time the ports are also automatically injected as `PORT_1`, `PORT_2`, etc. into the main process environment, regardless of whether `ENV` was used in the GeniejarsFile.
98
+
99
+ ## Comments and blank lines
100
+
101
+ Lines starting with `#` are comments. Blank lines are ignored.
102
+
103
+ ```
104
+ # This is a comment
105
+ ```
106
+
107
+ ## Example
108
+
109
+ ```
110
+ # Build a Node.js app in a geniejars sandbox
111
+ ENV NODE_ENV=production
112
+ ENV PORT=${PORT(1)}
113
+ ENV DEBUG_PORT=${PORT(2)}
114
+
115
+ WORKDIR app
116
+ COPY ./myapp .
117
+
118
+ RUN npm install --omit=dev
119
+
120
+ CMD ["node", "server.js"]
121
+ ```
122
+
123
+ ## Usage
124
+
125
+ ```
126
+ node script/build.mjs <name> [GeniejarsFile] # apply this file to a geniejars
127
+ node script/run.mjs <name> # start the CMD
128
+ node script/exec.mjs <name> <cmd> [args...] # run a one-off command
129
+ node script/stop.mjs <name> # stop the main process
130
+ ```
package/README.md CHANGED
@@ -144,7 +144,7 @@ The `JFile` format mirrors Dockerfile. Supported directives:
144
144
 
145
145
  Port placeholders `${PORT(1)}`, `${PORT(2)}` etc. are substituted with the geniejars's pre-assigned ports at build time. `${COMMON}` expands to `commonDir`.
146
146
 
147
- See [SUBFILE.md](./SUBFILE.md) for full documentation.
147
+ See [JFILE.md](./JFILE.md) for full documentation.
148
148
 
149
149
  ## Library usage
150
150
 
@@ -213,6 +213,10 @@ script/
213
213
  uninstall-geniejars.mjs remove all geniejars and system config (run as root)
214
214
  ```
215
215
 
216
+ ## Common Issues
217
+
218
+ See [COMMON-ISSUES.md](./COMMON-ISSUES.md) for solving common issues.
219
+
216
220
  ## License
217
221
 
218
222
  MIT — see [LICENSE.md](./LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geniejars",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "description": "Linux geniejars sandboxing — library and CLI for running processes as isolated system users",
6
6
  "main": "src/index.mjs",
@@ -10,11 +10,14 @@
10
10
  "bin": {
11
11
  "geniejars": "script/geniejars.mjs"
12
12
  },
13
+ "license": "MIT",
13
14
  "files": [
14
15
  "src/",
15
16
  "script/",
16
17
  "geniejars.config.example.json",
17
- "COMMON-ISSUES.md"
18
+ "COMMON-ISSUES.md",
19
+ "LICENSE.md",
20
+ "JFILE.md"
18
21
  ],
19
22
  "engines": {
20
23
  "node": ">=18.17.0"