@codedependant/semantic-release-docker 3.1.1 → 3.1.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Semantic Release Docker
2
2
 
3
+ ## [3.1.2](https://github.com/esatterwhite/semantic-release-docker/compare/v3.1.1...v3.1.2) (2021-09-18)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **config**: ensure the docker context is passed image builds [366b8d1](https://github.com/esatterwhite/semantic-release-docker/commit/366b8d1d1f90855a76cfdb78009ec4510ead769e) - Eric Satterwhite, closes: [#13](https://github.com/esatterwhite/semantic-release-docker/issues/13)
9
+
3
10
  ## [3.1.1](https://github.com/esatterwhite/semantic-release-docker/compare/v3.1.0...v3.1.1) (2021-09-18)
4
11
 
5
12
 
@@ -19,6 +19,7 @@ async function buildConfig(build_id, config, context) {
19
19
  , dockerLogin: login = true
20
20
  , dockerImage: image
21
21
  , dockerPublish: publish = true
22
+ , dockerContext = '.'
22
23
  } = config
23
24
 
24
25
  let name = null
@@ -58,6 +59,6 @@ async function buildConfig(build_id, config, context) {
58
59
  , build: build_id
59
60
  , login: login
60
61
  , env: context.env
61
- , context: config.context || '.'
62
+ , context: dockerContext
62
63
  }
63
64
  }
@@ -53,7 +53,7 @@ class Image {
53
53
  }
54
54
 
55
55
  get context() {
56
- return this.opts.context
56
+ return path.resolve(this.opts.cwd, this.opts.context)
57
57
  }
58
58
 
59
59
  set context(ctx) {
package/lib/prepare.js CHANGED
@@ -16,6 +16,7 @@ async function dockerPrepare(opts, context) {
16
16
  , dockerfile: opts.dockerfile
17
17
  , build_id: opts.build
18
18
  , cwd: cwd
19
+ , context: opts.context
19
20
  })
20
21
 
21
22
  const args = {
package/lib/publish.js CHANGED
@@ -15,6 +15,7 @@ async function publish(opts, context) {
15
15
  , dockerfile: opts.dockerfile
16
16
  , build_id: opts.build
17
17
  , cwd: cwd
18
+ , context: opts.context
18
19
  })
19
20
 
20
21
  const vars = buildTemplateVars(opts, context)
package/lib/verify.js CHANGED
@@ -17,7 +17,8 @@ async function verify(opts, context) {
17
17
  const error = new SemanticError(
18
18
  'Docker image name not found'
19
19
  , 'EINVAL'
20
- , 'Image name parsed from package.json name if possible. Or via the "image" option.'
20
+ , 'Image name parsed from package.json name if possible. '
21
+ + 'Or via the "dockerImage" option.'
21
22
  )
22
23
  throw error
23
24
  }
@@ -29,6 +30,7 @@ async function verify(opts, context) {
29
30
  , dockerfile: opts.dockerfile
30
31
  , build_id: opts.build
31
32
  , cwd: cwd
33
+ , context: opts.context
32
34
  })
33
35
 
34
36
  debug('docker options', opts)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codedependant/semantic-release-docker",
3
3
  "private": false,
4
- "version": "3.1.1",
4
+ "version": "3.1.2",
5
5
  "description": "docker package",
6
6
  "main": "index.js",
7
7
  "scripts": {
@@ -49,6 +49,7 @@ test('steps::prepare', async (t) => {
49
49
  , BUILD_DATE: '{now}'
50
50
  }
51
51
  , dockerFile: 'docker/Dockerfile.prepare'
52
+ , dockerContext: 'docker'
52
53
  }, context)
53
54
 
54
55
  const auth = await verify(config, context)
@@ -64,6 +65,7 @@ test('steps::prepare', async (t) => {
64
65
  tt.equal(image.opts.args.get('MAJOR_TEMPLATE'), '2', 'MAJOR_TEMPLATE value')
65
66
  tt.equal(image.opts.args.get('GIT_REF'), 'abacadaba', 'GIT_REF value')
66
67
  tt.match(image.opts.args.get('BUILD_DATE'), DATE_REGEX, 'BUILD_DATE value')
68
+ tt.equal(image.context, path.join(context.cwd, config.context), 'docker context path')
67
69
 
68
70
  const {stdout} = await execa('docker', [
69
71
  'images', image.name
@@ -172,7 +172,8 @@ test('steps::verify', async (t) => {
172
172
  code: 'EINVAL'
173
173
  , name: 'SemanticReleaseError'
174
174
  , details: new RegExp(
175
- 'image name parsed from package.json name if possible. or via the "image" option'
175
+ 'image name parsed from package.json name if possible. '
176
+ + 'or via the "dockerImage" option'
176
177
  , 'gi'
177
178
  )
178
179
  })
@@ -60,7 +60,7 @@ test('Image', async (t) => {
60
60
  , args: Map
61
61
  }, 'default image options')
62
62
 
63
- tt.equal(img.context, '.', 'default image context')
63
+ tt.equal(img.context, path.join(__dirname, 'build', '.'), 'default image context')
64
64
  img.context = __dirname
65
65
  tt.equal(img.context, __dirname, 'context override')
66
66
  tt.equal(
@@ -176,7 +176,7 @@ test('Image', async (t) => {
176
176
  , 'quay.io/esatterwhite/test:abacadaba'
177
177
  , '-f'
178
178
  , path.join(process.cwd(), 'Dockerfile')
179
- , '.'
179
+ , process.cwd()
180
180
  ], 'build command')
181
181
  }
182
182
 
@@ -286,4 +286,18 @@ test('Image', async (t) => {
286
286
  tt.deepEqual(stdout, '', 'all tags removed')
287
287
  })
288
288
 
289
+ t.test('image.context', async (tt) => {
290
+ const img = new docker.Image({
291
+ name: 'test'
292
+ , registry: 'quay.io'
293
+ , project: 'esatterwhite'
294
+ , build_id: build_id
295
+ , cwd: __dirname
296
+ , dockerfile: path.join('fixture', 'Dockerfile.test')
297
+ , context: 'fixture'
298
+ })
299
+
300
+ tt.equal(img.context, path.join(__dirname, 'fixture'), 'expected image context')
301
+ })
302
+
289
303
  }).catch(threw)