@platformatic/service 1.36.0 → 1.36.1
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.
- package/lib/start.js +7 -2
- package/lib/utils.js +29 -1
- package/package.json +8 -8
- package/schema.json +2 -2
package/lib/start.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
const { readFile } = require('fs/promises')
|
|
4
4
|
const close = require('close-with-grace')
|
|
5
5
|
const { loadConfig, ConfigManager, printConfigValidationErrors, printAndExitLoadConfigError } = require('@platformatic/config')
|
|
6
|
-
const { addLoggerToTheConfig } = require('./utils.js')
|
|
6
|
+
const { addLoggerToTheConfig, isDocker } = require('./utils.js')
|
|
7
7
|
const { restartable } = require('@fastify/restartable')
|
|
8
8
|
const { randomUUID } = require('crypto')
|
|
9
|
+
|
|
9
10
|
async function adjustHttpsKeyAndCert (arg) {
|
|
10
11
|
if (typeof arg === 'string') {
|
|
11
12
|
return arg
|
|
@@ -47,13 +48,17 @@ async function buildServer (options, app) {
|
|
|
47
48
|
async function createRestartable (fastify) {
|
|
48
49
|
const config = configManager.current
|
|
49
50
|
let fastifyOptions = {}
|
|
51
|
+
|
|
50
52
|
if (config.server) {
|
|
53
|
+
// override hostname if it's docker
|
|
54
|
+
if (await isDocker()) {
|
|
55
|
+
config.server.hostname = '0.0.0.0'
|
|
56
|
+
}
|
|
51
57
|
fastifyOptions = {
|
|
52
58
|
...config.server
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
fastifyOptions.genReqId = function (req) { return randomUUID() }
|
|
56
|
-
|
|
57
62
|
const root = fastify(fastifyOptions)
|
|
58
63
|
root.decorate('platformatic', { configManager, config })
|
|
59
64
|
await root.register(app)
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { access } = require('node:fs/promises')
|
|
3
|
+
const { access, readFile, stat } = require('node:fs/promises')
|
|
4
4
|
const { resolve, join, relative, dirname, basename } = require('node:path')
|
|
5
5
|
const { isatty } = require('tty')
|
|
6
6
|
|
|
@@ -190,7 +190,35 @@ function changeOpenapiSchemaPrefix (openapiSchema, oldVersionPrefix, newVersionP
|
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
+
let isDockerCached
|
|
194
|
+
|
|
195
|
+
async function isDocker () {
|
|
196
|
+
async function hasDockerEnv () {
|
|
197
|
+
try {
|
|
198
|
+
await stat('/.dockerenv')
|
|
199
|
+
return true
|
|
200
|
+
} catch {
|
|
201
|
+
return false
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async function hasDockerCGroup () {
|
|
206
|
+
try {
|
|
207
|
+
return (await readFile('/proc/self/cgroup', 'utf8')).includes('docker')
|
|
208
|
+
} catch {
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (isDockerCached === undefined) {
|
|
214
|
+
isDockerCached = await hasDockerEnv() || await hasDockerCGroup()
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return isDockerCached
|
|
218
|
+
}
|
|
219
|
+
|
|
193
220
|
module.exports = {
|
|
221
|
+
isDocker,
|
|
194
222
|
isFileAccessible,
|
|
195
223
|
getJSPluginPath,
|
|
196
224
|
addLoggerToTheConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"semgrator": "^0.3.0",
|
|
79
79
|
"ua-parser-js": "^1.0.37",
|
|
80
80
|
"undici": "^6.9.0",
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/generators": "1.36.
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/
|
|
87
|
-
"@platformatic/
|
|
81
|
+
"@platformatic/client": "1.36.1",
|
|
82
|
+
"@platformatic/generators": "1.36.1",
|
|
83
|
+
"@platformatic/config": "1.36.1",
|
|
84
|
+
"@platformatic/scalar-theme": "1.36.1",
|
|
85
|
+
"@platformatic/authenticate": "1.36.1",
|
|
86
|
+
"@platformatic/telemetry": "1.36.1",
|
|
87
|
+
"@platformatic/utils": "1.36.1"
|
|
88
88
|
},
|
|
89
89
|
"standard": {
|
|
90
90
|
"ignore": [
|
package/schema.json
CHANGED