-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed
Closed
Copy link
Labels
@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.docs/inlineRelated to inline documentation of the API ReferenceRelated to inline documentation of the API ReferencedocumentationThis is a problem with documentation.This is a problem with documentation.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1
Description
When using lambda.Code.fromAsset and cdk.BundlingDockerImage.fromAsset together, synth fails to find anything in \asset-output
Reproduction Steps
- Create a Dockerfile that compiles and copies files to an
/asset-outputdirectory
FROM python:3.7-slim
COPY . /asset-input
COPY . /asset-output
WORKDIR /asset-input
RUN apt-get update && apt-get -y install curl make automake gcc g++ subversion python3-dev
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 -
ENV PATH "/root/.poetry/bin:/opt/venv/bin:${PATH}"
RUN poetry export -f requirements.txt -o requirements.txt
RUN pip3 install -r requirements.txt -t /asset-output
- Use the following snippet when creating the lambda using cdk:
code: lambda.Code.fromAsset(PROJECT_DIR, {
bundling: {
image: cdk.BundlingDockerImage.fromAsset(PROJECT_DIR)
}
}),
- Run
tsc && cdk synth -o cdk.out
What did you expect to happen?
Docker should find the compiled assets in /asset-output
What actually happened?
Error: Bundling did not produce any output. Check that content is written to /asset-output.
Environment
- CDK CLI Version : 1.75.0
- Framework Version: 1.75.0
- Node.js Version: v15.3.0
- OS : Mac Catalina 10.15.7
- Language (Version): TypeScript 4.1.2
Other
If I use an implementation of ILocalBundling that is mostly copied from asset-staging.ts but calls both run and cp the synth works but I don't believe that should be necessary:
class LocalBundling implements ILocalBundling {
tryBundle(outputDir: string, options: BundlingOptions): boolean {
let user: string;
if (options.user) {
user = options.user;
} else {
// Default to current user
const userInfo = os.userInfo();
user =
userInfo.uid !== -1 // uid is -1 on Windows
? `${userInfo.uid}:${userInfo.gid}`
: "1000:1000";
}
// Always mount input and output dir
const volumes = [
{
hostPath: PROJECT_DIR, // this.sourcePath
containerPath: AssetStaging.BUNDLING_INPUT_DIR,
},
{
hostPath: outputDir, // bundleDir
containerPath: AssetStaging.BUNDLING_OUTPUT_DIR ?? outputDir,
},
...(options.volumes ?? []),
];
options.image.run({
command: options.command,
user,
volumes,
environment: options.environment,
workingDirectory:
options.workingDirectory ?? AssetStaging.BUNDLING_INPUT_DIR,
});
options.image.cp(AssetStaging.BUNDLING_OUTPUT_DIR ?? outputDir, outputDir);
return true;
}
}
This is 🐛 Bug Report
Metadata
Metadata
Assignees
Labels
@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.docs/inlineRelated to inline documentation of the API ReferenceRelated to inline documentation of the API ReferencedocumentationThis is a problem with documentation.This is a problem with documentation.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1