@toa.io/operations 0.8.0-canary.2 → 0.8.0-dev.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/operations",
|
|
3
|
-
"version": "0.8.0-
|
|
3
|
+
"version": "0.8.0-dev.4",
|
|
4
4
|
"description": "Toa Deployment",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@toa.io/filesystem": "1.1.0-
|
|
30
|
-
"@toa.io/generic": "0.11.0-
|
|
31
|
-
"@toa.io/yaml": "0.8.0-
|
|
29
|
+
"@toa.io/filesystem": "1.1.0-dev.4",
|
|
30
|
+
"@toa.io/generic": "0.11.0-dev.3",
|
|
31
|
+
"@toa.io/yaml": "0.8.0-dev.4",
|
|
32
32
|
"execa": "5.1.1"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "24d68d70a56717f2f4441cc9884a60f9fee0863e"
|
|
35
35
|
}
|
package/readme.md
CHANGED
|
@@ -7,9 +7,24 @@
|
|
|
7
7
|
#### Build Options
|
|
8
8
|
|
|
9
9
|
```yaml
|
|
10
|
+
# context.toa.yaml
|
|
11
|
+
|
|
10
12
|
registry:
|
|
11
13
|
build:
|
|
12
14
|
arguments: [NPM_TOKEN]
|
|
15
|
+
run: echo //npm.pkg.github.com/:_authToken=${NPM_TOKEN} > .npmrc
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`arguments` is a list of environemt varialbes to be passed to `docker build`.
|
|
19
|
+
|
|
20
|
+
`run` is a command(s) to be executed during build. Multiline is supported.
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
# context.toa.yaml
|
|
24
|
+
|
|
25
|
+
registry:
|
|
26
|
+
build:
|
|
13
27
|
run: |
|
|
14
|
-
echo
|
|
28
|
+
echo test > .test
|
|
29
|
+
rm .test
|
|
15
30
|
```
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
FROM node:18.16.0-alpine3.17
|
|
2
2
|
|
|
3
|
+
{{build.arguments}}
|
|
4
|
+
|
|
3
5
|
ENV NODE_ENV=production
|
|
4
|
-
RUN if [ {{runtime.
|
|
6
|
+
RUN if [ {{runtime.registry}} != undefined ]; then npm set registry {{runtime.registry}}; fi
|
|
5
7
|
RUN if [ {{runtime.proxy}} != undefined ]; then npm set proxy {{runtime.proxy}}; fi
|
|
6
8
|
RUN npm i -g @toa.io/runtime@{{runtime.version}}
|
|
7
9
|
|
|
@@ -11,6 +13,6 @@ ADD . .
|
|
|
11
13
|
# run 'npm i' in each component
|
|
12
14
|
RUN find . -maxdepth 1 -type d \( ! -name . \) -exec /bin/sh -c "cd '{}' && if [ -f package.json ]; then npm i; fi" \;
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
{{build.run}}
|
|
15
17
|
|
|
16
18
|
CMD toa compose *
|
|
@@ -46,8 +46,7 @@ class Image {
|
|
|
46
46
|
this.#runtime = runtime
|
|
47
47
|
this.#type = this.constructor.name.toLowerCase()
|
|
48
48
|
|
|
49
|
-
this.#
|
|
50
|
-
this.#values.build = overwrite(this.#values.build, registry.build)
|
|
49
|
+
this.#setValues()
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
tag () {
|
|
@@ -89,6 +88,14 @@ class Image {
|
|
|
89
88
|
return path
|
|
90
89
|
}
|
|
91
90
|
|
|
91
|
+
#setValues () {
|
|
92
|
+
this.#values.runtime = this.#runtime
|
|
93
|
+
this.#values.build = overwrite(this.#values.build, this.#registry.build)
|
|
94
|
+
|
|
95
|
+
if (this.#values.build.arguments !== undefined) this.#values.build.arguments = createArguments(this.#values.build.arguments)
|
|
96
|
+
if (this.#values.build.run !== undefined) this.#values.build.run = createRunCommands(this.#values.build.run)
|
|
97
|
+
}
|
|
98
|
+
|
|
92
99
|
/**
|
|
93
100
|
* @param key {string}
|
|
94
101
|
* @returns {string}
|
|
@@ -100,4 +107,25 @@ class Image {
|
|
|
100
107
|
}
|
|
101
108
|
}
|
|
102
109
|
|
|
110
|
+
function createRunCommands (input) {
|
|
111
|
+
const lines = input.split('\n')
|
|
112
|
+
|
|
113
|
+
return lines.reduce((commands, command) => {
|
|
114
|
+
commands += '\nRUN ' + command
|
|
115
|
+
|
|
116
|
+
return commands
|
|
117
|
+
}, '')
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function createArguments (variables) {
|
|
121
|
+
const args = []
|
|
122
|
+
|
|
123
|
+
for (const variable of variables) {
|
|
124
|
+
args.push('ARG ' + variable)
|
|
125
|
+
args.push(`ENV ${variable}=$${variable}`)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return args.join('\n')
|
|
129
|
+
}
|
|
130
|
+
|
|
103
131
|
exports.Image = Image
|
|
@@ -84,6 +84,10 @@ class Registry {
|
|
|
84
84
|
|
|
85
85
|
const multiarch = this.#registry.platforms !== null
|
|
86
86
|
|
|
87
|
+
if (this.#registry.build?.arguments !== undefined) {
|
|
88
|
+
for (const arg of this.#registry.build.arguments) args.push('--build-arg', `${arg}=${process.env[arg]}`)
|
|
89
|
+
}
|
|
90
|
+
|
|
87
91
|
if (multiarch) {
|
|
88
92
|
const platform = this.#registry.platforms.join(',')
|
|
89
93
|
|