Skip to content

Commit 171714d

Browse files
LineIndentAlek99Alek99
authored
[ENG-5990] fill out config.yaml docs (#1390)
* fill out config.yaml docs * more config * update * uv lock --------- Co-authored-by: Alek99 <[email protected]> Co-authored-by: Alek Petuskey <[email protected]>
1 parent af9f513 commit 171714d

File tree

3 files changed

+212
-15
lines changed

3 files changed

+212
-15
lines changed

docs/hosting/config_file.md

Lines changed: 162 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,180 @@
11
```python exec
22
import reflex as rx
33
from reflex_image_zoom import image_zoom
4-
from pcweb.pages.docs import hosting
4+
from pcweb.pages.docs import hosting
55
from pcweb.pages import docs
66
from pcweb.styles.styles import get_code_style, cell_style
7-
87
```
9-
## Config File
108

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:
1212

1313
```bash
1414
reflex cloud config
1515
```
1616

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
18139

140+
**Development (`cloud-dev.yml`):**
19141
```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'
22152
regions:
23153
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
31168
```
32169

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+

pcweb/flexdown.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,54 @@ def render(self, env) -> rx.Component:
279279
),
280280
)
281281

282+
class DemoOnly(flexdown.blocks.Block):
283+
"""A block that displays only a component demo without showing the code."""
284+
285+
starting_indicator = "```python demo-only"
286+
ending_indicator = "```"
287+
include_indicators = True
288+
theme: str = None
289+
290+
def render(self, env) -> rx.Component:
291+
lines = self.get_lines(env)
292+
code = "\n".join(lines[1:-1])
293+
294+
args = lines[0].removeprefix(self.starting_indicator).split()
295+
296+
exec_mode = env.get("__exec", False)
297+
comp = ""
298+
299+
for arg in args:
300+
if arg.startswith("id="):
301+
comp_id = arg.rsplit("id=")[-1]
302+
break
303+
else:
304+
comp_id = None
305+
306+
if "exec" in args:
307+
env["__xd"].exec(code, env, self.filename)
308+
if not exec_mode:
309+
comp = env[list(env.keys())[-1]]()
310+
elif "graphing" in args:
311+
env["__xd"].exec(code, env, self.filename)
312+
if not exec_mode:
313+
comp = env[list(env.keys())[-1]]()
314+
# Get all the code before the final "def".
315+
parts = code.rpartition("def")
316+
data, code = parts[0], parts[1] + parts[2]
317+
comp = docgraphing(code, comp=comp, data=data)
318+
return comp
319+
elif exec_mode:
320+
return comp
321+
elif "box" in args:
322+
comp = eval(code, env, env)
323+
return rx.box(comp, margin_bottom="1em", id=comp_id)
324+
else:
325+
comp = eval(code, env, env)
326+
327+
# Return only the component without any code display
328+
return rx.box(comp, margin_bottom="1em", id=comp_id)
329+
282330

283331
class DemoBlock(flexdown.blocks.Block):
284332
"""A block that displays a component along with its code."""
@@ -543,6 +591,7 @@ def render(self, env) -> rx.Component:
543591

544592
xd = flexdown.Flexdown(
545593
block_types=[
594+
DemoOnly,
546595
DemoBlock,
547596
AlertBlock,
548597
DefinitionBlock,

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)