Fix build/deploy commands with QEMU emulation and alternative Dockerfile name

Resolves: #1624
Change-type: patch
This commit is contained in:
Paulo Castro 2020-02-24 22:18:22 -03:00
parent 28c00696b8
commit cdfd1d124b
6 changed files with 17 additions and 24 deletions

View File

@ -54,6 +54,7 @@ buildProject = (docker, logger, composeOpts, opts) ->
opts.buildOpts opts.buildOpts
composeOpts.inlineLogs composeOpts.inlineLogs
opts.convertEol opts.convertEol
composeOpts.dockerfilePath
) )
.then -> .then ->
logger.outputDeferredMessages() logger.outputDeferredMessages()

View File

@ -74,6 +74,7 @@ deployProject = (docker, logger, composeOpts, opts) ->
opts.buildOpts opts.buildOpts
composeOpts.inlineLogs composeOpts.inlineLogs
opts.convertEol opts.convertEol
composeOpts.dockerfilePath
) )
.then (builtImages) -> .then (builtImages) ->
_.keyBy(builtImages, 'serviceName') _.keyBy(builtImages, 'serviceName')

View File

@ -158,7 +158,8 @@ exports.buildProject = (
arch, deviceType, arch, deviceType,
emulated, buildOpts, emulated, buildOpts,
inlineLogs, inlineLogs,
convertEol convertEol,
dockerfilePath,
) -> ) ->
_ = require('lodash') _ = require('lodash')
humanize = require('humanize') humanize = require('humanize')
@ -221,11 +222,15 @@ exports.buildProject = (
# Setup emulation if needed # Setup emulation if needed
return [ task, null ] if task.external or not needsQemu return [ task, null ] if task.external or not needsQemu
binPath = qemu.qemuPathInContext(path.join(projectPath, task.context)) binPath = qemu.qemuPathInContext(path.join(projectPath, task.context))
transpose.transposeTarStream task.buildStream, transpose.transposeTarStream(
hostQemuPath: toPosixPath(binPath) task.buildStream,
containerQemuPath: "/tmp/#{qemu.QEMU_BIN_NAME}" {
qemuFileMode: 0o555 hostQemuPath: toPosixPath(binPath),
.then (stream) -> containerQemuPath: "/tmp/#{qemu.QEMU_BIN_NAME}",
qemuFileMode: 0o555,
},
dockerfilePath
).then (stream) ->
task.buildStream = stream task.buildStream = stream
.return([ task, binPath ]) .return([ task, binPath ])
.map ([ task, qemuPath ]) -> .map ([ task, qemuPath ]) ->

View File

@ -384,20 +384,6 @@ async function validateSpecifiedDockerfile(
`); `);
} }
const { dir, ext, name } = path.parse(fullDockerfilePath);
if (ext) {
const nativePathMinusExt = path.join(dir, name);
if (await fs.exists(nativePathMinusExt)) {
throw new ExpectedError(stripIndent`
Error: "${name}" exists on the same folder as "${nativeDockerfilePath}".
When an alternative Dockerfile name is specified, a file with the same base name
(minus the file extension) must not exist in the same folder. This is because
the base name file will be auto generated and added to the tar stream that is
sent to balenaEngine or the Docker daemon, resulting in duplicate Dockerfiles
and undefined behavior.
`);
}
}
return toPosixPath(nativeDockerfilePath); return toPosixPath(nativeDockerfilePath);
} }

6
npm-shrinkwrap.json generated
View File

@ -4214,9 +4214,9 @@
} }
}, },
"docker-qemu-transpose": { "docker-qemu-transpose": {
"version": "1.0.2", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/docker-qemu-transpose/-/docker-qemu-transpose-1.0.2.tgz", "resolved": "https://registry.npmjs.org/docker-qemu-transpose/-/docker-qemu-transpose-1.0.3.tgz",
"integrity": "sha512-DzyYPX3Gx6/g0dM9KVqeTgGYYM559J0TeWDxdZ4spSSc37M44XrrUw/yG8B48Wo0ENMlb+orHSt7NFt8cTuYiA==", "integrity": "sha512-U9bv8Ch6aOJ3LmqTQ3+aQxSmUFJG6pMdIM5wWqlgCShkVFNIYQTG5wCUf5x23QwYizpemExx4QLF78poo5UOsw==",
"requires": { "requires": {
"@types/bluebird": "^3.5.2", "@types/bluebird": "^3.5.2",
"@types/event-stream": "^3.3.31", "@types/event-stream": "^3.3.31",

View File

@ -186,7 +186,7 @@
"denymount": "^2.3.0", "denymount": "^2.3.0",
"docker-modem": "^2.0.4", "docker-modem": "^2.0.4",
"docker-progress": "^4.0.0", "docker-progress": "^4.0.0",
"docker-qemu-transpose": "^1.0.2", "docker-qemu-transpose": "^1.0.3",
"docker-toolbelt": "^3.3.7", "docker-toolbelt": "^3.3.7",
"dockerode": "^2.5.8", "dockerode": "^2.5.8",
"ejs": "^3.0.1", "ejs": "^3.0.1",