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

Add build and push subcommands to cloudchamber #7378

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IRCody
Copy link
Contributor

@IRCody IRCody commented Nov 27, 2024

Describe your change...
Add build and push subcommands to cloudchamber that build a docker image and push to the cloudchamber managed registry using a local docker daemon.

I wanted to get feedback on behavior/approach now but making a draft because still some todos:

  • Testing the interaction with docker by mocking the docker calls to make sure we are passing the intended flags.
  • Clean up the ux/command descriptions.

  • Tests
    • TODO (before merge)- some basic tests included but need to add some more before merge.
    • [] Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • [] Not required because:
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

@IRCody IRCody requested a review from mikenomitch November 27, 2024 21:18
Copy link

changeset-bot bot commented Nov 27, 2024

🦋 Changeset detected

Latest commit: ebb28fd

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

This PR includes changesets to release 2 packages
Name Type
wrangler Minor
@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

@IRCody IRCody force-pushed the cloudchamber-build branch 3 times, most recently from 5e7b0b0 to 138e8b2 Compare December 13, 2024 04:09
Copy link
Contributor

github-actions bot commented Dec 13, 2024

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/12898243735/npm-package-wrangler-7378

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

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

Or you can use npx with this latest build directly:

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

cloudflare-workers-bindings-extension:

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

create-cloudflare:

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

@cloudflare/kv-asset-handler:

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

miniflare:

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

@cloudflare/pages-shared:

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

@cloudflare/unenv-preset:

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

@cloudflare/vite-plugin:

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

@cloudflare/vitest-pool-workers:

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

@cloudflare/workers-editor-shared:

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

@cloudflare/workers-shared:

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

@cloudflare/workflows-shared:

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

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


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20241230.2
workerd 1.20241230.0 1.20241230.0
workerd --version 1.20241230.0 2024-12-30

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

@IRCody IRCody force-pushed the cloudchamber-build branch from 138e8b2 to 16f1c9f Compare December 13, 2024 04:42
@IRCody IRCody force-pushed the cloudchamber-build branch from 16f1c9f to 8e75c5e Compare December 13, 2024 18:27
IRCody added 2 commits January 2, 2025 17:30
Added additional tests
Removed login to managed registry in favor of credential helper
Fixed lots of input validation/corner cases
Piped dockers output directly to our stdio instead of trying to
intercept.
return yargs
.positional("PATH", {
type: "string",
describe: "path for the directory containing the dockerfile",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
describe: "path for the directory containing the dockerfile",
describe: "path to the directory containing the Dockerfile to build",

alias: "t",
type: "string",
demandOption: true,
describe: "Tag to use for the built image",
Copy link
Member

Choose a reason for hiding this comment

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

We should mention that this should also include the name of the image, not just the tag (i.e. it should be -t foo-bar:1.0, not just -t 1.0).

docker build describes this as "Name and optionally a tag (format: "name:tag")". I think we should just use the exact same phrasing since it just gets passed to docker build -t anyway.

Suggested change
describe: "Tag to use for the built image",
describe: "Name and optionally a tag (format: \"name:tag\")",

.option("path-to-docker", {
type: "string",
default: "docker",
describe: "path to docker binary",
Copy link
Member

Choose a reason for hiding this comment

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

The option is called "path-to-docker" but accepts a command (i.e. "docker") so maybe docker-cmd is a better name? Path implies a full path.

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 is used to find the binary for docker. So if it's on your $PATH you can use 'docker' but if not you can pass it here.

Maybe the description could be changed to something like:

Add the path to your docker binary if it's not on your $PATH?

})
.option("build-command", {
type: "string",
describe: "custom build command to use",
Copy link
Member

Choose a reason for hiding this comment

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

I'm not really sure what this option does from the description or why/how it's different from the path-to-docker option. Do we need both? Can we eliminate one or the other?

I'm also curious to read more about the use case for this option. It strikes me as a potential footgun since specifying a custom build command seems to ignore all of the other options provided to this command, which seems like it could be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The use case is you want to do something more complicated than we want to support so you can use this to hook in.

I could go either way on including it. Thinking about it again it seems pretty rare that someone will both need this level of control and not be comfortable using docker directly.

@mikenomitch: wdyt?

Agree the description needs more info for context if the option is going to stay.. Not sure a great way to phrase it but here is an attempt:

Build command to use instead of our default one. Note: Will override all of our defaults.

})
.option("platform", {
type: "string",
default: "linux/amd64",
Copy link
Member

Choose a reason for hiding this comment

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

Can we make the default whatever the user is using (e.g. linux/arm64 on an M1 Mac and linux/amd64 on x86)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reasoning for defaulting to linux/amd64 is that is the only supported platform in cc today.

.option("push", {
alias: "p",
type: "boolean",
describe: "push the built image to a registry",
Copy link
Member

Choose a reason for hiding this comment

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

Nit: since this only supports pushing to one registry, we should make that clear

Suggested change
describe: "push the built image to a registry",
describe: "push the built image to Cloudflare's managed registry",

I see there's a TODO comment to potentially change this though. If that's the case then this suggestion doesn't apply.

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.

2 participants