Skip to content

Commit

Permalink
fix(config): ensure the docker context is passed image builds
Browse files Browse the repository at this point in the history
The `dockerContext` options was documented but never implemented making
it always utilize the default value of `.` or cwd. update steps to pass
the context which the docker Image class will resolve against the
current working directory

Fixes: #13
  • Loading branch information
esatterwhite committed Sep 18, 2021
1 parent 4909d4e commit 366b8d1
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 319 deletions.
3 changes: 2 additions & 1 deletion lib/build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async function buildConfig(build_id, config, context) {
, dockerLogin: login = true
, dockerImage: image
, dockerPublish: publish = true
, dockerContext = '.'
} = config

let name = null
Expand Down Expand Up @@ -58,6 +59,6 @@ async function buildConfig(build_id, config, context) {
, build: build_id
, login: login
, env: context.env
, context: config.context || '.'
, context: dockerContext
}
}
2 changes: 1 addition & 1 deletion lib/docker/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Image {
}

get context() {
return this.opts.context
return path.resolve(this.opts.cwd, this.opts.context)
}

set context(ctx) {
Expand Down
1 change: 1 addition & 0 deletions lib/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function dockerPrepare(opts, context) {
, dockerfile: opts.dockerfile
, build_id: opts.build
, cwd: cwd
, context: opts.context
})

const args = {
Expand Down
1 change: 1 addition & 0 deletions lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ async function publish(opts, context) {
, dockerfile: opts.dockerfile
, build_id: opts.build
, cwd: cwd
, context: opts.context
})

const vars = buildTemplateVars(opts, context)
Expand Down
4 changes: 3 additions & 1 deletion lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ async function verify(opts, context) {
const error = new SemanticError(
'Docker image name not found'
, 'EINVAL'
, 'Image name parsed from package.json name if possible. Or via the "image" option.'
, 'Image name parsed from package.json name if possible. '
+ 'Or via the "dockerImage" option.'
)
throw error
}
Expand All @@ -29,6 +30,7 @@ async function verify(opts, context) {
, dockerfile: opts.dockerfile
, build_id: opts.build
, cwd: cwd
, context: opts.context
})

debug('docker options', opts)
Expand Down

0 comments on commit 366b8d1

Please sign in to comment.