Skip to content

Commit 6b07c18

Browse files
authored
fix: Fix Dockerfile reference issue (#35)
* fix: Fix Dockerfile reference issue * Moving Dockerfile to be packged by CI * Fixing docker tests * Fix bundling tests and force Docker bundling for Integration tests to guarantee same behavior between local / CI tests
1 parent f1eda13 commit 6b07c18

7 files changed

+13
-4
lines changed

src/Dockerfile Dockerfile

File renamed without changes.

src/bundling.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class Bundling implements CdkBundlingOptions {
111111
!checkInstalledTarget(toTarget(this.props.architecture));
112112
this.image = shouldBuildImage
113113
? props.dockerImage ??
114-
DockerImage.fromBuild(path.join(__dirname, '../src'), {
114+
DockerImage.fromBuild(path.join(__dirname, '../'), {
115115
buildArgs: {
116116
...(props.buildArgs ?? {}),
117117
// If runtime isn't passed use regional default, lowest common denominator is node18

test/bundling.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('Bundling in Docker', () => {
8080
);
8181

8282
expect(DockerImage.fromBuild).toHaveBeenCalledWith(
83-
expect.stringMatching(/aws-lambda-rust\/src$/),
83+
expect.stringMatching(/aws-lambda-rust\/$/),
8484
expect.objectContaining({
8585
buildArgs: expect.objectContaining({
8686
IMAGE: expect.stringMatching(/build-provided.al2023$/),
@@ -274,7 +274,7 @@ describe('Bundling in Docker', () => {
274274
});
275275

276276
expect(DockerImage.fromBuild).toHaveBeenCalledWith(
277-
expect.stringMatching(/src$/),
277+
expect.stringMatching(/aws-lambda-rust\/$/),
278278
expect.objectContaining({
279279
buildArgs: expect.objectContaining({
280280
HELLO: 'WORLD',

test/docker.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const docker = process.env.CDK_DOCKER ?? 'docker';
66
beforeAll(() => {
77
const process = spawnSync(
88
docker,
9-
['build', '-t', 'cargo-builder', path.join(__dirname, '../src')],
9+
['build', '-t', 'cargo-builder', path.join(__dirname, '../')],
1010
{ stdio: 'inherit' },
1111
);
1212
expect(process.error).toBeUndefined();

test/integ.function-bins.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class TestStack extends Stack {
1515
const fn = new RustFunction(this, 'binary1', {
1616
entry: 'rust-bins/Cargo.toml',
1717
binaryName: 'my_lambda1',
18+
bundling: {
19+
forceDockerBundling: true,
20+
},
1821
});
1922
this.functionName = fn.functionName;
2023

test/integ.function-workspace.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class TestStack extends Stack {
1515
const fn = new RustFunction(this, 'binary1', {
1616
entry: 'rust-workspaces/Cargo.toml',
1717
binaryName: 'my_lambda2',
18+
bundling: {
19+
forceDockerBundling: true,
20+
},
1821
});
1922
this.functionName = fn.functionName;
2023

test/integ.function.ts

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class TestStack extends Stack {
1414

1515
const fn = new RustFunction(this, 'binary1', {
1616
entry: 'rust-standalone/Cargo.toml',
17+
bundling: {
18+
forceDockerBundling: true,
19+
},
1720
});
1821
this.functionName = fn.functionName;
1922

0 commit comments

Comments
 (0)