|
1 | 1 | ```python exec |
2 | 2 | import reflex as rx |
3 | 3 | from reflex_image_zoom import image_zoom |
4 | | -from pcweb.pages.docs import hosting |
| 4 | +from pcweb.pages.docs import hosting |
5 | 5 | from pcweb.pages import docs |
6 | 6 | from pcweb.styles.styles import get_code_style, cell_style |
7 | | - |
8 | 7 | ``` |
9 | | -## Config File |
10 | 8 |
|
11 | | -To create a `config.yml` file for your app run the command below: |
| 9 | +## What is reflex cloud config? |
| 10 | + |
| 11 | +The following command: |
12 | 12 |
|
13 | 13 | ```bash |
14 | 14 | reflex cloud config |
15 | 15 | ``` |
16 | 16 |
|
17 | | -This will create a yaml file similar to the one below where you can edit the app configuration: |
| 17 | +generates a `cloud.yml` configuration file used to deploy your Reflex app to the Reflex cloud platform. This file tells Reflex how and where to run your app in the cloud. |
| 18 | + |
| 19 | +## Configuration File Structure |
| 20 | + |
| 21 | +The `cloud.yml` file uses YAML format and supports the following structure. **All fields are optional** and will use sensible defaults if not specified: |
| 22 | + |
| 23 | +```yaml |
| 24 | +# Basic deployment settings |
| 25 | +name: my-app-prod # Optional: defaults to project folder name |
| 26 | +description: 'Production deployment' # Optional: empty by default |
| 27 | +projectname: my-client-project # Optional: defaults to personal project |
| 28 | + |
| 29 | +# Infrastructure settings |
| 30 | +regions: # Optional: defaults to sjc: 1 |
| 31 | + sjc: 1 # San Jose (# of machines) |
| 32 | + lhr: 2 # London (# of machines) |
| 33 | +vmtype: c2m2 # Optional: defaults to c1m1 |
| 34 | + |
| 35 | +# Custom domain and environment |
| 36 | +hostname: myapp # Optional: myapp.reflex.dev |
| 37 | +envfile: .env.production # Optional: defaults to .env |
| 38 | + |
| 39 | +# Additional dependencies |
| 40 | +packages: # Optional: empty by default |
| 41 | + - procps |
| 42 | +``` |
| 43 | +
|
| 44 | +## Configuration Options Reference |
| 45 | +
|
| 46 | +```python demo-only |
| 47 | +rx.table.root( |
| 48 | + rx.table.header( |
| 49 | + rx.table.row( |
| 50 | + rx.table.column_header_cell(rx.text("Option", size="1", weight="bold", color=rx.color("slate", 11))), |
| 51 | + rx.table.column_header_cell(rx.text("Type", size="1", weight="bold", color=rx.color("slate", 11))), |
| 52 | + rx.table.column_header_cell(rx.text("Default", size="1", weight="bold", color=rx.color("slate", 11))), |
| 53 | + rx.table.column_header_cell(rx.text("Description", size="1", weight="bold", color=rx.color("slate", 11))), |
| 54 | + align="center" |
| 55 | + ) |
| 56 | + ), |
| 57 | + rx.table.body(*[ |
| 58 | + rx.table.row( |
| 59 | + rx.table.cell(rx.text(option, class_name="text-sm")), |
| 60 | + rx.table.cell(rx.text(type_, class_name="text-sm")), |
| 61 | + rx.table.cell(rx.text(default, class_name="text-sm")), |
| 62 | + rx.table.cell(rx.link(description, href=link, class_name="text-sm") if link else rx.text(description, size="1", weight="regular")), |
| 63 | + align="center" |
| 64 | + ) for option, type_, default, description, link in [ |
| 65 | + ("name", "string", "folder name", "Deployment identifier in dashboard", None), |
| 66 | + ("description", "string", "empty", "Description of deployment", None), |
| 67 | + ("regions", "object", "sjc: 1", "Region deployment mapping", "/docs/hosting/regions"), |
| 68 | + ("vmtype", "string", "c1m1", "Virtual machine specifications", "/docs/hosting/machine-types"), |
| 69 | + ("hostname", "string", "null", "Custom subdomain", None), |
| 70 | + ("envfile", "string", ".env", "Environment variables file path", "/docs/hosting/secrets-environment-vars"), |
| 71 | + ("project", "uuid", "null", "Project uuid", None), |
| 72 | + ("projectname", "string", "null", "Project name", None), |
| 73 | + ("packages", "array", "empty", "Additional system packages", None), |
| 74 | + ("include_db", "boolean", "false", "Include local sqlite", None), |
| 75 | + ("strategy", "string", "auto", "Deployment strategy", None) |
| 76 | + ] |
| 77 | + ]), |
| 78 | + variant="ghost", |
| 79 | + size="2", |
| 80 | + width="100%", |
| 81 | + max_width="800px", |
| 82 | +) |
| 83 | +``` |
| 84 | + |
| 85 | +## Configuration Options |
| 86 | + |
| 87 | +For details of specific sections click the links in the table. |
| 88 | + |
| 89 | +### Projects |
| 90 | + |
| 91 | +Organize deployments using projects: |
| 92 | + |
| 93 | +```yaml |
| 94 | +projectname: client-alpha # Groups related deployments |
| 95 | +``` |
| 96 | +
|
| 97 | +You can also specify a project uuid instead of name: |
| 98 | +```yaml |
| 99 | +project: 12345678-1234-1234-1234-1234567890ab |
| 100 | +``` |
| 101 | +
|
| 102 | +You can go to the homepage of the project in the reflex cloud dashboard to find your project uuid in the url `https://cloud.reflex.dev/project/uuid` |
| 103 | + |
| 104 | +### Apt Packages |
| 105 | + |
| 106 | +Install additional system packages your application requires. Package names are based on the apt package manager: |
| 107 | + |
| 108 | +```yaml |
| 109 | +packages: |
| 110 | + - procps=2.0.32-1 # Version pinning is optional |
| 111 | + - imagemagick |
| 112 | + - ffmpeg |
| 113 | +``` |
| 114 | + |
| 115 | +### Include SQLite |
| 116 | + |
| 117 | +Include local sqlite database: |
| 118 | + |
| 119 | +```yaml |
| 120 | +include_db: true |
| 121 | +``` |
| 122 | + |
| 123 | +This is not persistent and will be lost on restart. It is recommended to use a database service instead. |
| 124 | + |
| 125 | +### Strategy |
| 126 | + |
| 127 | +Deployment strategy: |
| 128 | +Available strategies: |
| 129 | +- `immediate`: [Default] Deploy immediately |
| 130 | +- `rolling`: Deploy in a rolling manner |
| 131 | +- `bluegreen`: Deploy in a blue-green manner |
| 132 | +- `canary`: Deploy in a canary manner, boot as single machine verify its health and then restart the rest. |
| 133 | + |
| 134 | +```yaml |
| 135 | +strategy: immediate |
| 136 | +``` |
| 137 | + |
| 138 | +## Multi-Environment Setup |
18 | 139 |
|
| 140 | +**Development (`cloud-dev.yml`):** |
19 | 141 | ```yaml |
20 | | -name: medo |
21 | | -description: '' |
| 142 | +name: myapp-dev |
| 143 | +description: 'Development environment' |
| 144 | +vmtype: c1m1 |
| 145 | +envfile: .env.development |
| 146 | +``` |
| 147 | + |
| 148 | +**Staging (`cloud-staging.yml`):** |
| 149 | +```yaml |
| 150 | +name: myapp-staging |
| 151 | +description: 'Staging environment' |
22 | 152 | regions: |
23 | 153 | sjc: 1 |
24 | | - lhr: 2 |
25 | | -vmtype: c1m1 |
26 | | -hostname: null |
27 | | -envfile: .env |
28 | | -project: null |
29 | | -packages: |
30 | | -- procps |
| 154 | +vmtype: c2m2 |
| 155 | +envfile: .env.staging |
| 156 | +``` |
| 157 | + |
| 158 | +**Production (`cloud-prod.yml`):** |
| 159 | +```yaml |
| 160 | +name: myapp-production |
| 161 | +description: 'Production environment' |
| 162 | +regions: |
| 163 | + sjc: 2 |
| 164 | + lhr: 1 |
| 165 | +vmtype: c4m4 |
| 166 | +hostname: myapp |
| 167 | +envfile: .env.production |
31 | 168 | ``` |
32 | 169 |
|
| 170 | +Deploy with specific configuration files: |
| 171 | + |
| 172 | +```bash |
| 173 | +# Use default cloud.yml |
| 174 | +reflex deploy |
| 175 | +
|
| 176 | +# Use specific configuration file |
| 177 | +reflex deploy --config cloud-prod.yml |
| 178 | +reflex deploy --config cloud-staging.yml |
| 179 | +```error: The lockfile at `uv.lock` needs to be updated, but `--locked` was provided. To update the lockfile, run `uv lock`. |
| 180 | + |
0 commit comments