ente/web/docs/deploy.md

66 lines
2.3 KiB
Markdown
Raw Normal View History

2024-02-20 05:52:22 +00:00
# Deploying the web apps
2024-03-06 06:14:09 +00:00
## tl;dr;
2024-02-20 05:52:22 +00:00
2024-03-06 06:14:09 +00:00
```sh
yarn deploy:photos
```
2024-02-20 05:52:22 +00:00
2024-03-06 06:14:09 +00:00
## Details
2024-02-20 05:52:22 +00:00
2024-03-06 06:14:09 +00:00
The various web apps (Ente Photos, Ente Auth) are deployed on Cloudflare Pages.
2024-02-20 05:52:22 +00:00
2024-03-06 06:14:09 +00:00
The deployment is done using the GitHub app provided by Cloudflare Pages. The
Cloudflare integration watches for pushes to all branches named "deploy/*". In
all cases, it runs the same script, `scripts/deploy.sh`, using the
`CF_PAGES_BRANCH` environment variable to decide what exactly to build ([CF
2024-02-20 05:52:22 +00:00
docs](https://developers.cloudflare.com/pages/how-to/build-commands-branches/)).
2024-03-06 06:14:09 +00:00
For each of these branches, we have configured CNAME aliases (Cloudflare calls
them Custom Domains) to give a stable URL to the deployments.
2024-02-20 05:52:22 +00:00
2024-03-06 06:14:09 +00:00
- `deploy/photos`_web.ente.io_
- `deploy/auth`_auth.ente.io_
- `deploy/accounts`_accounts.ente.io_
- `deploy/cast`_cast.ente.io_
2024-02-20 05:52:22 +00:00
Thus to trigger a, say, production deployment of the photos app, we can open and
2024-03-06 06:14:09 +00:00
merge a PR into the `deploy/photos` branch. Cloudflare will then build and
2024-02-20 05:52:22 +00:00
deploy the code to _web.ente.io_.
2024-03-06 06:14:09 +00:00
The command `yarn deploy:photos` just does that - it'll open a new PR to fast
forward the current main onto `deploy/photos`. There are similar `yarn deploy:*`
commands for the other apps.
## Other subdomains
2024-02-24 11:31:07 +00:00
Apart from this, there are also some subdomains:
- `albums.ente.io` is a CNAME alias to the production deployment
(`web.ente.io`). However, when the code detects that it is being served from
`albums.ente.io`, it redirects to the `/shared-albums` page (Enhancement:
serve it as a separate app with a smaller bundle size).
- `payments.ente.io` and `family.ente.io` are currently in a separate
repositories (Enhancement: bring them in here).
2024-03-06 06:14:09 +00:00
## NODE_VERSION
In Cloudflare Pages setting the `NODE_VERSION` environment variables is defined.
2024-02-24 11:31:07 +00:00
2024-03-06 06:14:09 +00:00
This determines which version of Node is used when we do `yarn build:foo`.
Currently this is set to `20.11.1`. The major version here should match that of
`@types/node` in our dev dependencies.
2024-02-24 11:31:07 +00:00
2024-03-06 06:14:09 +00:00
It is a good idea to also use the same major version of node on your machine.
For example, for macOS you can install the the latest from the v20 series using
`brew install node@20`.
2024-02-24 11:31:07 +00:00
2024-02-20 05:52:22 +00:00
## Adding a new app
2024-02-20 05:56:11 +00:00
1. Add a mapping in `scripts/deploy.sh`.
2024-02-20 05:52:22 +00:00
2. Add a [Custom Domain in
Cloudflare](https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/)
pointing to this branch's deployment.