Merge pull request #1628 from balena-io/1624-transpose-specified-dockerfile

Fix build/deploy commands with QEMU emulation and alternative Dockerfile
This commit is contained in:
Paulo Castro 2020-02-25 17:47:13 -03:00 committed by GitHub
commit d86f213b68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 24 deletions

View File

@ -93,6 +93,7 @@ Since this is error prone, it's suggested to use the following npm script:
```
npm run update balena-sdk ^12.1.0
```
This will create a new branch (only if you are currently on master), run `npm update` with the
version you provided as a target and commit the package.json & npm-shrinkwrap.json. The script by
default will set the `Change-type` to `patch` or `minor`, depending on the semver change of the
@ -101,6 +102,7 @@ extra argument:
```
npm run update balena-sdk ^12.14.0 patch
npm run update balena-sdk ^13.0.0 major
```
## Common gotchas

View File

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

View File

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

View File

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

6
npm-shrinkwrap.json generated
View File

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

View File

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