Skip to content

Commit 056eb71

Browse files
[Docs] Featute DSTACK_PROJECT in dstack project reference page and Protips
1 parent f31aa26 commit 056eb71

2 files changed

Lines changed: 49 additions & 2 deletions

File tree

docs/docs/guides/protips.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@ replace it with a corresponding command to start Docker daemon.
197197

198198
See more Docker examples [here](https://github.com/dstackai/dstack/tree/master/examples/misc/docker-compose).
199199

200+
## Projects
201+
202+
If you're using multiple `dstack` projects (e.g., from different `dstack` servers),
203+
you can switch between them using the [`dstack project`](../reference/cli/dstack/project.md) command.
204+
205+
Alternatively, you can install [`direnv` :material-arrow-top-right-thin:{ .external }](https://direnv.net/){:target="_blank"}
206+
to automatically apply environment variables from the `.envrc` file in your project directory.
207+
208+
<div editor-title=".envrc">
209+
210+
```shell
211+
export DSTACK_PROJECT=main
212+
```
213+
214+
</div>
215+
216+
Now, `dstack` will always use this project within this directory.
217+
218+
Remember to add `.envrc` to `.gitignore` to avoid committing it to the repo.
219+
200220
## Environment variables
201221

202222
If a configuration requires an environment variable that you don't want to hardcode in the YAML, you can define it
@@ -250,9 +270,9 @@ $ dstack apply -e HF_TOKEN=... -f .dstack.yml
250270
</div>
251271

252272
If you install [`direnv` :material-arrow-top-right-thin:{ .external }](https://direnv.net/){:target="_blank"},
253-
it will automatically pass the environment variables from the `.env` file to the `dstack apply` command.
273+
it will automatically apply the environment variables from the `.envrc` file to the `dstack apply` command.
254274

255-
Remember to add `.env` to `.gitignore` to avoid pushing it to the repo.
275+
Remember to add `.envrc` to `.gitignore` to avoid committing it to the repo.
256276

257277
[//]: # (## Profiles)
258278
[//]: # ()

docs/docs/reference/cli/dstack/project.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ Before the CLI can be used, it must be configured with a [project](../../../conc
66
77
The `dstack project set-default` command can be used to switch between multiple projects.
88

9+
??? info "Environment variable"
10+
Alternatively to `dstack project set-default`, you can set the `DSTACK_PROJECT` environment variable. It overrides the default project set in `~/.dstack/config.yml`.
11+
12+
<div class="termy">
13+
14+
```shell
15+
$ DSTACK_PROJECT=main
16+
$ dstack apply -f examples/.dstack.yml
17+
```
18+
19+
</div>
20+
21+
Also, you can install [`direnv` :material-arrow-top-right-thin:{ .external }](https://direnv.net/){:target="_blank"}
22+
to automatically apply environment variables from the `.envrc` file in your project directory.
23+
24+
<div editor-title=".envrc">
25+
26+
```shell
27+
export DSTACK_PROJECT=main
28+
```
29+
30+
</div>
31+
32+
Now, `dstack` will always use this project within this directory.
33+
34+
Remember to add `.envrc` to `.gitignore` to avoid committing it to the repo.
35+
936
## dstack project add
1037

1138
This command adds a new project configuration.

0 commit comments

Comments
 (0)