> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Monorepo and multi-environment deployments

By default, `fly deploy` builds and deploys a `fly.toml` file, a `Dockerfile`, and source code from the current working directory. This is sufficient for deploying a single app, but you can also configure flyctl to build and deploy multiple apps from a monorepo or deploy an app to multiple targets.

## Paths

### Working directory

The first argument to `fly deploy` is the path to the working directory for your app's source code. For Dockerfile and Buildpack builds, this is the [build context](https://docs.docker.com/engine/reference/commandline/build/#usage) sent to the Docker daemon. It defaults to the current working directory.

You can override this by providing a path:

```bash theme={null}
fly deploy ./path/to/app
```

### `fly.toml` path

By default, `fly deploy` will look for a `fly.toml` in the working directory. You can override this using the `--config` option.

```bash theme={null}
fly deploy --config ./path/to/fly.toml
```

### `Dockerfile` path

By default, `fly deploy` will look for a `Dockerfile` in the working directory. You can override this using the `--dockerfile` option.

```bash theme={null}
fly deploy --dockerfile ./path/to/Dockerfile
```

## Multi-stage Build Target

By default, the final stage of a [multi-stage dockerfile](https://docs.docker.com/develop/develop-images/multistage-build) is exported as the deployed image. You can stop at a specific stage by using the `--build-target` option:

```
fly deploy --build-target web
fly deploy --build-target api
fly deploy --build-target worker
```

## Combining options

When you specify a working directory, the `--config` and `--dockerfile` paths are relative to the working directory (build context), not your current directory.

For example, given this structure:

```
repo/
├── flyio/
│   └── my-app.toml
└── my-app/
    └── Dockerfile
```

This won't work, because `./flyio/my-app.toml` doesn't exist inside `./my-app`:

```bash theme={null}
fly deploy ./my-app --config ./flyio/my-app.toml
```

Instead, use a path relative to the working directory:

```bash theme={null}
fly deploy ./my-app --config ../flyio/my-app.toml
```

## Examples

**Use a different fly.toml file per environment**

```
fly deploy --config ./fly.production.toml
fly deploy --config ./fly.staging.toml
```

**Use a different Dockerfile per environment**

```
fly deploy --dockerfile ./Dockerfile.production
fly deploy --dockerfile ./Dockerfile.staging
```

**Deploy a subdirectory**

```bash theme={null}
fly deploy ./apps/api
```

**Share a multi-stage Dockerfile with several Fly Apps**

```bash theme={null}
fly deploy --config fly.api.toml --build-target api
```
