-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the same DockerContext and Dockerfile paths as the CDK is using (#…
…4074) * Use the same DockerContext and Dockerfile paths as the CDK is using * Add tests to ensure `Dockerfile` can be a path to a docker file via subdirectories. This means images can share code more easily. * Add tests to ensure SAM supports CDK apps where Docker image asset `file` is a path to a docker file via subdirectories. * Fixed failing test after merge conflict with commit fa26bff Co-authored-by: Wing Fung Lau <4760060+hawflau@users.noreply.github.com> Co-authored-by: Mohamed Elasmar <71043312+moelasmar@users.noreply.github.com> Co-authored-by: Mehmet Nuri Deveci <5735811+mndeveci@users.noreply.github.com>
- Loading branch information
1 parent
339e8d6
commit c29d13e
Showing
27 changed files
with
458 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM public.ecr.aws/lambda/nodejs:14 | ||
|
||
# Add the lambda handler for this feature | ||
COPY DockerImageFunctionWithSharedCode/app.js ./ | ||
|
||
# Add the shared code | ||
COPY SharedCode/ ./SharedCode | ||
|
||
# Add the shared dependencies | ||
COPY package.json ./ | ||
|
||
# Install the dependencies | ||
RUN npm install | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "app.lambdaHandler" ] |
24 changes: 24 additions & 0 deletions
24
...ion/cdk/testdata/src/docker/ImagesWithSharedCode/DockerImageFunctionWithSharedCode/app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var gen = require('unique-names-generator'); | ||
const {sayHelloWorld} = require("./SharedCode/shared"); | ||
|
||
const colorName = gen.uniqueNamesGenerator({ | ||
dictionaries: [gen.colors] | ||
}); | ||
|
||
|
||
exports.lambdaHandler = async(event, context) => { | ||
let response; | ||
|
||
try { | ||
response = { | ||
'statusCode': 200, | ||
'body': JSON.stringify({ | ||
message: sayHelloWorld("docker image function construct"), | ||
}), | ||
}; | ||
} catch (err) { | ||
console.log(err); | ||
return err; | ||
} | ||
return response; | ||
}; |
16 changes: 16 additions & 0 deletions
16
.../cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM public.ecr.aws/lambda/nodejs:14 | ||
|
||
# Add the lambda handler for this feature | ||
COPY FunctionImageAssetWithSharedCode/app.js ./ | ||
|
||
# Add the shared code | ||
COPY SharedCode/ ./SharedCode | ||
|
||
# Add the shared dependencies | ||
COPY package.json ./ | ||
|
||
# Install the dependencies | ||
RUN npm install | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "app.lambdaHandler" ] |
24 changes: 24 additions & 0 deletions
24
...tion/cdk/testdata/src/docker/ImagesWithSharedCode/FunctionImageAssetWithSharedCode/app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var gen = require('unique-names-generator'); | ||
const {sayHelloWorld} = require("./SharedCode/shared"); | ||
|
||
const colorName = gen.uniqueNamesGenerator({ | ||
dictionaries: [gen.colors] | ||
}); | ||
|
||
|
||
exports.lambdaHandler = async(event, context) => { | ||
let response; | ||
|
||
try { | ||
response = { | ||
'statusCode': 200, | ||
'body': JSON.stringify({ | ||
message: sayHelloWorld("function construct with image asset"), | ||
}), | ||
}; | ||
} catch (err) { | ||
console.log(err); | ||
return err; | ||
} | ||
return response; | ||
}; |
4 changes: 4 additions & 0 deletions
4
tests/iac_integration/cdk/testdata/src/docker/ImagesWithSharedCode/SharedCode/shared.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
exports.sayHelloWorld = (from) => { | ||
return `Hello World from ${from} with a Dockerfile that shares code with another Dockerfile`; | ||
} |
Oops, something went wrong.