Deploy a Reflex app to a cloud target. Currently the only supported target is GCP Cloud Run via --gcp. The command fetches a Dockerfile and bash deploy script from Reflex, embeds the Dockerfile inside a generated ``cloudbuild.yaml`` (written to a tempfile), rewrites the script's ``g
(
use_gcp: bool,
gcp_project: str | None,
region: str,
service_name: str,
ar_repo: str,
version_tag: str | None,
cpu: str,
memory: str,
min_instances: int,
max_instances: int,
allow_unauthenticated: bool,
service_account: str | None,
envfile: str | None,
envs: tuple[str, ...],
source_dir: str,
token: str | None,
interactive: bool,
dry_run: bool,
loglevel: str,
)
| 231 | help="The log level to use.", |
| 232 | ) |
| 233 | def deploy_command( |
| 234 | use_gcp: bool, |
| 235 | gcp_project: str | None, |
| 236 | region: str, |
| 237 | service_name: str, |
| 238 | ar_repo: str, |
| 239 | version_tag: str | None, |
| 240 | cpu: str, |
| 241 | memory: str, |
| 242 | min_instances: int, |
| 243 | max_instances: int, |
| 244 | allow_unauthenticated: bool, |
| 245 | service_account: str | None, |
| 246 | envfile: str | None, |
| 247 | envs: tuple[str, ...], |
| 248 | source_dir: str, |
| 249 | token: str | None, |
| 250 | interactive: bool, |
| 251 | dry_run: bool, |
| 252 | loglevel: str, |
| 253 | ): |
| 254 | """Deploy a Reflex app to a cloud target. |
| 255 | |
| 256 | Currently the only supported target is GCP Cloud Run via --gcp. The |
| 257 | command fetches a Dockerfile and bash deploy script from Reflex, embeds |
| 258 | the Dockerfile inside a generated ``cloudbuild.yaml`` (written to a |
| 259 | tempfile), rewrites the script's ``gcloud builds submit`` invocation to |
| 260 | reference that config, then runs the script with cwd= your source dir. |
| 261 | Your project tree is never modified. |
| 262 | """ |
| 263 | from reflex_cli.utils import hosting |
| 264 | |
| 265 | console.set_log_level(loglevel) |
| 266 | |
| 267 | if not use_gcp: |
| 268 | console.error( |
| 269 | "Specify a deploy target. Currently supported: --gcp (GCP Cloud Run)." |
| 270 | ) |
| 271 | raise click.exceptions.Exit(2) |
| 272 | if not gcp_project: |
| 273 | console.error("--gcp-project is required when using --gcp.") |
| 274 | raise click.exceptions.Exit(2) |
| 275 | if max_instances < min_instances: |
| 276 | console.error( |
| 277 | f"--max-instances ({max_instances}) must be >= --min-instances ({min_instances})." |
| 278 | ) |
| 279 | raise click.exceptions.Exit(2) |
| 280 | |
| 281 | parsed_envs = _parse_envs(envfile=envfile, envs=envs) |
| 282 | |
| 283 | authenticated_client = hosting.get_authenticated_client( |
| 284 | token=token, interactive=interactive |
| 285 | ) |
| 286 | |
| 287 | bash_path = shutil.which("bash") |
| 288 | if not bash_path: |
| 289 | console.error( |
| 290 | "`bash` was not found on PATH; required to run the deploy script." |
nothing calls this directly
no test coverage detected