# Deploy with the CLI

> `forkrail` uploads a folder, builds it in your own AWS account, and prints a URL. Add `--prod` to ship it to production.

- Category: Deploy
- URL: https://www.forkrail.com/docs/deploy

## Deploy a folder

**Preview, production, and options**

```bash
# A preview of the current folder
forkrail

# Production
forkrail --prod

# Another folder, under a name you choose
forkrail ~/code/my-api --project my-api

# This deployment only: 1,024 MB of memory
forkrail --memory 1024
```

As with `vercel`, no command means deploy: `forkrail` is short for `forkrail deploy`, and both take the same options. A command’s name is the command, so a folder named like one is written as a path: `forkrail ./build`. Your home folder and the disk’s root are refused, since every file in them would be uploaded.

The first deploy of a name creates the project. Each deploy prints the deployment’s own URL, `https://<project>-<id>.<your domain>`, and a production deploy also moves `https://<project>.<your domain>` and the project’s custom domains to it.

The deployment shows up in the dashboard as soon as the deploy starts, with its build log live. It ends **Ready**, **Error** (with the step that failed and why) or **Canceled**.

## Where builds run

Every deploy builds in your install’s **builder**, a Lambda function in your AWS account, the way Vercel builds on its machines rather than yours. The terminal uploads the source and shows the log as it’s written. Closing the terminal doesn’t stop the build.

- **The build runs where the app runs:** Amazon Linux 2023 on arm64, with the Python and Node versions your project asks for, plus Go and Rust. Native packages install for the right platform.
- **What’s uploaded** is what a git checkout would have: files your `.gitignore` and `.vercelignore` leave out stay behind, and so do dependencies, build output, caches and `.env.local` files. The upload is encrypted under your install’s key. At most 100,000 files and 1 GB.
- **Memory:** builds get 4,096 MB. A build that runs out of memory is retried once on a larger builder with 8,192 MB, and the project’s later builds start there.
- **Time:** a build has 15 minutes, Lambda’s limit. Longer builds can run on your own machine with `--local`.
- **Nothing else is reachable:** the builder reads its source and writes its output through URLs signed for that one build, so your build scripts can’t reach the install’s state, secrets or other projects.

### The build cache

After a successful build, the builder keeps the project’s dependencies (`node_modules`, installed Python requirements, Go and Cargo caches, and Next.js’s `.next/cache`) and restores them on the next build. The install command still runs every time, as on Vercel, and has little left to do. Production builds use production’s cache; previews use the previews’ (or production’s until there is one). A cache is rebuilt from scratch after 30 days.

```bash
# Build without the cache (a new one is written), like vercel --force
forkrail deploy --no-cache
```

## Build logs and canceling

- The log shows each step: preparing, installing dependencies, building, packaging and publishing, with every line your build prints.
- Any environment variable value of 8 characters or more is replaced by `[NAME hidden]` in the dashboard’s copy of the log.
- Logs are kept up to 4 MB each, for as long as the deployment is kept.
- Cancel a build from the deployment’s page or with `forkrail cancel <id>`. It stops within a few seconds and nothing is published. Ctrl-C in the terminal only stops showing the log.

```bash
forkrail inspect <id> --logs   # print a finished build’s log
forkrail cancel <id>           # stop a build
```

## Local, prebuilt and split builds

| Command | What it does |
| --- | --- |
| `forkrail deploy --local` | Builds on your machine instead of the builder. Needs the install’s AWS credentials. |
| `forkrail deploy --prebuilt` | Deploys a `.vercel/output` (or Nitro `.output`, or Next.js standalone) you already built, as it is. |
| `forkrail build DIR --out OUT` | Builds only, into a folder, like `vercel build`. With `--request FILE` it needs no AWS access at all. |
| `forkrail publish OUT` | Publishes a folder `forkrail build` made, like `vercel deploy --prebuilt`. |

## What goes into a deployment

The package is your project folder minus `.git`, `.vercel`, `node_modules`, virtual environments, `__pycache__`, `.DS_Store`, every `.env*` file and whatever `.vercelignore` lists (gitignore syntax, the same file Vercel reads). Use `.vercelignore` to keep test scripts and fixtures out:

```bash
printf 'test.py\nfixtures/\n' >> .vercelignore
```

Each deploy also keeps a copy of the project’s own source for the dashboard’s **Source** view (without dependencies, build output or files whose names suggest secrets, such as `*.pem` and `.npmrc`).

## Project names

- Lowercase letters, digits and dashes. The name becomes the production host: `<project>.<your domain>`.
- `www`, `api`, `app`, `docs`, `dashboard`, `admin`, `status` and `mail` are reserved.
- Names ending in a dash and 8 hex digits, or containing `-git-`, are refused, because they would look like another project’s deployment or branch URL.
- Rename a project with `forkrail project <name> --rename <new>` or under Settings → General. Its URLs, functions and logs keep the first name.

## New projects from the dashboard

**New project** in the dashboard makes a project three ways: import a GitHub repository (see [Deploy from GitHub](https://www.forkrail.com/docs/deploy-from-github)), give it a name only and deploy it from a terminal, or start from a template (FastAPI or a plain Node.js server) that builds and deploys to production at once.
