Skip to content

Commit 5e43546

Browse files
committed
add deploy to cloudflare docs + fix getting started
1 parent 63e9106 commit 5e43546

File tree

2 files changed

+101
-11
lines changed

2 files changed

+101
-11
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
title: Deploy to Cloudflare Button
3+
pcx_content_type: concept
4+
sidebar:
5+
order: 5
6+
head: []
7+
description: Set Up a Deploy to Cloudflare Button
8+
---
9+
10+
# Using a Deploy to Cloudflare Button
11+
If you're building a Workers application and would like to share it with other developers, you can embed a Deploy to Cloudflare button in your README, blog post, or documentation to enable others to quickly bootstrap your application on their own Cloudflare account. Deploy to Cloudflare buttons eliminate the need for complex setup, allowing developers to get started with your public GitHub or GitLab repository in just a few clicks.
12+
13+
<insert deploy button here that links to example/>
14+
15+
## What are Deploy to Cloudflare Buttons?
16+
Deploy to Cloudflare buttons simplify the deployment of a Workers application by enabling Cloudflare to:
17+
* **Clone a Git repository**: Cloudflare clones your source repository into the user's GitHub/GitLab account where they can continue development after deploying.
18+
* **Configure a project**: Your users can customize key details such as repository name, Worker name, and required resource names in a single setup page with customizations reflected in the newly created Git repository.
19+
* **Build & deploy**: Cloudflare builds the application using Workers Builds and deploys it to the Cloudflare network. Any required resources are automatically provisioned and bound to the Worker without additional setup.
20+
21+
<insert flow with screenshots/>
22+
23+
## How to Set Up Deploy to Cloudflare buttons
24+
Deploy to Cloudflare buttons can be embedded anywhere developers might want to launch your project. To add a Deploy to Cloudflare button, copy the following snippet and replace the Git repository URL with your project's URL. You can also optionally specify a subdirectory.
25+
26+
27+
<Tabs syncKey="DeployButtonSnippet"> <TabItem label="HTML">
28+
```html
29+
<a href="https://deploy.workers.cloudflare.com/?url=<your git repo URL>"><img src="https://deploy.workers.cloudflare.com/button" alt="Deploy to Cloudflare"/></a>
30+
```
31+
32+
</TabItem>
33+
34+
<TabItem label="Markdown">
35+
```md
36+
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=<git repo URL>)
37+
```
38+
39+
</TabItem>
40+
</Tabs>
41+
42+
If you have already deployed your application using Workers Builds, you can generate a Deploy to Cloudflare button directly from the Cloudflare dashboard by clicking the share button and copying the provided snippet.
43+
44+
<insert image of share icon pop out/>
45+
46+
Once you have your snippet, you can paste this wherever you would like your button to be displayed.
47+
48+
## Automatic Resource Provisioning
49+
If your Worker application requires Cloudflare resources, they will be automatically provisioned as part of the deployment. Currently, supported resources include:
50+
* **Storage**: KV namespaces, D1 databases, R2 buckets, Hyperdrive and Vectorize
51+
* **Compute**: Durable Objects, Workers AI, Containers and Queues
52+
53+
Cloudflare will read the Wrangler configuration file of your source repo to determine resource requirements for your application. During deployment, Cloudflare will provision any necessary resources and update the Wrangler configuration where applicable for newly created resources (e.g. database IDs, namespace IDs). To ensure successful deployment, please make sure your source repository includes default values for resource names, resource IDs and any other properties for each binding.
54+
55+
## Best Practices
56+
**Configuring Build/Deploy commands**: If you are using custom `build` and `deploy` scripts in your package.json (e.g. if using a full stack framework or running D1 migrations), Cloudfare will automatically detect and pre-populate the build and deploy fields. Users can choose to modify or accept the custom commands during deployment configuration.
57+
58+
<insert screenshot of build and deploy command UI/>
59+
60+
If no `deploy` script is specified, Cloudflare will preconfigure `npx wrangler deploy` by default. If no `build` script is specified, Cloudflare will leave this field blank.
61+
62+
** Running D1 Migrations**: If you would like to run migrations as part of your set up, you can specify this in your `package.json` by running your migrations as part of your `deploy` script. The migration command should reference the binding name rather than the database name to ensure migrations are successful when users specify a database name that is different from that of your source repository. The following is an example of how you can set up the scripts section of your `package.json`:
63+
64+
```json
65+
{
66+
"scripts": {
67+
"build": "astro build",
68+
"deploy": "npm run db:migrations:apply && wrangler deploy"
69+
"db:migrations:apply": "wrangler d1 migrations apply DB_BINDING --remote",
70+
}
71+
}
72+
```
73+
74+
## Not currently supported
75+
* **Monorepos**: Cloudflare does not fully support monorepos unless your application is completely isolated within a subdirectory and has no dependencies outside of that subdirectory (for example, [a monorepo of example applications](https://github.com/cloudflare/templates)). If your application relies on dependencies outside its subdirectory, the build will fail. Additionally, if your monorepo contains multiple Workers applications, they will not be deployed together. You must configure a separate Deploy to Cloudflare button for each application. The user will manually create a distinct Workers application for each subdirectory.
76+
* **Pages applications**: Deploy to Cloudflare buttons only support Workers applications today.
77+
* **Non gitHub.com/gitLab.com repositories**: Source repositories from anything other than gitHub.com and gitLab.com are not supported. Self-hosted versions of GitHub and GitLab are also not supported.
78+
* **Private repositories**: Repositories must be public in order for others to successfully use your Deploy to Cloudflare button.

src/content/docs/workers/get-started/dashboard.mdx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,36 @@ Follow this guide to create a Workers application using [the Cloudflare dashboar
2020

2121
## Setup
2222

23-
To create a Workers application:
23+
To get started with a new Workers application:
2424

25-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
26-
2. Go to **Workers & Pages**.
27-
3. Select **Create**.
28-
4. Select a template or **Create Worker**.
29-
5. Review the provided code and select **Deploy**.
30-
6. Preview your Worker at its provided [`workers.dev`](/workers/configuration/routing/workers-dev/) subdomain.
25+
1. Click [Create](https://dash.cloudflare.com/?to=/:account/workers-and-pages/create) in the Workers & Pages section of the dashboard
26+
2. You can select from the gallery of existing templates or choose to connect to GitHub or GitLab, import an existing repository on your own account or let Cloudflare clone and bootstrap a public repository containing a Workers application.
27+
3. Once you've connected to your chosen Git provider, configure your project and click `Deploy`.
28+
4. Cloudflare will kick off a build and deployment. Once deployed, preview your Worker at its provided `workers.dev` subdomain.
3129

3230
## Development
31+
Applications started in the dashboard are set up with Git to help kickstart your development workflow. To continue developing on your repository, you can run:
3332

34-
<Render file="dash-creation-next-steps" />
33+
```bash
34+
# clone you repository locally
35+
git clone <git repo URL>
36+
# be sure you are in the root directory
37+
cd <directory>
38+
```
3539

36-
## Next steps
40+
Now, you can preview and test your changes by [running Wrangler in your local development environment](/workers/local-development/). Once you are ready to deploy you can run:
41+
42+
```bash
43+
# adds the files to git tracking
44+
git add .
45+
# commits the changes
46+
git commit -m "your message"
47+
# push the changes to your Git provider
48+
git push origin main
49+
```
3750

38-
To do more:
3951

40-
- Push your project to a GitHub or GitLab respoitory then [connect to builds](/workers/ci-cd/builds/#get-started) to enable automatic builds and deployments.
52+
To do more:
4153
- Review our [Examples](/workers/examples/) and [Tutorials](/workers/tutorials/) for inspiration.
4254
- Set up [bindings](/workers/runtime-apis/bindings/) to allow your Worker to interact with other resources and unlock new functionality.
4355
- Learn how to [test and debug](/workers/testing/) your Workers.

0 commit comments

Comments
 (0)