Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix permanent docker asset diff #318

Merged
merged 9 commits into from
Jan 2, 2025
Merged

Fix permanent docker asset diff #318

merged 9 commits into from
Jan 2, 2025

Conversation

corymhall
Copy link
Contributor

@corymhall corymhall commented Dec 30, 2024

Docker assets show a permanent diff on preview due to the cdk.out directory using an absolute path to a system temporary directory. Even if the asset does not change, the temporary directory will always be different.

There are two ways we could go about solving this:

  1. Update our internally created cdk.App to always set outdir to a relative cdk.out directory
  2. Update our docs to point users to set this themselves.

I opted for the second route mainly because this follows the default behavior of CDK. Almost all CDK applications will have a cdk.json file to configure some basic settings, one of them being the outdir setting. We don't require users to have this file, but we should be strongly encouraging users to have this because there are a couple of additional things that users should set (app, and context feature flags).

I've updated the readme to have an additional Getting Started section which matches what we have in https://www.pulumi.com/docs/iac/clouds/aws/guides/cdk/. I've added the cdk.json part (i'll need to also go back and add this to the guide).

closes #287

@@ -42,13 +42,17 @@ jobs:
uses: ./.github/actions/build

test:
needs:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the build/test was failing, but the integration tests were still running. I think it's better to fail fast here.

SkipRefresh: true,
Quick: true,
ExpectRefreshChanges: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've fixed most of these issues, but there is still an issue with refresh changes with IAM roles due to #293

@@ -2,8 +2,7 @@ FROM node:lts AS builder

WORKDIR /app

COPY package.json yarn.lock ./
COPY app ./
COPY package.json yarn.lock index.ts ./
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way the docker image only changes when the app folder changes not the entire fargate folder.

src/stack.ts Outdated
@@ -238,6 +238,7 @@ export class App
}

const app = new cdk.App({
outdir: 'cdk.out',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively we could keep the default as is and instruct people that use Docker assets to provide this property.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was not formatted.

@corymhall corymhall marked this pull request as draft December 30, 2024 20:57
@@ -292,7 +296,9 @@ describe('cloud assembly manifest reader', () => {

expect(() => {
AssemblyManifestReader.fromDirectory(path.dirname(manifestFile));
}).toThrow(/no such file or directory, open '\/tmp\/foo\/bar\/does\/not\/exist\/MyNestedStack.template.json'/);
}).toThrow(
/Failed to read CloudFormation template at path: \/tmp\/foo\/bar\/does\/not\/exist\/MyNestedStack.template.json/,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were asserting on the runtime error which must be different between node versions as I was getting a different error locally vs in CI. Updated this to assert on the error that we throw.

@corymhall corymhall requested review from flostadler and t0yv0 January 2, 2025 15:35
@corymhall corymhall marked this pull request as ready for review January 2, 2025 15:35
@corymhall corymhall self-assigned this Jan 2, 2025
README.md Outdated
CDK application.
- `output`: The directory location where the CDK output will be placed. If this
is not specified it will be placed in a system temporary directory and could
cause issues with Docker assets.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd point out what issues exactly, IMO this makes it sound like something will go wrong or the docker images will get mangled.

@corymhall corymhall force-pushed the corymhall/docker-diff branch from 37851dc to 301b3ba Compare January 2, 2025 18:00
@corymhall corymhall enabled auto-merge (squash) January 2, 2025 18:58
@corymhall corymhall merged commit fe95806 into main Jan 2, 2025
13 checks passed
@corymhall corymhall deleted the corymhall/docker-diff branch January 2, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docker images show diff on every operation
2 participants