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

Documentation on how to deploy static site #70

Open
duffn opened this issue Aug 12, 2020 · 3 comments
Open

Documentation on how to deploy static site #70

duffn opened this issue Aug 12, 2020 · 3 comments
Labels
question Further information is requested

Comments

@duffn
Copy link

duffn commented Aug 12, 2020

First, thanks for these utilities.

I'm having difficulty figuring out how to deploy a simple static site. What should I be passing into the --site argument? I have my static site build locally and in a public directory in the cwd.

./node_modules/.bin/cfworker deploy-dev -s public

results in

✖ Error: Could not load rollup:plugin-multi-entry:entry-point: invalid glob pattern:

I'm happy to open a PR for the README if I can figure out how to properly pass in my static site directory.

@jdanyow
Copy link
Member

jdanyow commented Aug 24, 2020

Wrangler sites creates a worker script that uses @cloudflare/kv-asset-handler. The script looks like this: https://github.com/cloudflare/kv-asset-handler#return

cfworker doesn't generate a site worker script so you'd need to create one using the example above. Assuming you created a worker script matching the example and the script was at ./path/to/worker.js then the following command should work:

cfworker run ./path/to/worker.js --site ./path/to/site/folder --watch --inspect

I've not tried this to be honest, I don't use @cloudflare/kv-asset-handler in my applications due to some custom requirements, however cfworker's deploy logic was written to be compatible with @cloudflare/kv-asset-handler's manifest format, kv key format, and default bindings:

@duffn
Copy link
Author

duffn commented Aug 28, 2020

Thank you, this worked! Well, very nearly.

With your direction, here's what I did for others to reference.

  • wrangler init --site my-site-name.
  • Took the contents of index.js in workers-site from the files generated by the above command.
  • Created a worker.js file with the above contents (you can just as easily use the created index.js file itself).
  • Built my static site into the public directory.
  • ./node_modules/.bin/cfworker deploy-dev ./worker.js --site ./public

This resulted in deploying my static site correctly to my dev domain on Cloudflare workers. 🎉

However, this little deploy button was not checked, requiring me to manually check it in order to fully deploy and visit my site. This was during the first deploy only. It remains in a checked state for subsequent deploys.

Screen Shot 2020-08-28 at 8 14 57 AM

I'm going to look through the codebase to see if I can locate where this would happen (and if it's possible to automate this), but would take any direction if you have it.

Thanks!

@jdanyow
Copy link
Member

jdanyow commented Aug 28, 2020

@duffn nice work! Looks like cfworker is missing this step:

https://github.com/cloudflare/wrangler/blob/7798fb04242fc58e8e58c98087bd40b04a126134/src/deploy/mod.rs#L52-L64

(posting { enabled: true })

Probably goes here in the deploy code, apologies this area isn't very tidy 😬
https://github.com/cfworker/cfworker/blob/master/packages/dev/src/cloudflare-api.js#L94

@jdanyow jdanyow added the question Further information is requested label Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants