@naturalcycles/backend-lib 9.29.0 → 9.30.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.
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { NonNegativeInteger, NumberOfMilliseconds, NumberOfSeconds, PositiveInteger, UnixTimestamp } from '@naturalcycles/js-lib/types';
|
|
2
|
+
export interface CloudRunDeployInfo {
|
|
3
|
+
gcpProject: string;
|
|
4
|
+
/**
|
|
5
|
+
* Name of the Cloud Run service.
|
|
6
|
+
*/
|
|
7
|
+
cloudRunService: string;
|
|
8
|
+
cloudRunServiceBase: string;
|
|
9
|
+
runtimeServiceAccount: string;
|
|
10
|
+
/**
|
|
11
|
+
* GCP region where the Cloud Run service is deployed. Example: 'europe-west1'
|
|
12
|
+
*/
|
|
13
|
+
cloudRunRegion: string;
|
|
14
|
+
sqlInstance?: string;
|
|
15
|
+
vpcConnector?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Service URL that is used to access the service externally (through load balancer)
|
|
18
|
+
* todo: overlaps with env.K_EXTERNAL_URL
|
|
19
|
+
*/
|
|
20
|
+
externalUrl: string;
|
|
21
|
+
serviceUrl: string;
|
|
22
|
+
buildVersion: string;
|
|
23
|
+
/**
|
|
24
|
+
* Unix timestamp of the build/deployment time.
|
|
25
|
+
*/
|
|
26
|
+
tsUnix: UnixTimestamp;
|
|
27
|
+
targetDockerImageId: string;
|
|
28
|
+
dockerImageTag: string;
|
|
29
|
+
/**
|
|
30
|
+
* Short SHA of the commit used for this deployment.
|
|
31
|
+
*/
|
|
32
|
+
gitRev: string;
|
|
33
|
+
gitBranch: string;
|
|
34
|
+
/**
|
|
35
|
+
* Example: 'APP_ENV=prod,BUILD_VERSION=abcd,a=b'
|
|
36
|
+
*/
|
|
37
|
+
envString: string;
|
|
38
|
+
/**
|
|
39
|
+
* Example: httpGet.path='/',httpGet.port=8080,initialDelaySeconds=3,failureThreshold=50,timeoutSeconds=1,periodSeconds=2
|
|
40
|
+
*/
|
|
41
|
+
startupProbeConfigString: string;
|
|
42
|
+
minInstances: NonNegativeInteger;
|
|
43
|
+
maxInstances: PositiveInteger;
|
|
44
|
+
/**
|
|
45
|
+
* CloudRun concurrency setting.
|
|
46
|
+
* Example: 80
|
|
47
|
+
*/
|
|
48
|
+
concurrency: PositiveInteger;
|
|
49
|
+
/**
|
|
50
|
+
* Example: '512Mi'
|
|
51
|
+
*/
|
|
52
|
+
memoryPerInstance: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CloudRunStartupProbeConfig {
|
|
55
|
+
/**
|
|
56
|
+
* Example: '/'
|
|
57
|
+
*/
|
|
58
|
+
'httpGet.path': string;
|
|
59
|
+
'httpGet.port': PositiveInteger;
|
|
60
|
+
initialDelaySeconds: NumberOfSeconds;
|
|
61
|
+
failureThreshold: PositiveInteger;
|
|
62
|
+
timeoutSeconds: NumberOfSeconds;
|
|
63
|
+
periodSeconds: NumberOfSeconds;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Experimental, subject to change.
|
|
67
|
+
*/
|
|
68
|
+
export declare const defaultStartupProbeConfig: CloudRunStartupProbeConfig;
|
|
69
|
+
export interface CloudRunEnv {
|
|
70
|
+
APP_ENV: string;
|
|
71
|
+
/**
|
|
72
|
+
* Example: '--max-old-space-size=864'
|
|
73
|
+
*/
|
|
74
|
+
NODE_OPTIONS: string;
|
|
75
|
+
/**
|
|
76
|
+
* Example: '2025-09-01T15:23:20.769Z'
|
|
77
|
+
* The result of running `new Date().toISOString()`
|
|
78
|
+
*/
|
|
79
|
+
DEPLOY_BUILD_TIME: string;
|
|
80
|
+
/**
|
|
81
|
+
* Example: 'abcd'
|
|
82
|
+
* Should match the name of the GCP project.
|
|
83
|
+
*/
|
|
84
|
+
GOOGLE_CLOUD_PROJECT: string;
|
|
85
|
+
/**
|
|
86
|
+
* Anything (a string) that would identify the build.
|
|
87
|
+
*/
|
|
88
|
+
BUILD_VERSION: string;
|
|
89
|
+
/**
|
|
90
|
+
* External url of the deployed service.
|
|
91
|
+
*/
|
|
92
|
+
K_EXTERNAL_URL?: string;
|
|
93
|
+
OTEL_SERVICE_NAME?: string;
|
|
94
|
+
OTEL_METRICS_EXPORTER?: 'console' | 'otlp' | string;
|
|
95
|
+
OTEL_METRIC_EXPORT_INTERVAL?: NumberOfMilliseconds;
|
|
96
|
+
OTEL_METRIC_EXPORT_TIMEOUT?: NumberOfMilliseconds;
|
|
97
|
+
OTEL_EXPORTER_OTLP_PROTOCOL?: 'http/protobuf' | string;
|
|
98
|
+
/**
|
|
99
|
+
* Example: 'http://localhost:4317'
|
|
100
|
+
*/
|
|
101
|
+
OTEL_EXPORTER_OTLP_ENDPOINT?: string;
|
|
102
|
+
OTEL_LOG_LEVEL?: 'INFO' | 'DEBUG';
|
|
103
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.30.1",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@sentry/node": "^10"
|
|
7
7
|
},
|
|
@@ -29,12 +29,13 @@
|
|
|
29
29
|
"@sentry/node": "^10",
|
|
30
30
|
"@types/ejs": "^3",
|
|
31
31
|
"fastify": "^5",
|
|
32
|
-
"@naturalcycles/dev-lib": "
|
|
32
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
33
33
|
},
|
|
34
34
|
"exports": {
|
|
35
35
|
".": "./dist/index.js",
|
|
36
36
|
"./admin": "./dist/admin/index.js",
|
|
37
37
|
"./admin/*.js": "./dist/admin/*.js",
|
|
38
|
+
"./cloudrun": "./dist/cloudrun/cloudRun.util.js",
|
|
38
39
|
"./db": "./dist/db/index.js",
|
|
39
40
|
"./deploy": "./dist/deploy/index.js",
|
|
40
41
|
"./deploy/*.js": "./dist/deploy/*.js",
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
NonNegativeInteger,
|
|
3
|
+
NumberOfMilliseconds,
|
|
4
|
+
NumberOfSeconds,
|
|
5
|
+
PositiveInteger,
|
|
6
|
+
UnixTimestamp,
|
|
7
|
+
} from '@naturalcycles/js-lib/types'
|
|
8
|
+
|
|
9
|
+
export interface CloudRunDeployInfo {
|
|
10
|
+
//
|
|
11
|
+
// GCP settings
|
|
12
|
+
//
|
|
13
|
+
gcpProject: string
|
|
14
|
+
/**
|
|
15
|
+
* Name of the Cloud Run service.
|
|
16
|
+
*/
|
|
17
|
+
cloudRunService: string
|
|
18
|
+
cloudRunServiceBase: string // todo: review
|
|
19
|
+
runtimeServiceAccount: string
|
|
20
|
+
/**
|
|
21
|
+
* GCP region where the Cloud Run service is deployed. Example: 'europe-west1'
|
|
22
|
+
*/
|
|
23
|
+
cloudRunRegion: string
|
|
24
|
+
sqlInstance?: string
|
|
25
|
+
vpcConnector?: string
|
|
26
|
+
//
|
|
27
|
+
// Urls
|
|
28
|
+
//
|
|
29
|
+
/**
|
|
30
|
+
* Service URL that is used to access the service externally (through load balancer)
|
|
31
|
+
* todo: overlaps with env.K_EXTERNAL_URL
|
|
32
|
+
*/
|
|
33
|
+
externalUrl: string
|
|
34
|
+
serviceUrl: string
|
|
35
|
+
//
|
|
36
|
+
// Versioning
|
|
37
|
+
//
|
|
38
|
+
buildVersion: string // todo: overlaps with env.BUILD_VERSION
|
|
39
|
+
/**
|
|
40
|
+
* Unix timestamp of the build/deployment time.
|
|
41
|
+
*/
|
|
42
|
+
tsUnix: UnixTimestamp
|
|
43
|
+
//
|
|
44
|
+
// Docker
|
|
45
|
+
//
|
|
46
|
+
targetDockerImageId: string
|
|
47
|
+
dockerImageTag: string
|
|
48
|
+
//
|
|
49
|
+
// Git
|
|
50
|
+
//
|
|
51
|
+
/**
|
|
52
|
+
* Short SHA of the commit used for this deployment.
|
|
53
|
+
*/
|
|
54
|
+
gitRev: string
|
|
55
|
+
gitBranch: string
|
|
56
|
+
//
|
|
57
|
+
// Cloud Run environment settings
|
|
58
|
+
//
|
|
59
|
+
/**
|
|
60
|
+
* Example: 'APP_ENV=prod,BUILD_VERSION=abcd,a=b'
|
|
61
|
+
*/
|
|
62
|
+
envString: string
|
|
63
|
+
/**
|
|
64
|
+
* Example: httpGet.path='/',httpGet.port=8080,initialDelaySeconds=3,failureThreshold=50,timeoutSeconds=1,periodSeconds=2
|
|
65
|
+
*/
|
|
66
|
+
startupProbeConfigString: string
|
|
67
|
+
minInstances: NonNegativeInteger
|
|
68
|
+
maxInstances: PositiveInteger
|
|
69
|
+
/**
|
|
70
|
+
* CloudRun concurrency setting.
|
|
71
|
+
* Example: 80
|
|
72
|
+
*/
|
|
73
|
+
concurrency: PositiveInteger
|
|
74
|
+
/**
|
|
75
|
+
* Example: '512Mi'
|
|
76
|
+
*/
|
|
77
|
+
memoryPerInstance: string
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface CloudRunStartupProbeConfig {
|
|
81
|
+
/**
|
|
82
|
+
* Example: '/'
|
|
83
|
+
*/
|
|
84
|
+
'httpGet.path': string
|
|
85
|
+
'httpGet.port': PositiveInteger
|
|
86
|
+
initialDelaySeconds: NumberOfSeconds
|
|
87
|
+
failureThreshold: PositiveInteger
|
|
88
|
+
timeoutSeconds: NumberOfSeconds
|
|
89
|
+
periodSeconds: NumberOfSeconds
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Experimental, subject to change.
|
|
94
|
+
*/
|
|
95
|
+
export const defaultStartupProbeConfig: CloudRunStartupProbeConfig = {
|
|
96
|
+
'httpGet.path': '/',
|
|
97
|
+
'httpGet.port': 8080,
|
|
98
|
+
initialDelaySeconds: 3,
|
|
99
|
+
failureThreshold: 50,
|
|
100
|
+
timeoutSeconds: 1,
|
|
101
|
+
periodSeconds: 2,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CloudRunEnv {
|
|
105
|
+
APP_ENV: string
|
|
106
|
+
/**
|
|
107
|
+
* Example: '--max-old-space-size=864'
|
|
108
|
+
*/
|
|
109
|
+
NODE_OPTIONS: string
|
|
110
|
+
/**
|
|
111
|
+
* Example: '2025-09-01T15:23:20.769Z'
|
|
112
|
+
* The result of running `new Date().toISOString()`
|
|
113
|
+
*/
|
|
114
|
+
DEPLOY_BUILD_TIME: string
|
|
115
|
+
/**
|
|
116
|
+
* Example: 'abcd'
|
|
117
|
+
* Should match the name of the GCP project.
|
|
118
|
+
*/
|
|
119
|
+
GOOGLE_CLOUD_PROJECT: string
|
|
120
|
+
/**
|
|
121
|
+
* Anything (a string) that would identify the build.
|
|
122
|
+
*/
|
|
123
|
+
BUILD_VERSION: string
|
|
124
|
+
/**
|
|
125
|
+
* External url of the deployed service.
|
|
126
|
+
*/
|
|
127
|
+
K_EXTERNAL_URL?: string
|
|
128
|
+
// UV_THREADPOOL_SIZE?: number
|
|
129
|
+
|
|
130
|
+
OTEL_SERVICE_NAME?: string
|
|
131
|
+
OTEL_METRICS_EXPORTER?: 'console' | 'otlp' | string
|
|
132
|
+
OTEL_METRIC_EXPORT_INTERVAL?: NumberOfMilliseconds
|
|
133
|
+
OTEL_METRIC_EXPORT_TIMEOUT?: NumberOfMilliseconds
|
|
134
|
+
OTEL_EXPORTER_OTLP_PROTOCOL?: 'http/protobuf' | string
|
|
135
|
+
/**
|
|
136
|
+
* Example: 'http://localhost:4317'
|
|
137
|
+
*/
|
|
138
|
+
OTEL_EXPORTER_OTLP_ENDPOINT?: string
|
|
139
|
+
OTEL_LOG_LEVEL?: 'INFO' | 'DEBUG'
|
|
140
|
+
}
|