File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,13 @@ const duration = __webpack_require__(3805);
3535 abort("docker build args require at least one --tag")
3636 }
3737
38- const primaryKey = sha256(`${cacheKey} ${dockerBuildArgs}`)
38+ // parse dockerfile from args
39+ const dockerfile = getDockerfile(dockerBuildArgs)
40+ if (dockerfile == "") {
41+ abort("docker build args require --file")
42+ }
43+
44+ const primaryKey = sha256(`${cacheKey} ${dockerBuildArgs} ${sha256File(dockerfile)}`)
3945 const cachePath = path.join(runnerTemp, "cached-docker-build", primaryKey)
4046 let cacheHit = false
4147
@@ -114,11 +120,28 @@ function getDockerBuildTags(cmd) {
114120 return tags.flat()
115121}
116122
123+ function getDockerfile(cmd) {
124+ let args = __webpack_require__(8909)(cmd)
125+ if (args["f"]) {
126+ return args["f"]
127+ }
128+
129+ if (args["file"]) {
130+ return args["file"]
131+ }
132+
133+ return ""
134+ }
135+
117136// sha256 returns sha256(input) hex string
118137function sha256(input) {
119138 return __webpack_require__(6417).createHash('sha256').update(input, 'utf8').digest('hex');
120139}
121140
141+ function sha256File(filename) {
142+ return sha256(fs.readFileSync(filename))
143+ }
144+
122145
123146/***/ }),
124147
Original file line number Diff line number Diff line change @@ -28,7 +28,13 @@ const duration = require('parse-duration');
2828 abort ( "docker build args require at least one --tag" )
2929 }
3030
31- const primaryKey = sha256 ( `${ cacheKey } ${ dockerBuildArgs } ` )
31+ // parse dockerfile from args
32+ const dockerfile = getDockerfile ( dockerBuildArgs )
33+ if ( dockerfile == "" ) {
34+ abort ( "docker build args require --file" )
35+ }
36+
37+ const primaryKey = sha256 ( `${ cacheKey } ${ dockerBuildArgs } ${ sha256File ( dockerfile ) } ` )
3238 const cachePath = path . join ( runnerTemp , "cached-docker-build" , primaryKey )
3339 let cacheHit = false
3440
@@ -107,7 +113,24 @@ function getDockerBuildTags(cmd) {
107113 return tags . flat ( )
108114}
109115
116+ function getDockerfile ( cmd ) {
117+ let args = require ( "yargs-parser" ) ( cmd )
118+ if ( args [ "f" ] ) {
119+ return args [ "f" ]
120+ }
121+
122+ if ( args [ "file" ] ) {
123+ return args [ "file" ]
124+ }
125+
126+ return ""
127+ }
128+
110129// sha256 returns sha256(input) hex string
111130function sha256 ( input ) {
112131 return require ( 'crypto' ) . createHash ( 'sha256' ) . update ( input , 'utf8' ) . digest ( 'hex' ) ;
113132}
133+
134+ function sha256File ( filename ) {
135+ return sha256 ( fs . readFileSync ( filename ) )
136+ }
You can’t perform that action at this time.
0 commit comments