Skip to content

Commit 804f91c

Browse files
authored
Add Dir and Mounts support (#102)
1 parent 4eab899 commit 804f91c

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

examples/swarm-app.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ service_specs:
4646
replicas: 2
4747
stop_signal: SIGQUIT
4848
stop_grace_period: 10
49+
user: '0'
50+
dir: /etc/nginx
4951
placement:
5052
preferences:
5153
- { spread: node.hostname }

schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
}
157157
}
158158
},
159+
"dir": {
160+
"type": "string"
161+
},
159162
"mounts": {
160163
"values": {
161164
"properties": {

src/service-spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function initServiceSpec ({appName, serviceName, config, hashedConfigs, c
7979
User: serviceConfig.user,
8080
Configs: configs,
8181
Isolation: "default",
82+
Dir: serviceConfig.dir,
8283
HealthCheck: {
8384
Test: serviceConfig.health_check?.test,
8485
Interval: serviceConfig.health_check?.interval,
@@ -87,6 +88,14 @@ export function initServiceSpec ({appName, serviceName, config, hashedConfigs, c
8788
StartInterval: serviceConfig.health_check?.start_interval,
8889
Retries: serviceConfig.health_check?.retries,
8990
},
91+
Mounts: Object.entries(serviceConfig.mounts ?? {}).map(([t, m]) => {
92+
return {
93+
Target: t,
94+
Source: m.source,
95+
Type: m.type,
96+
ReadOnly: m.readonly,
97+
};
98+
}),
9099
},
91100
Placement: {
92101
Constraints: serviceConfig.placement?.constraints,

src/swarm-app-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface SwarmAppServiceConfig {
5353
start_period?: number;
5454
start_interval?: number;
5555
};
56+
dir?: string;
5657
mounts?: Record<string, {
5758
source: string;
5859
type: "bind" | "volume";
@@ -144,6 +145,7 @@ export const swarmAppConfigSchema: JTDSchemaType<SwarmAppConfig> = {
144145
start_interval: {type: "int32"},
145146
},
146147
},
148+
dir: {type: "string"},
147149
mounts: {
148150
values: {
149151
properties: {

0 commit comments

Comments
 (0)