diff --git a/docs/local-development.mdx b/docs/local-development.mdx index 92a7a65e..526dc180 100644 --- a/docs/local-development.mdx +++ b/docs/local-development.mdx @@ -163,34 +163,43 @@ Next, you'll need to set up the [Tinybird](https://tinybird.co) Clickhouse datab -In your newly-cloned Dub repo, navigate to the `packages/tinybird` directory. + In your newly-cloned Dub repo, navigate to the `packages/tinybird` directory. - If you have `brew`, install `pipx` by running `brew install pipx`. If not, you can check [installation guide](https://pipx.pypa.io/stable/installation/) for other options. After that, install the Tinybird CLI with `pipx install tinybird-cli` (requires Python >= 3.8). + Install the Tinybird CLI: - Run `tb auth --interactive` and paste your `admin` Auth Token. + ```bash Terminal + curl https://tinybird.co | sh + ``` + + Then authenticate with Tinybird: + + ```bash Terminal + tb login + ``` - Run `tb deploy` to publish the datasource and endpoints in the `packages/tinybird` directory. You should see the following output (truncated for brevity): + Run `tb --cloud deploy` to publish the datasource and endpoints to your Tinybird Cloud workspace. ```bash Terminal - $ tb deploy - - ** Processing ./datasources/click_events.datasource - ** Processing ./endpoints/clicks.pipe - ... - ** Building dependencies - ** Running 'click_events' - ** 'click_events' created - ** Running 'device' - ** => Test endpoint at https://api.us-east.tinybird.co/v0/pipes/device.json - ** Token device_endpoint_read_8888 not found, creating one - ** => Test endpoint with: - ** $ curl https://api.us-east.tinybird.co/v0/pipes/device.json?token=p.ey...NWeaoTLM - ** 'device' created - ... + tb --cloud deploy + ``` + + You should see output like this when the deployment is live: + + ```bash Terminal + Deployment URL: https://cloud.tinybird.co/aws/us-east-1//deployments/ + Job API URL: https://api.us-east.aws.tinybird.co/v0/jobs/ + Jobs URL: https://cloud.tinybird.co/aws/us-east-1//jobs + + * Deployment submitted. It will be auto-promoted when ready. + » Waiting for deployment to be ready... + ✓ Deployment is ready + » Waiting for deployment to be promoted... + ✓ Deployment promoted + ✓ Deployment #1 is live! ``` @@ -199,16 +208,16 @@ In your newly-cloned Dub repo, navigate to the `packages/tinybird` directory. You will then need to update your [Tinybird API base URL](https://www.tinybird.co/docs/api-reference/api-reference.html#regions-and-endpoints) to match the region of your database. - From the previous step, take note of the **Test endpoint** URL. It should look something like this: + From the previous step, take note of the **Job API URL** in the deployment output. It should look something like this: ```bash Terminal - Test endpoint at https://api.us-east.tinybird.co/v0/pipes/device.json + Job API URL: https://api.us-east.aws.tinybird.co/v0/jobs/ ``` - Copy the base URL and paste it as the `TINYBIRD_API_URL` environment variable in your `.env` file. + Copy the base URL before `/v0/jobs` and paste it as the `TINYBIRD_API_URL` environment variable in your `.env` file. ```bash Terminal - TINYBIRD_API_URL=https://api.us-east.tinybird.co + TINYBIRD_API_URL=https://api.us-east.aws.tinybird.co ``` @@ -223,9 +232,7 @@ Next, you'll need to set up the [Upstash](https://upstash.com) Redis database. T -In your [Upstash account](https://console.upstash.com/), create a new database. - -For better performance & read times, we recommend setting up a global database with several read regions. +In your [Upstash account](https://console.upstash.com/), create a new database in the `us-east-1` region. ![Upstash Redis database](/images/upstash-create-db.png) @@ -237,7 +244,7 @@ Once your database is created, copy the `UPSTASH_REDIS_REST_URL` and `UPSTASH_RE ![Upstash Redis tokens](/images/upstash-redis-tokens.png) -Navigate to the [QStash tab](https://console.upstash.com/qstash) and copy the `QSTASH_TOKEN`, `QSTASH_CURRENT_SIGNING_KEY`, and `QSTASH_NEXT_SIGNING_KEY` from the **Request Builder** section into your `.env` file. +Navigate to the [QStash tab](https://console.upstash.com/qstash) and copy `QSTASH_TOKEN`, `QSTASH_CURRENT_SIGNING_KEY`, and `QSTASH_NEXT_SIGNING_KEY` into your `.env` file. You don't need to copy `QSTASH_URL` for local Dub setup. ![Upstash QStash tokens](/images/upstash-qstash-tokens.png) @@ -245,7 +252,7 @@ Navigate to the [QStash tab](https://console.upstash.com/qstash) and copy the `Q - If you're planning to run Qstash-powered background jobs locally, you'll need to set up an Ngrok tunnel to expose your local server to the internet. + If you're testing features that enqueue QStash background jobs locally, you'll need to set up an Ngrok tunnel to expose your local server to the internet. Dub uses QStash for workflows like imports, exports, webhooks, payouts, and other `/api/cron/*` jobs. Without a tunnel, QStash won't be able to call back into your local app. Follow [these steps](https://ngrok.com/docs/getting-started/) to setup `ngrok`, and then run the following command to start an Ngrok tunnel at port `8888`: @@ -253,7 +260,7 @@ Navigate to the [QStash tab](https://console.upstash.com/qstash) and copy the `Q ngrok http 8888 ``` - Copy the `https` URL and paste it as the `NEXT_PUBLIC_NGROK_URL` environment variable in your `.env` file. + Copy the `https` URL and paste it as the `NEXT_PUBLIC_NGROK_URL` environment variable in your `.env` file. If you're using a free Ngrok account, this URL can change when you restart Ngrok, so make sure to update `NEXT_PUBLIC_NGROK_URL` whenever it changes. diff --git a/images/upstash-create-db.png b/images/upstash-create-db.png index 52540116..f4e24a35 100644 Binary files a/images/upstash-create-db.png and b/images/upstash-create-db.png differ diff --git a/images/upstash-qstash-tokens.png b/images/upstash-qstash-tokens.png index f865a356..3a0ad288 100644 Binary files a/images/upstash-qstash-tokens.png and b/images/upstash-qstash-tokens.png differ diff --git a/images/upstash-redis-tokens.png b/images/upstash-redis-tokens.png index a9db45c3..585259a6 100644 Binary files a/images/upstash-redis-tokens.png and b/images/upstash-redis-tokens.png differ