diff --git a/deploy/getting_started.md b/deploy/getting_started.md index 633a69a80..1aa9d92be 100644 --- a/deploy/getting_started.md +++ b/deploy/getting_started.md @@ -35,6 +35,14 @@ An application is a single deployed web service with one build configuration, build history, environment variables, attached custom domains, a linked GitHub repository, etc. +:::info + +You can also create and configure apps from the command line with +`deno deploy create`. See the +[Apps reference](/deploy/reference/apps/#using-the-cli) for details. + +::: + ## Select a repo 1. Choose the GitHub repository for your application: diff --git a/deploy/reference/apps.md b/deploy/reference/apps.md index 8155293aa..0bd7335c4 100644 --- a/deploy/reference/apps.md +++ b/deploy/reference/apps.md @@ -12,17 +12,20 @@ organization and is used in default domain names. ## Creating an application -To create an application: +Applications can be created from the +[Deno Deploy dashboard](https://dash.deno.com) or from the command line using +the [`deno deploy` CLI](/runtime/reference/cli/deploy/). -1. Click the "+ Create App" button on the organization page +### Using the dashboard + +To create an application from the web dashboard: + +1. Click the "+ New App" button on the Application overview page 2. Select the GitHub repository to deploy from 3. Configure the app slug (name) 4. Set up build configuration 5. Add any required environment variables -> ⚠️ Currently, applications must be linked to a GitHub repository during -> creation. - The build configuration determines how the application is built during the deployment process. Builds are automatically triggered on each push to the linked repository or when manually clicking "Deploy Default Branch". For @@ -34,6 +37,47 @@ Environment Variables". For more details on environment variables, see the [Environment Variables and Contexts](/deploy/reference/env_vars_and_contexts/) documentation. +### Using the CLI + +You can also create applications from the command line with +`deno deploy create`. Running without flags starts an interactive wizard that +walks you through each step: + +```bash +deno deploy create +``` + +For CI/CD pipelines or scripting, provide flags to skip the wizard entirely: + +```bash +deno deploy create \ + --org my-org \ + --app my-api \ + --source local \ + --framework-preset fresh \ + --build-timeout 5 \ + --build-memory-limit 1024 \ + --region us +``` + +You can also create apps that deploy from a GitHub repository: + +```bash +deno deploy create \ + --org my-org \ + --app my-app \ + --source github \ + --owner my-github-org \ + --repo my-repo \ + --framework-preset astro \ + --build-timeout 10 \ + --build-memory-limit 2048 \ + --region global +``` + +For the full list of flags and options, see the +[`deno deploy create` CLI reference](/runtime/reference/cli/deploy/#create-application). + ## Renaming an application Applications can be renamed by editing the app slug on the app settings page. diff --git a/runtime/reference/cli/deploy.md b/runtime/reference/cli/deploy.md index 127a1f23c..7e41513b5 100644 --- a/runtime/reference/cli/deploy.md +++ b/runtime/reference/cli/deploy.md @@ -35,19 +35,160 @@ system's keyring: ### Create application -Creates a new application in Deno Deploy. +Creates a new application in Deno Deploy. When run without flags, an interactive +wizard walks you through each step. When any configuration flag is provided, the +command runs in non-interactive mode (useful for CI/CD pipelines and scripting). ```bash deno deploy create [root-path] ``` -**Options:** +The optional `[root-path]` argument sets the local project directory. Defaults +to the current working directory. + +#### General options - `-h, --help` - Show help information -- `--org ` - The name of the organization to create the application for +- `--org ` - The organization to create the app in +- `--app ` - The application name (used in the default URL) +- `--allow-node-modules` - Include `node_modules` when uploading +- `--no-wait` - Skip waiting for the first build to complete +- `--dry-run` - Validate flags and run through the flow without actually + creating anything + +#### Source options + +These flags control where the app code comes from: + +- `--source ` - Deploy from a GitHub repo or the local filesystem +- `--owner ` - GitHub owner/organization (required when source is + `github`) +- `--repo ` - GitHub repository name (required when source is `github`) + +#### Build configuration options + +- `--app-directory ` - Path to the app directory within the project +- `--framework-preset ` - Use a framework preset for build defaults. + Supported values: `astro`, `nextjs`, `nuxt`, `remix`, `solidstart`, + `sveltekit`, `fresh`, `lume`, or `""` (none) +- `--do-not-use-detected-build-config` - Skip auto-detected build settings and + use only the provided flags +- `--install-command ` - Install command (e.g. `"deno install"`) +- `--build-command ` - Build command (e.g. `"deno task build"`) +- `--pre-deploy-command ` - Command to run after building but before + deploying + +#### Runtime mode options + +- `--runtime-mode ` - Whether the app runs as a server or a + static site + +**Dynamic mode** (server): + +- `--entrypoint ` - The entrypoint file (e.g. `main.ts`) +- `--arguments ` - Arguments passed to the entrypoint (can be specified + multiple times) +- `--working-directory ` - Working directory for the process + +**Static mode** (static site): + +- `--static-dir ` - Directory containing the static files to serve +- `--single-page-app` - Serve `index.html` for routes that don't match a file + (instead of returning 404) + +#### Build resource options + +- `--build-timeout ` - Build timeout. Allowed values: `5`, `10`, `15`, + `20`, `25`, `30` +- `--build-memory-limit ` - Build memory limit in MB. Allowed values: + `1024`, `2048`, `3072`, `4096` +- `--region ` - Deployment region. Allowed values: `us`, `eu`, `global` + +#### Interactive wizard + +When you run `deno deploy create` without flags, an interactive wizard guides +you through each configuration step: + +1. **Organization** - Select which org to create the app in +2. **App name** - Choose a name for your app +3. **Source** - Deploy from GitHub or a local directory +4. **GitHub repo** _(if source is GitHub)_ - Select the owner and repo +5. **App directory** - Pick the directory within your project (auto-detects + workspace members) +6. **Build configuration** - Auto-detects framework settings. You can accept the + detected config or configure manually (framework preset, install/build + commands, runtime mode, etc.) +7. **Build timeout** - How long the build can run +8. **Build memory limit** - How much memory the build gets +9. **Region** - Where to deploy (`us`, `eu`, or `global`) +10. **Confirm** - Review and confirm before creating + +#### Examples + +Create an app interactively: ```bash -deno deploy create --org my-organization +deno deploy create +``` + +Create a local dynamic app with all flags (non-interactive): + +```bash +deno deploy create \ + --org my-org \ + --app my-api \ + --source local \ + --runtime-mode dynamic \ + --entrypoint main.ts \ + --install-command "deno install" \ + --build-command "deno task build" \ + --build-timeout 5 \ + --build-memory-limit 1024 \ + --region us +``` + +Create a static site: + +```bash +deno deploy create \ + --org my-org \ + --app my-site \ + --source local \ + --runtime-mode static \ + --static-dir dist \ + --single-page-app \ + --build-command "deno task build" \ + --build-timeout 10 \ + --build-memory-limit 2048 \ + --region us +``` + +Use a framework preset (fewer flags needed since the preset provides defaults): + +```bash +deno deploy create \ + --org my-org \ + --app my-fresh-app \ + --source local \ + --framework-preset fresh \ + --build-timeout 5 \ + --build-memory-limit 1024 \ + --region us +``` + +Deploy from a GitHub repo: + +```bash +deno deploy create \ + --org my-org \ + --app my-app \ + --source github \ + --owner my-github-org \ + --repo my-repo \ + --framework-preset astro \ + --build-timeout 10 \ + --build-memory-limit 2048 \ + --region global ``` ### Environment variables management @@ -80,8 +221,16 @@ deno deploy env add Adds an environment variable to the application. +**Options:** + +- `--secret` - Mark the variable as a secret. Secret values are hidden in the + dashboard and in `env list` output. + ```bash deno deploy env add DATABASE_URL "postgresql://user:pass@localhost/db" + +# Add a secret environment variable +deno deploy env add API_KEY "sk-secret-value" --secret ``` #### Update environment variable value @@ -125,10 +274,188 @@ deno deploy env delete OLD_API_KEY deno deploy env load ``` -Loads environment variables from a `.env` file into the application. +Loads environment variables from a `.env` file into the application. The CLI +automatically detects which variables are likely secrets based on their names +(e.g. keys containing `SECRET`, `TOKEN`, `PASSWORD`, etc.) and marks them +accordingly. + +**Options:** + +- `--non-secrets ` - Keys from the `.env` file that should be treated + as non-secrets, overriding the auto-detection ```bash deno deploy env load .env.production + +# Load and treat specific keys as non-secrets +deno deploy env load .env.production --non-secrets PUBLIC_URL SITE_NAME +``` + +### Database management + +Manage database instances for your organization. + +```bash +deno deploy database +``` + +**Options:** + +- `-h, --help` - Show help information +- `--org ` - The name of the organization + +#### Provision a database + +```bash +deno deploy database provision --kind [--region ] +``` + +Creates a new database instance. + +**Options:** + +- `--kind ` - The type of database to provision (required) +- `--region ` - The primary region for the database (required for + Prisma) + +```bash +# Provision a Deno KV database +deno deploy database provision my-kv-db --kind denokv + +# Provision a Prisma Postgres database +deno deploy database provision my-pg-db --kind prisma --region us-east-1 +``` + +#### Link an external database + +```bash +deno deploy database link [connectionString] +``` + +Links an external PostgreSQL database to your organization. You can provide a +connection string or use individual flags. + +**Options:** + +- `--hostname ` - Database hostname (conflicts with connection string) +- `--username ` - Database username (conflicts with connection string) +- `--password ` - Database password (conflicts with connection string) +- `--port ` - Database port (conflicts with connection string) +- `--cert ` - SSL certificate for the connection +- `--dry-run` - Test the connection without actually linking + +```bash +# Link using a connection string +deno deploy database link my-db "postgres://user:pass@host:5432/mydb" + +# Link using individual flags +deno deploy database link my-db \ + --hostname db.example.com \ + --username admin \ + --password secret \ + --port 5432 + +# Test the connection first +deno deploy database link my-db "postgres://user:pass@host:5432/mydb" --dry-run +``` + +#### Assign a database to an app + +```bash +deno deploy database assign [--app ] +``` + +Assigns a database instance to an application. If `--app` is not provided, you +will be prompted to select one interactively. + +```bash +deno deploy database assign my-db --app my-api +``` + +#### Detach a database from an app + +```bash +deno deploy database detach [--app ] +``` + +Removes the connection between a database instance and an application. + +```bash +deno deploy database detach my-db --app my-api +``` + +#### Query a database + +```bash +deno deploy database query [query...] +``` + +Executes a SQL query against a database. + +```bash +deno deploy database query my-db mydb "SELECT * FROM users LIMIT 10" +``` + +#### List databases + +```bash +deno deploy database list [search] +``` + +Lists all database instances in the organization. Also available as +`database ls`. + +```bash +# List all databases +deno deploy database list + +# Filter by name +deno deploy database list my-db +``` + +#### Delete a database + +```bash +deno deploy database delete +``` + +Permanently deletes a database instance. Also available as `database remove` or +`database rm`. + +```bash +deno deploy database delete my-old-db +``` + +### Switch organization and application + +Sets the default organization and application for subsequent commands, so you +don't have to pass `--org` and `--app` every time. + +```bash +deno deploy switch [--org ] [--app ] +``` + +When run without flags, an interactive prompt lets you select the org and app. + +**Options:** + +- `--org ` - The organization to switch to +- `--app ` - The application to switch to + +```bash +# Switch interactively +deno deploy switch + +# Switch to a specific org and app +deno deploy switch --org my-company --app my-api +``` + +### Logout + +Removes the stored authentication token. + +```bash +deno deploy logout ``` ### Application logs @@ -246,15 +573,58 @@ deno deploy --prod deno deploy --org my-company --app my-api --prod ``` -### Environment setup +### Creating applications + +```bash +# Start the interactive creation wizard +deno deploy create + +# Create with a framework preset +deno deploy create --org my-company --app my-site \ + --source local --framework-preset fresh \ + --build-timeout 5 --build-memory-limit 1024 --region us + +# Create a static site from a GitHub repo +deno deploy create --org my-company --app my-docs \ + --source github --owner my-github-org --repo my-docs-repo \ + --runtime-mode static --static-dir dist --single-page-app \ + --build-command "npm run build" \ + --build-timeout 10 --build-memory-limit 2048 --region global +``` + +### Switching context ```bash -# Create a new application -deno deploy create --org my-company +# Set a default org and app so you don't have to pass --org/--app every time +deno deploy switch --org my-company --app my-api + +# Now these commands use the saved org and app automatically +deno deploy env list +deno deploy logs +``` + +### Database management +```bash +# Provision a Deno KV database +deno deploy database provision my-kv --kind denokv --org my-company + +# Link an external PostgreSQL database +deno deploy database link my-pg "postgres://user:pass@host:5432/db" --org my-company + +# Assign a database to an app +deno deploy database assign my-kv --app my-api + +# Query a database +deno deploy database query my-pg mydb "SELECT count(*) FROM users" +``` + +### Environment setup + +```bash # Set up environment variables -deno deploy env add DATABASE_URL "postgresql://..." -deno deploy env add API_KEY "your-api-key" +deno deploy env add DATABASE_URL "postgresql://..." --secret +deno deploy env add SITE_NAME "My App" # Load from .env file deno deploy env load .env.production