fix: correctly resolve layer package artifact and docker image paths (#12972)

This commit is contained in:
Tomasz Czubocha 2025-01-07 16:12:38 +01:00 committed by GitHub
parent 3704754e68
commit 2aea99d345
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 5 deletions

View File

@ -169,6 +169,7 @@ export default {
}
return getLambdaLayerArtifactPath(
this.packagePath,
this.serverless.serviceDir,
name,
this.provider.serverless.service,
this.provider.naming,

View File

@ -60,6 +60,7 @@ class AwsCompileLayers {
let layerLogicalId = this.provider.naming.getLambdaLayerLogicalId(layerName)
const layerArtifactPath = getLambdaLayerArtifactPath(
this.packagePath,
this.serverless.serviceDir,
layerName,
this.provider.serverless.service,
this.provider.naming,

View File

@ -2424,11 +2424,11 @@ Object.defineProperties(
await this.ensureDockerIsAvailable()
let isDockerfileAvailable = false
const pathToDockerfile = path.resolve(
const absoluteImagePath = path.resolve(
this.serverless.serviceDir,
imagePath,
imageFilename,
)
const pathToDockerfile = path.resolve(absoluteImagePath, imageFilename)
try {
const stats = await fsp.stat(pathToDockerfile)
@ -2470,7 +2470,7 @@ Object.defineProperties(
...buildArgsArr,
...cacheFromArr,
...buildOptions,
imagePath,
absoluteImagePath,
]
// These are optional arguments, so we only append to the arguments

View File

@ -2,15 +2,16 @@ import path from 'path'
/**
* @param packagePath {string}
* @param serviceDir {string}
* @param layerName {string}
* @param service
* @param naming
* @returns {string}
*/
export default (packagePath, layerName, service, naming) => {
export default (packagePath, serviceDir, layerName, service, naming) => {
const layerObject = service.getLayer(layerName)
if (layerObject.package && layerObject.package.artifact) {
return layerObject.package.artifact
return path.resolve(serviceDir, layerObject.package.artifact)
}
return path.join(packagePath, naming.getLayerArtifactName(layerName))
}