@leverege/build-tools 2.93.0-quinn.13 → 2.93.0-quinn.3
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 +1 -1
- package/src/Docker.mjs +15 -18
- package/src/Utils.mjs +0 -2
- package/src/docker-to-registry.mjs +5 -15
- package/src/templates/dockerfileTemplateNodeJs.hbs +13 -13
package/package.json
CHANGED
package/src/Docker.mjs
CHANGED
|
@@ -121,14 +121,13 @@ const generateDockerfile = async ( options ) => {
|
|
|
121
121
|
fs.writeFileSync( dockerfilePlugin, dockerfilePluginTemplate )
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
const buildDir = options.isYarnProject ? `/tmp/${options.containerName}/build` : './build'
|
|
125
124
|
try {
|
|
126
|
-
const build = fs.readdirSync(
|
|
125
|
+
const build = fs.readdirSync( './build' )
|
|
127
126
|
if ( build.length === 0 ) {
|
|
128
127
|
errorExit( `***ERROR: the build dir is empty - ${chalk.yellow( 'npm run build' )}` )
|
|
129
128
|
}
|
|
130
129
|
} catch ( err ) {
|
|
131
|
-
errorExit( `***ERROR: expected the
|
|
130
|
+
errorExit( `***ERROR: expected the ./build directory to exist - ${chalk.yellow( 'npm run build' )}` )
|
|
132
131
|
}
|
|
133
132
|
|
|
134
133
|
// At this point the docker plugin file better exist.
|
|
@@ -185,8 +184,7 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
185
184
|
isPythonProject,
|
|
186
185
|
isYarnProject
|
|
187
186
|
} = repoDescr
|
|
188
|
-
const
|
|
189
|
-
const buildWorkspace = `${buildDir}/workspace` // passed to Cloud Build
|
|
187
|
+
const buildWorkspace = './build/workspace' // passed to Cloud Build
|
|
190
188
|
const imageName = `${artifactRegistry}/images/${containerName}`
|
|
191
189
|
|
|
192
190
|
if ( fs.existsSync( buildWorkspace ) ) {
|
|
@@ -206,24 +204,23 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
206
204
|
// 5. drop a copy of dev's npmrc to use for build process
|
|
207
205
|
// 6. drop a copy of package.json and the lock into the image root
|
|
208
206
|
//
|
|
209
|
-
fs.renameSync(
|
|
210
|
-
fs.mkdirSync(
|
|
211
|
-
fs.renameSync(
|
|
212
|
-
fs.cpSync( './docker/Dockerfile',
|
|
213
|
-
fs.cpSync(
|
|
207
|
+
fs.renameSync( './build', './workspace' )
|
|
208
|
+
fs.mkdirSync( './build' )
|
|
209
|
+
fs.renameSync( './workspace', buildWorkspace )
|
|
210
|
+
fs.cpSync( './docker/Dockerfile', './build/Dockerfile' )
|
|
211
|
+
fs.cpSync( './build/Dockerfile', `${buildWorkspace}/Dockerfile` )
|
|
214
212
|
|
|
215
213
|
// bashrc won't exist if we're opting out of dockerfile generation
|
|
216
214
|
if ( fs.existsSync( './docker/bashrc' ) ) {
|
|
217
|
-
fs.renameSync( './docker/bashrc',
|
|
215
|
+
fs.renameSync( './docker/bashrc', './build/bashrc' )
|
|
218
216
|
}
|
|
219
217
|
|
|
220
218
|
if ( isNodeJsProject ) {
|
|
221
|
-
|
|
219
|
+
fs.cpSync( './package.json', `${buildWorkspace}/package.json` )
|
|
222
220
|
if ( isYarnProject ) {
|
|
223
|
-
fs.cpSync( `${process.env.HOME}/.yarnrc.yml`,
|
|
221
|
+
fs.cpSync( `${process.env.HOME}/.yarnrc.yml`, './build/.yarnrc.yml' )
|
|
224
222
|
} else {
|
|
225
|
-
fs.cpSync( './
|
|
226
|
-
fs.cpSync( `${process.env.HOME}/.npmrc`, `${buildDir}/.npmrc` )
|
|
223
|
+
fs.cpSync( `${process.env.HOME}/.npmrc`, './build/.npmrc' )
|
|
227
224
|
fs.cpSync( './package-lock.json', `${buildWorkspace}/package-lock.json` )
|
|
228
225
|
}
|
|
229
226
|
}
|
|
@@ -239,7 +236,7 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
239
236
|
const gcloudProjectNumber = await shellCmd( `gcloud projects describe ${artifactProject} --format="value(projectNumber)"` )
|
|
240
237
|
|
|
241
238
|
// build the cloudbuild.yaml from the handlebars template
|
|
242
|
-
const cloudBuildFile =
|
|
239
|
+
const cloudBuildFile = './build/cloudbuild.yaml'
|
|
243
240
|
let cloudBuildSteps
|
|
244
241
|
let imagePlatformString
|
|
245
242
|
if ( isPythonProject || ( imagePlatform.length === 1 && imagePlatform[0] === 'linux/arm64' ) || imagePlatform.length > 1 ) {
|
|
@@ -269,12 +266,12 @@ const buildContainerImage = async ( repoDescr ) => {
|
|
|
269
266
|
` ) )
|
|
270
267
|
|
|
271
268
|
if ( process.env.DRY_RUN === '1' ) {
|
|
272
|
-
log( `Would have run => ${cloudBuildCmd} ${cloudBuildLogs} ${cloudBuildCfg}
|
|
269
|
+
log( `Would have run => ${cloudBuildCmd} ${cloudBuildLogs} ${cloudBuildCfg} ./build` )
|
|
273
270
|
log( '\n***Exiting from DRY_RUN\n' )
|
|
274
271
|
process.exit( 0 )
|
|
275
272
|
}
|
|
276
273
|
|
|
277
|
-
await shellCmd( `${cloudBuildCmd} ${cloudBuildLogs} ${cloudBuildCfg}
|
|
274
|
+
await shellCmd( `${cloudBuildCmd} ${cloudBuildLogs} ${cloudBuildCfg} ./build`, { stdio : 'inherit' } )
|
|
278
275
|
}
|
|
279
276
|
|
|
280
277
|
const repoCleanup = async () => {
|
package/src/Utils.mjs
CHANGED
|
@@ -562,7 +562,6 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
562
562
|
rootPackageJson,
|
|
563
563
|
rootPyProjectToml,
|
|
564
564
|
isNpmWorkspace,
|
|
565
|
-
isYarnProject
|
|
566
565
|
} = await getRepositoryDescr()
|
|
567
566
|
|
|
568
567
|
if ( isMonoRepo && rootPackageJson.isInvalid ) {
|
|
@@ -671,6 +670,5 @@ export const analyzeRepository = async ( giveGuidance ) => {
|
|
|
671
670
|
packageVersion,
|
|
672
671
|
subPkgs,
|
|
673
672
|
wsName,
|
|
674
|
-
isYarnProject
|
|
675
673
|
}
|
|
676
674
|
}
|
|
@@ -98,8 +98,7 @@ const {
|
|
|
98
98
|
isNpmWorkspace,
|
|
99
99
|
isNodeJsProject,
|
|
100
100
|
isPythonProject,
|
|
101
|
-
isYarnProject
|
|
102
|
-
closestPackageJson
|
|
101
|
+
isYarnProject
|
|
103
102
|
} = repoDescr
|
|
104
103
|
|
|
105
104
|
if ( requiresHelmChart ) {
|
|
@@ -116,16 +115,7 @@ if ( requiresHelmChart ) {
|
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
const leveregeStanza = isNodeJsProject ? closestPackageJson.leverege : repoDescr.rootPyProjectToml.leverege
|
|
120
|
-
let runCommand = 'node index.js'
|
|
121
|
-
|
|
122
|
-
if ( isYarnProject ) {
|
|
123
|
-
if ( isNpmWorkspace ) {
|
|
124
|
-
runCommand = `yarn workspace ${closestPackageJson.name} run start`
|
|
125
|
-
} else {
|
|
126
|
-
runCommand = 'yarn start'
|
|
127
|
-
}
|
|
128
|
-
}
|
|
118
|
+
const leveregeStanza = isNodeJsProject ? repoDescr.closestPackageJson.leverege : repoDescr.rootPyProjectToml.leverege
|
|
129
119
|
|
|
130
120
|
const dockerfileOptions = {
|
|
131
121
|
isNodeJsProject,
|
|
@@ -139,8 +129,6 @@ const dockerfileOptions = {
|
|
|
139
129
|
pythonVersion : repoDescr.rootPyProjectToml?.pythonVersion,
|
|
140
130
|
previousBuild : docker.getPreviousBuild(),
|
|
141
131
|
date : getDateTimestamp(),
|
|
142
|
-
containerName,
|
|
143
|
-
runCommand
|
|
144
132
|
}
|
|
145
133
|
let dockerInfo
|
|
146
134
|
if ( generateDockerfile ) {
|
|
@@ -163,7 +151,9 @@ const registryFolder = `${artifactRegistry}/images/${containerName}`
|
|
|
163
151
|
if ( isNodeJsProject ) {
|
|
164
152
|
// Update the dependencies...
|
|
165
153
|
log( chalk.green.bold( 'Updating dependencies and workspace...' ) )
|
|
166
|
-
if (
|
|
154
|
+
if ( isYarnProject ) {
|
|
155
|
+
await shellCmd( 'yarn install', { stdio : 'inherit' } )
|
|
156
|
+
} else {
|
|
167
157
|
await shellCmd( 'npm install', { stdio : 'inherit' } )
|
|
168
158
|
}
|
|
169
159
|
}
|
|
@@ -7,11 +7,9 @@ FROM {{image}} as intermediate
|
|
|
7
7
|
ARG BUILD_ENV="{{buildEnv}}"
|
|
8
8
|
|
|
9
9
|
ENV NODE_ENV production
|
|
10
|
-
{{#
|
|
11
|
-
ENV COREPACK_HOME /usr/src/.cache/node
|
|
12
|
-
{{else}}
|
|
10
|
+
{{#unless isYarnProject}}
|
|
13
11
|
ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
|
|
14
|
-
{{/
|
|
12
|
+
{{/unless}}
|
|
15
13
|
|
|
16
14
|
RUN mkdir -p /usr/src/app
|
|
17
15
|
WORKDIR /usr/src/app
|
|
@@ -35,6 +33,8 @@ RUN if [ "${BUILD_ENV}" = "debian" ]; then \
|
|
|
35
33
|
apt-get update && \
|
|
36
34
|
apt-get install -y wget openssh-client build-essential && \
|
|
37
35
|
{{#if isYarnProject}}
|
|
36
|
+
npm install -g {{npmVersion}} && \
|
|
37
|
+
npm install -g corepack && \
|
|
38
38
|
corepack enable && \
|
|
39
39
|
corepack prepare yarn@stable --activate; \
|
|
40
40
|
{{else}}
|
|
@@ -44,6 +44,8 @@ RUN if [ "${BUILD_ENV}" = "debian" ]; then \
|
|
|
44
44
|
apk --no-cache add openssh-client && \
|
|
45
45
|
apk --update add --no-cache --virtual build-dep g++ gcc libgcc libstdc++ linux-headers make {{apkadds}} && \
|
|
46
46
|
{{#if isYarnProject}}
|
|
47
|
+
npm install -g {{npmVersion}} && \
|
|
48
|
+
npm install -g corepack && \
|
|
47
49
|
corepack enable && \
|
|
48
50
|
corepack prepare yarn@stable --activate; \
|
|
49
51
|
{{else}}
|
|
@@ -73,11 +75,9 @@ FROM {{image}}
|
|
|
73
75
|
|
|
74
76
|
ARG BUILD_ENV="{{buildEnv}}"
|
|
75
77
|
|
|
76
|
-
{{#
|
|
77
|
-
ENV COREPACK_HOME /usr/src/.cache/node
|
|
78
|
-
{{else}}
|
|
78
|
+
{{#unless isYarnProject}}
|
|
79
79
|
ENV NPM_CONFIG_USERCONFIG /usr/src/app/.npmrc
|
|
80
|
-
{{/
|
|
80
|
+
{{/unless}}
|
|
81
81
|
|
|
82
82
|
# Copy .npmrc for private registry access for access to any @leverege packages
|
|
83
83
|
{{#if isYarnProject}}
|
|
@@ -90,22 +90,22 @@ COPY ./.npmrc ${NPM_CONFIG_USERCONFIG}
|
|
|
90
90
|
RUN if [ "$BUILD_ENV" = "debian" ]; then \
|
|
91
91
|
apt-get update && \
|
|
92
92
|
apt-get install -y tini bash curl vim {{apkadds}} && \
|
|
93
|
+
npm install -g {{npmVersion}} && \
|
|
93
94
|
{{#if isYarnProject}}
|
|
95
|
+
npm install -g corepack && \
|
|
94
96
|
corepack enable && \
|
|
95
97
|
corepack prepare yarn@stable --activate && \
|
|
96
|
-
{{else}}
|
|
97
|
-
npm install -g {{npmVersion}} && \
|
|
98
98
|
{{/if}}
|
|
99
99
|
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
100
100
|
mkdir -p /usr/src/app /tmp/levlog && chown node:node /usr/src/app; \
|
|
101
101
|
else \
|
|
102
102
|
apk update && \
|
|
103
103
|
apk add --no-cache bash curl tini vim {{apkadds}} && \
|
|
104
|
+
npm install -g {{npmVersion}} && \
|
|
104
105
|
{{#if isYarnProject}}
|
|
106
|
+
npm install -g corepack && \
|
|
105
107
|
corepack enable && \
|
|
106
108
|
corepack prepare yarn@stable --activate && \
|
|
107
|
-
{{else}}
|
|
108
|
-
npm install -g {{npmVersion}} && \
|
|
109
109
|
{{/if}}
|
|
110
110
|
rm /bin/sh && ln -s /bin/bash /bin/sh && \
|
|
111
111
|
mkdir -p /usr/src/app /tmp/levlog && chown node:node /usr/src/app; \
|
|
@@ -129,4 +129,4 @@ COPY --chown=node:node --from=intermediate /usr/src/app /usr/src/app
|
|
|
129
129
|
|
|
130
130
|
USER {{runuser}}
|
|
131
131
|
COPY ./bashrc /home/node/.bashrc
|
|
132
|
-
CMD [ "/bin/bash", "-c", "source /home/node/.bashrc &&
|
|
132
|
+
CMD [ "/bin/bash", "-c", "source /home/node/.bashrc && node index.js" ]
|