@@ -197,30 +197,55 @@ export = {
197
197
const app = new App ( ) ;
198
198
const stack = new Stack ( app , 'stack' ) ;
199
199
200
- new DockerImageAsset ( stack , 'MyAsset' , {
200
+ const image = new DockerImageAsset ( stack , 'MyAsset' , {
201
201
directory : path . join ( __dirname , 'demo-image' )
202
202
} ) ;
203
203
204
204
const session = app . synth ( ) ;
205
205
206
- test . ok ( fs . existsSync ( path . join ( session . directory , ' asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/ Dockerfile') ) ) ;
207
- test . ok ( fs . existsSync ( path . join ( session . directory , ' asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/ index.py') ) ) ;
206
+ test . ok ( fs . existsSync ( path . join ( session . directory , ` asset.${ image . sourceHash } ` , ' Dockerfile') ) ) ;
207
+ test . ok ( fs . existsSync ( path . join ( session . directory , ` asset.${ image . sourceHash } ` , ' index.py') ) ) ;
208
208
test . done ( ) ;
209
209
} ,
210
210
211
211
'docker directory is staged without files specified in .dockerignore' ( test : Test ) {
212
212
const app = new App ( ) ;
213
213
const stack = new Stack ( app , 'stack' ) ;
214
214
215
- new DockerImageAsset ( stack , 'MyAsset' , {
215
+ const image = new DockerImageAsset ( stack , 'MyAsset' , {
216
216
directory : path . join ( __dirname , 'dockerignore-image' )
217
217
} ) ;
218
218
219
219
const session = app . synth ( ) ;
220
220
221
- test . ok ( fs . existsSync ( path . join ( session . directory , `asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/Dockerfile` ) ) ) ;
222
- test . ok ( fs . existsSync ( path . join ( session . directory , 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/index.py' ) ) ) ;
223
- test . ok ( ! fs . existsSync ( path . join ( session . directory , 'asset.1a17a141505ac69144931fe263d130f4612251caa4bbbdaf68a44ed0f405439c/foobar.txt' ) ) ) ;
221
+ // .dockerignore itself should be included in output to be processed during docker build
222
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , '.dockerignore' ) ) ) ;
223
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , `Dockerfile` ) ) ) ;
224
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'index.py' ) ) ) ;
225
+ test . ok ( ! fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'foobar.txt' ) ) ) ;
226
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'subdirectory' ) ) ) ;
227
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'subdirectory' , 'baz.txt' ) ) ) ;
228
+
229
+ test . done ( ) ;
230
+ } ,
231
+
232
+ 'docker directory is staged without files specified in exclude option' ( test : Test ) {
233
+ const app = new App ( ) ;
234
+ const stack = new Stack ( app , 'stack' ) ;
235
+
236
+ const image = new DockerImageAsset ( stack , 'MyAsset' , {
237
+ directory : path . join ( __dirname , 'dockerignore-image' ) ,
238
+ exclude : [ 'subdirectory' ]
239
+ } ) ;
240
+
241
+ const session = app . synth ( ) ;
242
+
243
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , '.dockerignore' ) ) ) ;
244
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , `Dockerfile` ) ) ) ;
245
+ test . ok ( fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'index.py' ) ) ) ;
246
+ test . ok ( ! fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'foobar.txt' ) ) ) ;
247
+ test . ok ( ! fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'subdirectory' ) ) ) ;
248
+ test . ok ( ! fs . existsSync ( path . join ( session . directory , `asset.${ image . sourceHash } ` , 'subdirectory' , 'baz.txt' ) ) ) ;
224
249
225
250
test . done ( ) ;
226
251
} ,
0 commit comments