ruby-ship 0.1.0
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.
- checksums.yaml +7 -0
- data/LICENSE.md +21 -0
- data/README.md +175 -0
- data/docs/extensions.md +38 -0
- data/exe/ship +4 -0
- data/lib/ship/application.rb +123 -0
- data/lib/ship/cli.rb +429 -0
- data/lib/ship/compose.rb +288 -0
- data/lib/ship/config.rb +160 -0
- data/lib/ship/docker.rb +123 -0
- data/lib/ship/environment_files.rb +227 -0
- data/lib/ship/extensions.rb +70 -0
- data/lib/ship/project.rb +255 -0
- data/lib/ship/release.rb +332 -0
- data/lib/ship/services.rb +103 -0
- data/lib/ship/setup.rb +318 -0
- data/lib/ship/setup_options.rb +317 -0
- data/lib/ship/terminal.rb +205 -0
- data/lib/ship/version.rb +3 -0
- data/lib/ship.rb +6 -0
- data/schema/service-environment.json +23 -0
- data/schema/ship-release.schema.json +145 -0
- data/schema/ship.schema.json +507 -0
- data/templates/entrypoint.rb +19 -0
- data/templates/garage/Dockerfile +7 -0
- data/templates/garage/garage.toml +15 -0
- data/templates/mongodb/Dockerfile +7 -0
- data/templates/mongodb/app-user.js +4 -0
- data/templates/mongodb/bootstrap.js +28 -0
- data/templates/mongodb/bootstrap.sh +10 -0
- data/templates/mongodb/entrypoint.sh +20 -0
- data/templates/mongodb/health.js +18 -0
- data/templates/services.json +1783 -0
- metadata +70 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/ship-ecosystem/spec/main/schemas/ship.schema.json",
|
|
4
|
+
"title": "ship.json",
|
|
5
|
+
"description": "Project configuration for the Ship ecosystem (PHP Ship, Python Ship, JavaScript Ship). The source of truth is https://github.com/ship-ecosystem/spec; producers keep a copy that their CI checks against it. Fields marked PHP, Python or JavaScript are read only by that package; the others mean the same in every producer.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "The URL of this schema, for editors."
|
|
12
|
+
},
|
|
13
|
+
"name": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$",
|
|
16
|
+
"description": "The Compose project name. Defaults to the sanitized project directory name."
|
|
17
|
+
},
|
|
18
|
+
"services": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"description": "One selected service key per group (database, cache, storage, search, mail, testing, frontend, ...). A group without an entry means none. PostgreSQL is \"postgres\".",
|
|
21
|
+
"additionalProperties": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"minLength": 1
|
|
24
|
+
},
|
|
25
|
+
"examples": [
|
|
26
|
+
{
|
|
27
|
+
"database": "postgres",
|
|
28
|
+
"cache": "redis"
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"additionalServices": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"description": "Extra, named instances of a service. The name becomes the Compose service suffix ({service}-{name}) and the environment variable prefix ({NAME}_).",
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": false,
|
|
38
|
+
"required": [
|
|
39
|
+
"group",
|
|
40
|
+
"service",
|
|
41
|
+
"name"
|
|
42
|
+
],
|
|
43
|
+
"properties": {
|
|
44
|
+
"group": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"minLength": 1
|
|
47
|
+
},
|
|
48
|
+
"service": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 1
|
|
51
|
+
},
|
|
52
|
+
"name": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"pattern": "^[a-z][a-z0-9_]*$"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"serviceNames": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Renames Compose services: default name (\"app\", or a selected service key) to a new name.",
|
|
62
|
+
"additionalProperties": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"externalNetwork": {
|
|
68
|
+
"description": "Docker networks created outside Ship (a reverse proxy's, say), attached to the app and to every service that receives HTTP: one name, or a list of names.",
|
|
69
|
+
"oneOf": [
|
|
70
|
+
{
|
|
71
|
+
"$ref": "#/$defs/networkName"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"type": "array",
|
|
75
|
+
"minItems": 1,
|
|
76
|
+
"uniqueItems": true,
|
|
77
|
+
"items": {
|
|
78
|
+
"$ref": "#/$defs/networkName"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"extensions": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"description": "Explicit trusted community extensions: PHP class names, Python entry point names, or JavaScript relative module paths.",
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"minLength": 1
|
|
89
|
+
},
|
|
90
|
+
"uniqueItems": true
|
|
91
|
+
},
|
|
92
|
+
"siloImage": {
|
|
93
|
+
"enum": [
|
|
94
|
+
"standard",
|
|
95
|
+
"distroless"
|
|
96
|
+
],
|
|
97
|
+
"description": "Silo's image variant. The standard image needs an x86-64-v2 CPU."
|
|
98
|
+
},
|
|
99
|
+
"publishPorts": {
|
|
100
|
+
"type": "boolean",
|
|
101
|
+
"description": "Publish the app's port to the host in production. Development always publishes on 127.0.0.1."
|
|
102
|
+
},
|
|
103
|
+
"portPublishing": {
|
|
104
|
+
"type": "object",
|
|
105
|
+
"description": "Explicitly select the generated ports to publish per environment. Takes precedence over publishPorts. Development binds to localhost; production can bind to all host interfaces. Empty lists publish no ports in that environment.",
|
|
106
|
+
"additionalProperties": false,
|
|
107
|
+
"required": ["development", "production"],
|
|
108
|
+
"properties": {
|
|
109
|
+
"development": { "$ref": "#/$defs/publishedPortList" },
|
|
110
|
+
"production": { "$ref": "#/$defs/publishedPortList" }
|
|
111
|
+
},
|
|
112
|
+
"examples": [
|
|
113
|
+
{ "development": ["webserver:80", "postgres:5432"], "production": [] }
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"hostUser": {
|
|
117
|
+
"type": "boolean",
|
|
118
|
+
"description": "Run the development app as the host user's UID/GID on Linux. Defaults: false in PHP, true in Python."
|
|
119
|
+
},
|
|
120
|
+
"deployCommands": {
|
|
121
|
+
"type": "array",
|
|
122
|
+
"description": "Commands run once per deploy, before the app starts (migrations, typically). Python also accepts argument lists.",
|
|
123
|
+
"items": {
|
|
124
|
+
"$ref": "#/$defs/command"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"processes": {
|
|
128
|
+
"type": "object",
|
|
129
|
+
"description": "Extra long-running processes from the app's image (workers, schedulers, servers): name to command, or to an object with the command, an optional healthcheck command, and an optional http block saying the process receives HTTP traffic, which puts it in the release's http[] with an HTTP health check. Python also accepts argument lists.",
|
|
130
|
+
"propertyNames": {
|
|
131
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$"
|
|
132
|
+
},
|
|
133
|
+
"additionalProperties": {
|
|
134
|
+
"oneOf": [
|
|
135
|
+
{
|
|
136
|
+
"$ref": "#/$defs/command"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "object",
|
|
140
|
+
"required": [
|
|
141
|
+
"command"
|
|
142
|
+
],
|
|
143
|
+
"additionalProperties": false,
|
|
144
|
+
"properties": {
|
|
145
|
+
"command": {
|
|
146
|
+
"$ref": "#/$defs/command"
|
|
147
|
+
},
|
|
148
|
+
"healthcheck": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"minLength": 1,
|
|
151
|
+
"description": "A shell command, run in the process's container, that exits 0 while the process works. Without it: an HTTP check when http is set, otherwise that the process stayed up."
|
|
152
|
+
},
|
|
153
|
+
"http": {
|
|
154
|
+
"type": "object",
|
|
155
|
+
"description": "The process receives HTTP traffic: its release.json http[] entry, with the same fields.",
|
|
156
|
+
"required": [
|
|
157
|
+
"port",
|
|
158
|
+
"role"
|
|
159
|
+
],
|
|
160
|
+
"additionalProperties": false,
|
|
161
|
+
"properties": {
|
|
162
|
+
"port": {
|
|
163
|
+
"type": "integer",
|
|
164
|
+
"minimum": 1,
|
|
165
|
+
"maximum": 65535,
|
|
166
|
+
"description": "Container port the process listens on."
|
|
167
|
+
},
|
|
168
|
+
"role": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"minLength": 1,
|
|
171
|
+
"description": "Open list: site, websocket. Unknown: plain HTTP."
|
|
172
|
+
},
|
|
173
|
+
"health": {
|
|
174
|
+
"type": [
|
|
175
|
+
"string",
|
|
176
|
+
"null"
|
|
177
|
+
],
|
|
178
|
+
"pattern": "^/",
|
|
179
|
+
"description": "Path answering 2xx while the process works; null or absent when unknown."
|
|
180
|
+
},
|
|
181
|
+
"urlSetting": {
|
|
182
|
+
"type": [
|
|
183
|
+
"string",
|
|
184
|
+
"null"
|
|
185
|
+
],
|
|
186
|
+
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
|
|
187
|
+
"description": "Name of the setting holding the public address browsers use; null or absent when unknown. A name, never a value."
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
"php": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"pattern": "^\\d+\\.\\d+(?:\\.\\d+)?$",
|
|
199
|
+
"description": "PHP: the PHP branch (or release) built into the image."
|
|
200
|
+
},
|
|
201
|
+
"node": {
|
|
202
|
+
"type": "string",
|
|
203
|
+
"description": "Node.js major version for PHP/Python asset tooling or JavaScript application runtime."
|
|
204
|
+
},
|
|
205
|
+
"phpExtensions": {
|
|
206
|
+
"type": "array",
|
|
207
|
+
"description": "PHP: extra PHP extensions to install.",
|
|
208
|
+
"items": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"minLength": 1
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"framework": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$",
|
|
216
|
+
"description": "Python or JavaScript: framework adapter key."
|
|
217
|
+
},
|
|
218
|
+
"app": {
|
|
219
|
+
"type": "string",
|
|
220
|
+
"pattern": "^[A-Za-z_]\\w*(?:\\.[A-Za-z_]\\w*)*:[A-Za-z_]\\w*(?:\\(\\))?$",
|
|
221
|
+
"description": "Python: ASGI or WSGI module:callable target; optional () calls a zero-argument application factory."
|
|
222
|
+
},
|
|
223
|
+
"python": {
|
|
224
|
+
"type": "string",
|
|
225
|
+
"pattern": "^3\\.\\d+(?:\\.\\d+)?$",
|
|
226
|
+
"description": "Python: the Python branch (or release) built into the image."
|
|
227
|
+
},
|
|
228
|
+
"server": {
|
|
229
|
+
"type": "string",
|
|
230
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*$",
|
|
231
|
+
"description": "Python: the web server: uvicorn, hypercorn, granian (ASGI); gunicorn, granian (WSGI); or an extension's key. Defaults to the one recommended for the app."
|
|
232
|
+
},
|
|
233
|
+
"nodeAssets": {
|
|
234
|
+
"type": "boolean",
|
|
235
|
+
"description": "Python: build npm assets into the production image."
|
|
236
|
+
},
|
|
237
|
+
"djangoCollectstatic": {
|
|
238
|
+
"type": "boolean",
|
|
239
|
+
"description": "Python: run collectstatic at every production boot (Django only)."
|
|
240
|
+
},
|
|
241
|
+
"workspace": {
|
|
242
|
+
"anyOf": [
|
|
243
|
+
{
|
|
244
|
+
"type": "object",
|
|
245
|
+
"additionalProperties": false,
|
|
246
|
+
"properties": {
|
|
247
|
+
"app": {
|
|
248
|
+
"$ref": "#/$defs/relativePath"
|
|
249
|
+
},
|
|
250
|
+
"buildDependencies": {
|
|
251
|
+
"type": "array",
|
|
252
|
+
"uniqueItems": true,
|
|
253
|
+
"items": {
|
|
254
|
+
"$ref": "#/$defs/relativePath"
|
|
255
|
+
},
|
|
256
|
+
"default": []
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
"required": [
|
|
260
|
+
"app"
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"type": "null"
|
|
265
|
+
}
|
|
266
|
+
],
|
|
267
|
+
"default": null,
|
|
268
|
+
"description": "JavaScript: Select an app inside a root npm/pnpm/Yarn workspace; buildDependencies lists package paths built first, in order."
|
|
269
|
+
},
|
|
270
|
+
"build": {
|
|
271
|
+
"type": "object",
|
|
272
|
+
"additionalProperties": false,
|
|
273
|
+
"properties": {
|
|
274
|
+
"publicEnv": {
|
|
275
|
+
"type": "object",
|
|
276
|
+
"propertyNames": {
|
|
277
|
+
"$ref": "#/$defs/environmentName"
|
|
278
|
+
},
|
|
279
|
+
"additionalProperties": {
|
|
280
|
+
"type": "string",
|
|
281
|
+
"pattern": "^[^\\u0000]*$"
|
|
282
|
+
},
|
|
283
|
+
"default": {},
|
|
284
|
+
"description": "PUBLIC literal strings for builds and development. Never put credentials here."
|
|
285
|
+
},
|
|
286
|
+
"secrets": {
|
|
287
|
+
"type": "array",
|
|
288
|
+
"uniqueItems": true,
|
|
289
|
+
"items": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"allOf": [
|
|
292
|
+
{
|
|
293
|
+
"$ref": "#/$defs/environmentName"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"not": {
|
|
297
|
+
"pattern": "^(?:VITE_|NEXT_PUBLIC_|NUXT_PUBLIC_|PUBLIC_|GATSBY_|REACT_APP_)"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
"default": [],
|
|
303
|
+
"description": "Build-only environment names. Contents come from .ship-secrets/NAME; public framework prefixes are forbidden."
|
|
304
|
+
},
|
|
305
|
+
"npmrc": {
|
|
306
|
+
"type": "boolean",
|
|
307
|
+
"default": false,
|
|
308
|
+
"description": "Mount .ship-secrets/npmrc for npm/pnpm dependency operations, never production runtime."
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
"description": "JavaScript and Python: explicit public build values and temporary credentials; runtime .env files are excluded from builds."
|
|
312
|
+
},
|
|
313
|
+
"deployment": {
|
|
314
|
+
"type": "string",
|
|
315
|
+
"enum": [
|
|
316
|
+
"node",
|
|
317
|
+
"static"
|
|
318
|
+
],
|
|
319
|
+
"description": "JavaScript: Runtime strategy. Supported modes depend on the framework adapter."
|
|
320
|
+
},
|
|
321
|
+
"javascriptRuntime": {
|
|
322
|
+
"type": "string",
|
|
323
|
+
"enum": ["node", "bun"],
|
|
324
|
+
"default": "node",
|
|
325
|
+
"description": "JavaScript: Runtime for server package scripts. Bun availability depends on the selected framework and deployment mode."
|
|
326
|
+
},
|
|
327
|
+
"serverEntry": {
|
|
328
|
+
"anyOf": [
|
|
329
|
+
{
|
|
330
|
+
"$ref": "#/$defs/relativePath"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"type": "null"
|
|
334
|
+
}
|
|
335
|
+
],
|
|
336
|
+
"default": null,
|
|
337
|
+
"description": "JavaScript: Framework Node server entry relative to the app root."
|
|
338
|
+
},
|
|
339
|
+
"runtimeFiles": {
|
|
340
|
+
"type": "array",
|
|
341
|
+
"items": {
|
|
342
|
+
"$ref": "#/$defs/relativePath"
|
|
343
|
+
},
|
|
344
|
+
"default": [],
|
|
345
|
+
"description": "JavaScript: Extra files required by isolated Node runtime packaging."
|
|
346
|
+
},
|
|
347
|
+
"angularProject": {
|
|
348
|
+
"anyOf": [
|
|
349
|
+
{
|
|
350
|
+
"type": "string",
|
|
351
|
+
"pattern": "^[a-z][a-z0-9]*(?:[-_][a-z0-9]+)*(?![\\s\\S])"
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
"type": "null"
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
"default": null,
|
|
358
|
+
"description": "JavaScript: angularProject"
|
|
359
|
+
},
|
|
360
|
+
"mongodbMode": {
|
|
361
|
+
"type": "string",
|
|
362
|
+
"enum": [
|
|
363
|
+
"standalone",
|
|
364
|
+
"replica-set"
|
|
365
|
+
],
|
|
366
|
+
"default": "replica-set",
|
|
367
|
+
"description": "JavaScript: mongodbMode"
|
|
368
|
+
},
|
|
369
|
+
"packageManager": {
|
|
370
|
+
"type": "string",
|
|
371
|
+
"enum": [
|
|
372
|
+
"npm",
|
|
373
|
+
"pnpm",
|
|
374
|
+
"yarn"
|
|
375
|
+
],
|
|
376
|
+
"default": "npm",
|
|
377
|
+
"description": "JavaScript: packageManager"
|
|
378
|
+
},
|
|
379
|
+
"packageManagerVersion": {
|
|
380
|
+
"type": "string",
|
|
381
|
+
"pattern": "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?![\\s\\S])",
|
|
382
|
+
"examples": [
|
|
383
|
+
"12.2.2",
|
|
384
|
+
"12.21.0",
|
|
385
|
+
"4.18.1"
|
|
386
|
+
],
|
|
387
|
+
"description": "JavaScript: Exact stable version; must match package.json when declared there."
|
|
388
|
+
},
|
|
389
|
+
"scripts": {
|
|
390
|
+
"type": "object",
|
|
391
|
+
"additionalProperties": false,
|
|
392
|
+
"properties": {
|
|
393
|
+
"dev": {
|
|
394
|
+
"$ref": "#/$defs/script"
|
|
395
|
+
},
|
|
396
|
+
"build": {
|
|
397
|
+
"anyOf": [
|
|
398
|
+
{
|
|
399
|
+
"$ref": "#/$defs/script"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"type": "null"
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
"start": {
|
|
407
|
+
"anyOf": [
|
|
408
|
+
{
|
|
409
|
+
"$ref": "#/$defs/script"
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
"type": "null"
|
|
413
|
+
}
|
|
414
|
+
]
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
"description": "JavaScript: Names of package.json scripts, not shell commands."
|
|
418
|
+
},
|
|
419
|
+
"port": {
|
|
420
|
+
"type": "integer",
|
|
421
|
+
"minimum": 1,
|
|
422
|
+
"maximum": 65535,
|
|
423
|
+
"default": 3000,
|
|
424
|
+
"description": "JavaScript: port"
|
|
425
|
+
},
|
|
426
|
+
"outputDirectory": {
|
|
427
|
+
"anyOf": [
|
|
428
|
+
{
|
|
429
|
+
"$ref": "#/$defs/relativePath"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"type": "null"
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
"default": null,
|
|
436
|
+
"description": "JavaScript: Framework build output relative to the app root."
|
|
437
|
+
},
|
|
438
|
+
"staticRouting": {
|
|
439
|
+
"type": "string",
|
|
440
|
+
"enum": [
|
|
441
|
+
"spa",
|
|
442
|
+
"html"
|
|
443
|
+
],
|
|
444
|
+
"default": "spa",
|
|
445
|
+
"description": "JavaScript: staticRouting"
|
|
446
|
+
},
|
|
447
|
+
"basePath": {
|
|
448
|
+
"type": "string",
|
|
449
|
+
"pattern": "^\\/(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\\/)*(?![\\s\\S])",
|
|
450
|
+
"default": "/",
|
|
451
|
+
"examples": [
|
|
452
|
+
"/",
|
|
453
|
+
"/docs/"
|
|
454
|
+
],
|
|
455
|
+
"description": "JavaScript: basePath"
|
|
456
|
+
}
|
|
457
|
+
},
|
|
458
|
+
"$defs": {
|
|
459
|
+
"publishedPortList": {
|
|
460
|
+
"type": "array",
|
|
461
|
+
"uniqueItems": true,
|
|
462
|
+
"items": {
|
|
463
|
+
"type": "string",
|
|
464
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]*:(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])(?:/(?:udp|sctp))?$",
|
|
465
|
+
"description": "Generated Compose service name (after any rename) followed by its default container port. TCP is implicit; use /udp or /sctp for those protocols."
|
|
466
|
+
}
|
|
467
|
+
},
|
|
468
|
+
"networkName": {
|
|
469
|
+
"type": "string",
|
|
470
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9_.-]*$"
|
|
471
|
+
},
|
|
472
|
+
"command": {
|
|
473
|
+
"oneOf": [
|
|
474
|
+
{
|
|
475
|
+
"type": "string",
|
|
476
|
+
"minLength": 1
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
"type": "array",
|
|
480
|
+
"minItems": 1,
|
|
481
|
+
"prefixItems": [
|
|
482
|
+
{
|
|
483
|
+
"type": "string",
|
|
484
|
+
"minLength": 1
|
|
485
|
+
}
|
|
486
|
+
],
|
|
487
|
+
"items": {
|
|
488
|
+
"type": "string"
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
"relativePath": {
|
|
494
|
+
"type": "string",
|
|
495
|
+
"pattern": "^(?!\\.{1,2}(?:\\/|$))(?!.*\\/\\.{1,2}(?:\\/|$))[A-Za-z0-9_.-]+(?:\\/[A-Za-z0-9_.-]+)*(?![\\s\\S])",
|
|
496
|
+
"description": "Relative path without traversal, spaces or shell/config syntax."
|
|
497
|
+
},
|
|
498
|
+
"script": {
|
|
499
|
+
"type": "string",
|
|
500
|
+
"pattern": "^[a-zA-Z0-9:_-]+(?![\\s\\S])"
|
|
501
|
+
},
|
|
502
|
+
"environmentName": {
|
|
503
|
+
"type": "string",
|
|
504
|
+
"pattern": "^(?!(?:SHIP_|NODE_|NPM_|PNPM_|LD_|DYLD_))(?!(?:PATH|HOME|ENV|BASH_ENV|SHELL|IFS|CI|COREPACK_HOME|HOST|HOSTNAME|PORT|NG_ALLOWED_HOSTS)$)[A-Z][A-Z0-9_]*(?![\\s\\S])"
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require "uri"
|
|
3
|
+
|
|
4
|
+
# Rails merges DATABASE_URL into database.yml. Keep credentials out of Compose URLs.
|
|
5
|
+
if ENV["RAILS_ENV"] && ENV["DATABASE_URL"].to_s.empty?
|
|
6
|
+
if ENV["SHIP_DATABASE"] == "sqlite" && ENV["RAILS_ENV"] == "production"
|
|
7
|
+
ENV["DATABASE_URL"] = "sqlite3:#{ENV.fetch('SHIP_SQLITE_PATH')}"
|
|
8
|
+
elsif ENV["DB_HOST"]
|
|
9
|
+
scheme = { "postgres" => "postgresql", "mysql" => "mysql2", "mariadb" => "mysql2", "sqlserver" => "sqlserver" }[ENV["SHIP_DATABASE"]]
|
|
10
|
+
if scheme
|
|
11
|
+
database = ENV.fetch("DB_DATABASE")
|
|
12
|
+
database = ENV.fetch("DB_TEST_DATABASE", "#{database}_test") if ENV["RAILS_ENV"] == "test"
|
|
13
|
+
user, password, name = [ENV.fetch("DB_USERNAME"), ENV.fetch("DB_PASSWORD"), database].map { |value| URI.encode_uri_component(value) }
|
|
14
|
+
ENV["DATABASE_URL"] = "#{scheme}://#{user}:#{password}@#{ENV.fetch('DB_HOST')}:#{ENV.fetch('DB_PORT')}/#{name}"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
exec(*ARGV)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
metadata_dir = "/meta"
|
|
2
|
+
data_dir = "/data"
|
|
3
|
+
db_engine = "sqlite"
|
|
4
|
+
replication_factor = 1
|
|
5
|
+
|
|
6
|
+
rpc_bind_addr = "[::]:3901"
|
|
7
|
+
rpc_public_addr = "__GARAGE_RPC_PUBLIC_ADDR__"
|
|
8
|
+
|
|
9
|
+
[s3_api]
|
|
10
|
+
s3_region = "garage"
|
|
11
|
+
api_bind_addr = "[::]:3900"
|
|
12
|
+
root_domain = ".s3.garage.localhost"
|
|
13
|
+
|
|
14
|
+
[admin]
|
|
15
|
+
api_bind_addr = "[::]:3903"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
FROM mongo:9.0.8
|
|
2
|
+
COPY --chmod=755 docker/ship/mongodb/entrypoint.sh /usr/local/bin/ship-mongo
|
|
3
|
+
COPY --chmod=755 docker/ship/mongodb/bootstrap.sh /usr/local/bin/ship-mongo-bootstrap
|
|
4
|
+
COPY docker/ship/mongodb/bootstrap.js /usr/local/share/ship-mongo-bootstrap.js
|
|
5
|
+
COPY docker/ship/mongodb/health.js /usr/local/share/ship-mongo-health.js
|
|
6
|
+
COPY docker/ship/mongodb/app-user.js /docker-entrypoint-initdb.d/10-ship-user.js
|
|
7
|
+
ENTRYPOINT ["ship-mongo"]
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const name = process.env.MONGO_INITDB_DATABASE;
|
|
2
|
+
if (!name || ['admin', 'config', 'local'].includes(name)) throw new Error('Choose an application MongoDB database, not admin/config/local.');
|
|
3
|
+
if (!process.env.SHIP_MONGO_USER || !process.env.SHIP_MONGO_PASSWORD) throw new Error('MongoDB application credentials are required.');
|
|
4
|
+
db.getSiblingDB(name).createUser({ user: process.env.SHIP_MONGO_USER, pwd: process.env.SHIP_MONGO_PASSWORD, roles: [{ role: 'readWrite', db: name }] });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
function bootstrapReplicaSet() {
|
|
2
|
+
const admin = new Mongo('mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=1000&connectTimeoutMS=1000').getDB('admin');
|
|
3
|
+
const auth = admin.auth(process.env.MONGO_INITDB_ROOT_USERNAME, process.env.MONGO_INITDB_ROOT_PASSWORD);
|
|
4
|
+
if (auth !== true && auth !== 1 && auth?.ok !== 1) return 1;
|
|
5
|
+
const host = process.env.SHIP_MONGO_HOST + ':27017';
|
|
6
|
+
let result;
|
|
7
|
+
try { result = admin.runCommand({ replSetGetConfig: 1 }); }
|
|
8
|
+
catch (error) {
|
|
9
|
+
if (error.codeName !== 'NotYetInitialized' && error.code !== 94) return 1;
|
|
10
|
+
result = { ok: 0, codeName: 'NotYetInitialized' };
|
|
11
|
+
}
|
|
12
|
+
if (!result.ok) {
|
|
13
|
+
if (result.codeName !== 'NotYetInitialized') return 1; // never initiate the temporary standalone init server
|
|
14
|
+
const initiated = admin.runCommand({ replSetInitiate: { _id: 'rs0', members: [{ _id: 0, host }] } });
|
|
15
|
+
return initiated.ok ? 0 : 1;
|
|
16
|
+
}
|
|
17
|
+
const config = result.config;
|
|
18
|
+
if (config._id !== 'rs0' || config.members.length !== 1) return 1;
|
|
19
|
+
if (config.members[0].host !== host) {
|
|
20
|
+
config.members[0].host = host;
|
|
21
|
+
config.version += 1;
|
|
22
|
+
if (!admin.runCommand({ replSetReconfig: config, force: true }).ok) return 1;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
let exitCode = 1;
|
|
27
|
+
try { exitCode = bootstrapReplicaSet(); } catch { /* Do not print credential-bearing errors. */ }
|
|
28
|
+
quit(exitCode);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
attempt=0
|
|
4
|
+
while [ "$attempt" -lt 120 ]; do
|
|
5
|
+
if mongosh --nodb --quiet /usr/local/share/ship-mongo-bootstrap.js >/dev/null 2>&1; then exit 0; fi
|
|
6
|
+
attempt=$((attempt + 1))
|
|
7
|
+
sleep 1
|
|
8
|
+
done
|
|
9
|
+
echo 'ship: MongoDB replica-set bootstrap did not complete. Check credentials, mode and existing replica-set configuration.' >&2
|
|
10
|
+
exit 1
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
case "${SHIP_MONGO_MODE:-replica-set}" in
|
|
4
|
+
replica-set)
|
|
5
|
+
umask 077
|
|
6
|
+
if [ ! -s /data/configdb/ship-key ]; then
|
|
7
|
+
head -c 756 /dev/urandom | base64 | tr -d '\n' > /data/configdb/ship-key
|
|
8
|
+
fi
|
|
9
|
+
if [ "$(id -u)" = 0 ]; then chown mongodb:mongodb /data/configdb/ship-key; fi
|
|
10
|
+
chmod 400 /data/configdb/ship-key
|
|
11
|
+
# Detach under Docker's init so the bootstrap is reaped after completion.
|
|
12
|
+
if [ "$(id -u)" = 0 ]; then (gosu mongodb ship-mongo-bootstrap &)
|
|
13
|
+
else (ship-mongo-bootstrap &) fi
|
|
14
|
+
exec /usr/local/bin/docker-entrypoint.sh mongod --bind_ip_all --auth --replSet rs0 --keyFile /data/configdb/ship-key
|
|
15
|
+
;;
|
|
16
|
+
standalone)
|
|
17
|
+
exec /usr/local/bin/docker-entrypoint.sh mongod --bind_ip_all --auth
|
|
18
|
+
;;
|
|
19
|
+
*) echo 'ship: Invalid MongoDB mode.' >&2; exit 1 ;;
|
|
20
|
+
esac
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function healthStatus() {
|
|
2
|
+
const uri = 'mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=1000&connectTimeoutMS=1000';
|
|
3
|
+
const connection = new Mongo(uri);
|
|
4
|
+
const admin = connection.getDB('admin');
|
|
5
|
+
const rootAuth = admin.auth(process.env.MONGO_INITDB_ROOT_USERNAME, process.env.MONGO_INITDB_ROOT_PASSWORD);
|
|
6
|
+
if (rootAuth !== true && rootAuth !== 1 && rootAuth?.ok !== 1) return 1;
|
|
7
|
+
const options = admin.runCommand({ getCmdLineOpts: 1 });
|
|
8
|
+
if (options.parsed?.security?.authorization !== 'enabled') return 1; // temporary initialization is not readiness
|
|
9
|
+
const app = new Mongo(uri).getDB(process.env.MONGO_INITDB_DATABASE);
|
|
10
|
+
const appAuth = app.auth(process.env.SHIP_MONGO_USER, process.env.SHIP_MONGO_PASSWORD);
|
|
11
|
+
if (appAuth !== true && appAuth !== 1 && appAuth?.ok !== 1) return 1;
|
|
12
|
+
if (!app.runCommand({ ping: 1 }).ok) return 1;
|
|
13
|
+
if (process.env.SHIP_MONGO_MODE === 'replica-set' && !app.adminCommand({ hello: 1 }).isWritablePrimary) return 1;
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
let exitCode = 1;
|
|
17
|
+
try { exitCode = healthStatus(); } catch { /* Health output must not contain credentials. */ }
|
|
18
|
+
quit(exitCode);
|