You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `zerops.yaml` file is crucial for defining how Zerops should [build and deploy](/features/pipeline) your application.
27
27
Add the `zerops.yaml` file to the **root of your repository** and customize it to suit your application's needs.
28
28
29
+
:::note Parameter Availability
30
+
Not all parameters are available for every service type. Most parameters work across different runtime services, but some are specific to certain service types (e.g., documentRoot for webserver services, routing for Static services). This documentation covers zerops.yaml configuration for runtime services.
31
+
:::
32
+
29
33
---
30
34
31
35
<GroupCardsemoji="🙌"heading="Quick Links to Runtime-Specific Guides"items={languages} />
@@ -39,9 +43,7 @@ zerops:
39
43
run: ...
40
44
```
41
45
42
-
- The top-level element is always `zerops`.
43
-
- `setup`contains the **hostname** of your service (must exist in Zerops).
44
-
- Multiple services can be defined in a single `zerops.yaml` (useful for monorepos):
46
+
Multiple services can be defined in a single `zerops.yaml` (useful for monorepos):
45
47
46
48
```yaml
47
49
zerops:
@@ -56,7 +58,15 @@ zerops:
56
58
57
59
Each service configuration requires `build` and `run` sections. An optional `deploy` section can be added for readiness checks.
58
60
59
-
## Service Inheritance
61
+
## Service Configuration
62
+
63
+
### setup <Badge type="required" />
64
+
65
+
Contains the hostname of your service (must exist in Zerops).
66
+
67
+
```yaml
68
+
setup: my-service
69
+
```
60
70
61
71
### extends <Badge type="optional" />
62
72
@@ -67,26 +77,22 @@ zerops:
67
77
- setup: base
68
78
build:
69
79
buildCommands:
70
-
- echo "hello"
71
-
deployFiles: ./
80
+
- npm run build
81
+
deployFiles: ./dist
72
82
run:
73
-
start: server run
83
+
start: npm start
74
84
75
85
- setup: prod
76
86
extends: base
77
87
run:
78
-
crontab:
79
-
- command: xyz
80
-
allContainers: false
81
-
timing: "* * * * *"
88
+
envVariables:
89
+
NODE_ENV: production
82
90
83
91
- setup: dev
84
92
extends: base
85
93
run:
86
-
crontab:
87
-
- command: different command
88
-
allContainers: false
89
-
timing: "* * * * *"
94
+
envVariables:
95
+
NODE_ENV: development
90
96
```
91
97
92
98
When using `extends`:
@@ -294,10 +300,11 @@ Defines the port number on which your application listens. Must be between *10*
294
300
#### protocol <Badge type="optional" />
295
301
Specifies the network protocol to use:
296
302
- Allowed values: `TCP`*(default)* or `UDP`
303
+
297
304
#### httpSupport <Badge type="optional" />
298
305
Indicates whether the port is running a web server:
299
-
- Default value: `true`
300
-
- Set to `false` if a web server isn't running on the port
306
+
- Default value: `false`
307
+
- Set to `true` if a web server is running on the port
301
308
- Only available with TCP protocol
302
309
- Used by Zerops for [public access](/features/access) configuration
303
310
@@ -330,7 +337,7 @@ run:
330
337
331
338
### startCommands <Badge type="optional" />
332
339
333
-
Defines start commands
340
+
Defines start commands.
334
341
335
342
Unlike `start`, you can define multiple commands that starts their own processes.
@@ -373,6 +379,140 @@ Defines environment variables for the runtime environment.
373
379
DB_PASS: ${db_password}
374
380
```
375
381
382
+
### envReplace <Badge type="optional" />
383
+
384
+
Automatically replaces environment variable placeholders in your static files with their actual values during deployment.
385
+
386
+
```yaml
387
+
run:
388
+
envReplace:
389
+
delimiter: "%%"
390
+
target:
391
+
- config/jwt/public.pem
392
+
- config/jwt/private.pem
393
+
- ./config/
394
+
```
395
+
396
+
Available parameters:
397
+
398
+
#### delimiter <Badge type="required" />
399
+
Characters that wrap your variable names in placeholders (e.g., `%%` means placeholders look like `%%VARIABLE%%`).
400
+
- Type: `string`or `array of strings`
401
+
- Supports multiple delimiters simultaneously
402
+
403
+
#### target <Badge type="required" />
404
+
Files or directories to process for variable replacement.
405
+
- Type: `string`or `array of strings`
406
+
- Can be specific files or directories with glob patterns
407
+
- **Important**: Directory paths like `./` only process files in that directory, not subdirectories. For recursive processing, specify each subdirectory explicitly
408
+
409
+
**How it works:**
410
+
1. Define placeholders in your files using the specified delimiters
411
+
2. Set environment variables with matching names
412
+
3. During deployment, Zerops finds and replaces placeholders with actual values
413
+
414
+
**Example usage:**
415
+
416
+
```yaml
417
+
run:
418
+
envReplace:
419
+
delimiter: "%%"
420
+
target:
421
+
- ./config/
422
+
- ./templates/
423
+
- ./ # Only processes files in root, not subdirectories
424
+
```
425
+
426
+
File content before replacement:
427
+
```
428
+
# config/jwt/public.pem
429
+
%%JWT_PUBLIC_KEY_CONTENT%%
430
+
```
431
+
432
+
Environment variable:
433
+
```
434
+
JWT_PUBLIC_KEY_CONTENT=-----BEGIN PUBLIC KEY-----
435
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...
436
+
-----END PUBLIC KEY-----
437
+
```
438
+
439
+
The placeholder gets replaced with the actual JWT public key during deployment.
440
+
441
+
:::warning
442
+
When using `./` as target, only files directly in the root directory are processed. Subdirectories are ignored for performance reasons. To process subdirectories, specify each one explicitly in the target array.
443
+
:::
444
+
445
+
### routing <Badge type="optional" />
446
+
447
+
Configures URL routing, redirects, and HTTP headers (primarily for Static services).
448
+
449
+
```yaml
450
+
run:
451
+
routing:
452
+
root: /custom/root
453
+
cors: "'*' always"
454
+
redirects:
455
+
- from: /old-path
456
+
to: /new-path
457
+
status: 301
458
+
headers:
459
+
- for: "/*"
460
+
values:
461
+
X-Frame-Options: "'DENY'"
462
+
```
463
+
464
+
Available parameters:
465
+
466
+
#### root <Badge type="optional" />
467
+
Sets a custom root directory for the service.
468
+
- Type: `string`
469
+
470
+
#### cors <Badge type="optional" />
471
+
Enables CORS headers for cross-origin requests.
472
+
- Type: `string`
473
+
- Sets `Access-Control-Allow-Origin`, `Access-Control-Allow-Methods`, `Access-Control-Allow-Headers`, and `Access-Control-Expose-Headers`
474
+
- Special case: `"*"`is automatically converted to `'*'`
475
+
476
+
#### redirects <Badge type="optional" />
477
+
Defines URL redirects and rewrites.
478
+
- Type: `array of objects`
479
+
- Each redirect object supports:
480
+
- **from** <Badge type="required" /> - Source path to match (supports wildcards with `*`)
0 commit comments