-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from WcaleNieWolny/self_hosting_docs
- Loading branch information
Showing
6 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions
56
src/content/docs/docs/self-hosted/local-dev/capacitor-updater.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Using the capacitor updater with self-hosted capgo" | ||
sidebar: | ||
order: 2 | ||
--- | ||
|
||
## What this tutorial will cover? | ||
|
||
This tutorial will show how to use capacitor updater in a dev environment with self hosted capgo | ||
|
||
## Requirements | ||
|
||
1. [Cloned capgo](https://github.com/Cap-go/capgo) | ||
|
||
## Getting started | ||
|
||
To use the capacitor updater with self-hosted capgo edit the `capacitor.config.ts` from your app directory and set it like this: | ||
|
||
```ts | ||
const config: CapacitorConfig = { | ||
appId: 'com.demo.app', | ||
appName: 'demoApp', | ||
webDir: 'dist', | ||
bundledWebRuntime: false, | ||
plugins: { | ||
CapacitorUpdater : { | ||
statsUrl: "http://localhost:54321/functions/v1/stats", | ||
channelUrl: "http://localhost:54321/functions/v1/channel_self", | ||
updateUrl: "http://localhost:54321/functions/v1/updates" | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
This will enable you to use local capgo in development. However, by default, this is not enough. | ||
|
||
In Android enabling [plaintext communication](https://developer.android.com/topic/security/risks/cleartext) is required as by default SSL is disabled in local. | ||
This can be achived by modifying [AndroidManifest.xml](https://github.com/Cap-go/capacitor-updater/blob/main/android/src/main/AndroidManifest.xml) and adding `android:usesCleartextTraffic="true"` in the `application` tag | ||
A full example of this change can be seen [here](https://gist.github.com/WcaleNieWolny/061a015acdebe35eaf3afd7030797701) | ||
|
||
Since by default, Android does not allow `http` capgo has implemented a check for http [here](https://github.com/Cap-go/capgo/blob/4cce6c0707d745faa2afbab643e636bad927c602/supabase/functions/updates/index.ts#L396) | ||
This code might not be always here, but for now a change to this line is required to get updates working | ||
This line should look something like this: | ||
```ts | ||
if (!signedURL || (signedURL.startsWith('http://') || signedURL.startsWith('https://'))) { | ||
``` | ||
:::danger | ||
⚠️ Do not commit `supabase/functions/updates/index.ts` into the remote repo\ | ||
This code is here [on purpose](https://github.com/Cap-go/capacitor-updater/issues/37#issuecomment-1684916354) | ||
::: | ||
There also could be a problem that prevents the android app from connecting. If you do not see any requests being send to edge functions run | ||
```bash | ||
adb reverse tcp:54321 tcp:54321 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: "Using the CLI with self-hosted capgo" | ||
sidebar: | ||
order: 2 | ||
--- | ||
|
||
## What this tutorial will cover? | ||
|
||
This tutorial will show how to use CLI in a dev environment with self hosted capgo | ||
|
||
## Getting started | ||
|
||
To use the CLI with self-hosted capgo edit the `capacitor.config.ts` from your app directory and set it like this: | ||
|
||
```ts | ||
const config: CapacitorConfig = { | ||
appId: 'com.demo.app', | ||
appName: 'demoApp', | ||
webDir: 'dist', | ||
bundledWebRuntime: false, | ||
plugins: { | ||
CapacitorUpdater : { | ||
localHost: "http://localhost:5173", | ||
localWebHost: "http://localhost:5173", | ||
localSupa: "http://localhost:54321", | ||
localSupaAnon: "see_notes", | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
Note: To get `localSupaAnon` please follow [this tutorial](http://localhost:3000/docs/self-hosted/local-dev/getting-started/) and copy the `anon key` into `localSupaAnon` |
76 changes: 76 additions & 0 deletions
76
src/content/docs/docs/self-hosted/local-dev/getting-started.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
title: "Getting started" | ||
sidebar: | ||
order: 3 | ||
--- | ||
|
||
## What this tutorial will cover? | ||
|
||
This tutorial will show how to start the supabase from scratch as well as start edge functions | ||
|
||
## Requirements | ||
1. Cloned [capgo](https://github.com/Cap-go/capgo) | ||
3. [supabase](https://supabase.com/) | ||
|
||
## Getting started | ||
|
||
To get started run | ||
```bash | ||
supabase start | ||
``` | ||
|
||
Next should see something like this: | ||
```js | ||
Started supabase local development setup. | ||
|
||
API URL: http://localhost:54321 | ||
GraphQL URL: http://localhost:54321/graphql/v1 | ||
DB URL: postgresql://postgres:postgres@localhost:54322/postgres | ||
Studio URL: http://localhost:54323 | ||
Inbucket URL: http://localhost:54324 | ||
JWT secret: [truncated] | ||
anon key: supa_key_anon | ||
service_role key: supa_key_admin | ||
``` | ||
|
||
Next open `configs.json` and set the following values: | ||
```json | ||
{ | ||
"base_domain": { | ||
"prod": "web.capgo.app", | ||
"development": "development.web.capgo.app", | ||
"local": "localhost:3332" | ||
}, | ||
"supa_anon": { | ||
"prod": "supa_key_anon", | ||
"development": "supa_key_anon", | ||
"local": "supa_key_anon" | ||
}, | ||
"supa_url": { | ||
"prod": "http://localhost:54321", | ||
"development": "http://localhost:54321", | ||
"local": "http://localhost:54321" | ||
} | ||
} | ||
``` | ||
|
||
where `supa_key_anon` is the value from the previous step. | ||
|
||
:::danger | ||
⚠️ Do not commit `configs.json` into the remote repo | ||
::: | ||
|
||
Next, verify that you can go to [localhost:54323](http://localhost:54323/projects) and that the table `users` looks something like this | ||
|
||
<figure><img src="/supabase.png" alt="" /><figcaption></figcaption></figure> | ||
|
||
If it does start edge functions by running: | ||
|
||
```bash | ||
supabase functions serve | ||
``` | ||
|
||
and start fronend by running: | ||
```bash | ||
pnpm serve | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
--- | ||
title: "Self-hosting S3" | ||
sidebar: | ||
order: 2 | ||
--- | ||
|
||
## What this tutorial will cover? | ||
|
||
This tutorial will show how to set up [minio](https://min.io/) to work with capgo. | ||
|
||
This is not technically required to run capgo. | ||
|
||
Setting S3 allows for uploading bundles from the [CLI](/docs/tooling/cli/). | ||
|
||
:::danger | ||
⚠️ This tutorial is not supposed to be used in production.\ | ||
Use this only in local development. | ||
::: | ||
|
||
## Requirements | ||
|
||
1. [Docker](https://www.docker.com/) | ||
|
||
## Getting started | ||
|
||
First, create a new directory. | ||
|
||
Then create a folder named `data` inside. | ||
|
||
Then run the following command: | ||
```bash | ||
docker run \ | ||
-p 9000:9000 \ | ||
-p 9090:9090 \ | ||
--user $(id -u):$(id -g) \ | ||
--name minio1 \ | ||
-e "MINIO_ROOT_USER=ROOTUSER" \ | ||
-e "MINIO_ROOT_PASSWORD=CHANGEME123" \ | ||
-v PATH_TO_DATA_FOLDER_CREATED_IN_PREVIOUS_STEP:/data \ | ||
quay.io/minio/minio server /data --console-address ":9090" | ||
``` | ||
|
||
If you ever close the console window with this container you can start it with: | ||
```bash | ||
docker start minio1 | ||
``` | ||
|
||
If you ever need to change the configuration of minio you can remove the container by running: | ||
```bash | ||
docker rm minio1 | ||
``` | ||
⚠️ This command does not remove minio data | ||
|
||
## Setting up edge functions | ||
|
||
Now that we have a S3 server running we need to set up capgo edge functions to use our S3 server. | ||
|
||
To do that we need to create an ENV file in `capgo/supabase` named `.env.local` | ||
|
||
This file should look like this: | ||
```bash | ||
STRIPE_WEBHOOK_SECRET=test | ||
STRIPE_SECRET_KEY=test | ||
API_SECRET=testsecret | ||
PLAN_MAKER=test | ||
PLAN_SOLO=test | ||
PLAN_TEAM=test | ||
# Below is the accually important setup for S3 | ||
S3_ENDPOINT=172.17.0.1 | ||
S3_REGION=dev-region | ||
S3_PORT=9000 | ||
S3_SSL=false | ||
R2_ACCESS_KEY_ID=ROOTUSER | ||
R2_SECRET_ACCESS_KEY=CHANGEME123 | ||
``` | ||
|
||
The ip `172.17.0.1` is a docker ip that can be both reached by our local machine and the docker edge functions container | ||
|
||
To run edge functions with our new env file use | ||
```bash | ||
supabase functions serve --env-file ./supabase/.env.local | ||
``` | ||
|
||
## Setting up CLI to use S3 | ||
|
||
The CLI will not work by default with minio. The following change to `capacitor.config.ts`[^1] is required. | ||
```ts | ||
const config: CapacitorConfig = { | ||
appId: 'com.demo.app', | ||
appName: 'demoApp', | ||
webDir: 'dist', | ||
bundledWebRuntime: false, | ||
plugins: { | ||
CapacitorUpdater : { | ||
// Without this localS3 the upload command will fail | ||
localS3: true | ||
}, | ||
}, | ||
}; | ||
``` | ||
|
||
[^1]: File is located in your app directory |