Skip to content

Resolve dockerfile to absolute path in redirected config in vite plugin #10038

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

Merged
merged 4 commits into from
Jul 22, 2025

Conversation

emily-shen
Copy link
Contributor

To the same purpose as #10005, but in a different place :)


  • Tests
    • Tests included
    • Tests not necessary because: cannot be tested right now because preview doesn't work with containers. But this has been tested manually.
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: fixup
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: new

@emily-shen emily-shen requested review from a team as code owners July 22, 2025 09:47
Copy link

changeset-bot bot commented Jul 22, 2025

🦋 Changeset detected

Latest commit: 0f5b3f1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented Jul 22, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@10038

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@10038

miniflare

npm i https://pkg.pr.new/miniflare@10038

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@10038

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@10038

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@10038

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@10038

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@10038

wrangler

npm i https://pkg.pr.new/wrangler@10038

commit: 0f5b3f1

// however, wrangler deploy will re-resolve the config, so we should
// deduplicate the container.configuration.image field in favour of
// the non-deprecated one when we write out the deploy config
delete container.configuration?.image;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we set this to undefined in the output variable above rather than deleting here?

Copy link
Contributor Author

@emily-shen emily-shen Jul 22, 2025

Choose a reason for hiding this comment

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

What are your concerns with deleting it? I'd rather not have two different values for image kicking around here, the ContainerApp type and validation in wrangler is quite messed up. I have a refactor PR that should clean this up soon, but in the meantime its really hard in wrangler to know whether you should use container.configuration.image or container.image, since the types are just wrong 😭

Copy link
Contributor

Choose a reason for hiding this comment

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

Your version is fine and it doesn't make any difference to the behaviour.

// Wrangler's config validation resolves to container.configuration.image, even though it is deprecated
const image =
container.configuration?.image ?? container.image;
if (isDockerfile(image, workerConfig.configPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it matter that workerConfig.configPath is possible undefined here? Not sure if it ever can actually be undefined or if that's just a types thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah - if its possibly undefined, then we fall back on the cwd. is there a better fallback i should be using here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that should be OK for now. We may be able to assert the configPath if it's always defined but would need to investigate more.

Copy link
Contributor Author

@emily-shen emily-shen left a comment

Choose a reason for hiding this comment

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

I noticed that in wrangler we are also not resolving image_build_context to an absolute path, so i fixed that in 1776a99, even though it is not strictly related to this.

@emily-shen emily-shen requested a review from jamesopstad July 22, 2025 10:36
Copy link
Contributor

@jamesopstad jamesopstad left a comment

Choose a reason for hiding this comment

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

Looks good. Have you tested this manually?

// Wrangler's config validation resolves to container.configuration.image, even though it is deprecated
const image =
container.configuration?.image ?? container.image;
if (isDockerfile(image, workerConfig.configPath)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that should be OK for now. We may be able to assert the configPath if it's always defined but would need to investigate more.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jul 22, 2025
@emily-shen emily-shen merged commit a355327 into main Jul 22, 2025
43 of 45 checks passed
@emily-shen emily-shen deleted the emily/resolve-dockerfile-vite branch July 22, 2025 11:06
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants