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

wrangler deploy: Be able to deploy containers #8586

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

gabivlj
Copy link
Contributor

@gabivlj gabivlj commented Mar 19, 2025

We are adding a new step into wrangler deploy that allows the user to
deploy container applications through wrangler deploy.

The main changes on this commit allow:
 1. cloudchamber/build.ts to accomodate the needs of the new deploy path
    of containers.
 2. cloudchamber/apply.ts to create a Cloudchamber rollout.
 3. deploy.ts to call a method when containers option is defined.

 This method in cloudchamber/deploy.ts does the following:

  1. Call fetchVersion to know what's the namespace_id of the target
     DOs.
  2. Deploy each container application.
     Each container application might specify a Dockerfile or an image
     URI. If it's a Dockerfile, we will read it and build it.

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • Wrangler E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: no containers integration.
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: private product at this point.
  • Wrangler V3 Backport
    • TODO (before merge)
    • PR:
    • Not necessary because: I don't think it's necessary.

Copy link

changeset-bot bot commented Mar 19, 2025

🦋 Changeset detected

Latest commit: 84df6e2

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers 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
Contributor

github-actions bot commented Mar 19, 2025

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-wrangler-8586

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8586/npm-package-wrangler-8586

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-wrangler-8586 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-workers-bindings-extension-8586 -O ./cloudflare-workers-bindings-extension.0.0.0-v6faaad36a.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v6faaad36a.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-create-cloudflare-8586 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-kv-asset-handler-8586

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-miniflare-8586

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-pages-shared-8586

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-unenv-preset-8586

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-vite-plugin-8586

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-vitest-pool-workers-8586

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-workers-editor-shared-8586

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-workers-shared-8586

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14118078665/npm-package-cloudflare-workflows-shared-8586

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@4.5.1 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 4.20250321.1
workerd 1.20250321.0 1.20250321.0
workerd --version 1.20250321.0 2025-03-21

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@gabivlj gabivlj force-pushed the gv/containers-7 branch 3 times, most recently from 5e68476 to ac113c1 Compare March 20, 2025 14:49
@gabivlj gabivlj changed the title Gv/containers 7 wrangler deploy: Be able to deploy containers Mar 20, 2025
@Maximo-Guk
Copy link
Member

pre-release build worked great for me!

Copy link
Contributor

@IRCody IRCody left a comment

Choose a reason for hiding this comment

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

This is great. Left a few minor comments.

appConfigNoDefaults.durable_objects.namespace_id
) {
crash(
`Application "${prevApp.name}" is assigned to durable object ${prevApp.durable_objects.namespace_id}, but a new DO namespace is being assigned to the application,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call out how they can delete the container application in this message?

const [_result, err] = await wrap(
promiseSpinner(
RolloutsService.createApplicationRollout(action.id, {
description: "Progressive update",
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we expect users to introspect the rollouts api directly? If yes would it be helpful to add the container version in the rollout description?

@@ -0,0 +1,153 @@
import { readFileSync } from "fs";
Copy link
Contributor

@IRCody IRCody Mar 20, 2025

Choose a reason for hiding this comment

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

Do you think this file should be here or under src/containers?

targetDurableObjectNamespace.type !== "durable_object_namespace" ||
targetDurableObjectNamespace.namespace_id === undefined
)
throw new Error("unreachable");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think I still like the brackets around these.


return defaultBuildCommand;
if (options.args !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for cleaning up this file.

// not found, not a dockerfile, let's try parting the image ref as an URL?
isDockerImage = false;
try {
if (!imageRef.includes(":")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A ":" doesn't guarantee a tag because you can specify a port as well even though I think that's less commonly used.

[HOST[:PORT]/]NAMESPACE/REPOSITORY[:TAG]

Maybe split on "/" and then check if the last section has a ':'?

throw new Error(`Error reading file ${imagePath}: ${err.message}`);
}

// not found, not a dockerfile, let's try parting the image ref as an URL?
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: s/parting/parsing

throw new Error("image reference needs to include atleast a tag ':'");
}

const url = new URL(`https://${imageRef}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

What case is this catching?

@gabivlj gabivlj force-pushed the gv/containers-7 branch 2 times, most recently from 2e64835 to 425852a Compare March 26, 2025 23:42
applications

We are adding a new step into wrangler deploy that allows the user to
deploy container applications through wrangler deploy.

The main changes on this commit allow:
 1. cloudchamber/build.ts to accomodate the needs of the new deploy path
    of containers.
 2. cloudchamber/apply.ts to create a Cloudchamber rollout.
 3. deploy.ts to call a method when containers option is defined.

 This method in cloudchamber/deploy.ts does the following:

  1. Call fetchVersion to know what's the namespace_id of the target
     DOs.
  2. Deploy each container application.
     Each container application might specify a Dockerfile or an image
     URI. If it's a Dockerfile, we will read it and build it.
@gabivlj gabivlj force-pushed the gv/containers-7 branch 2 times, most recently from 5cf3a6d to 84df6e2 Compare March 27, 2025 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

3 participants