Skip to content

Commit df8b20a

Browse files
[Docs] Reflect the 0.20 changes related to working_dir and repo_dir (WIP)
1 parent 26016a5 commit df8b20a

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

docs/docs/concepts/dev-environments.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,11 @@ If you don't assign a value to an environment variable (see `HF_TOKEN` above),
301301

302302
### Working directory
303303

304-
If `working_dir` is not specified, it defaults to `/workflow`.
304+
If `working_dir` is not specified, it defaults to the working directory set in the Docker image. For example, the [default image](#default-image) uses `/dstack/run` as its working directory.
305305

306-
The `working_dir` must be an absolute path. The tilde (`~`) is supported (e.g., `~/my-working-dir`).
306+
If the Docker image does not have a working directory set, `dstack` uses `/` as the `working_dir`.
307307

308-
<!-- TODO: In a future version, the default working directory will be taken from `image`. -->
308+
The `working_dir` must be an absolute path. The tilde (`~`) is supported (e.g., `~/my-working-dir`).
309309

310310
<!-- TODO: Elaborate on `entrypoint` -->
311311

@@ -320,7 +320,7 @@ type: dev-environment
320320
name: vscode
321321
322322
files:
323-
- .:examples # Maps the directory where `.dstack.yml` to `/workflow/examples`
323+
- .:examples # Maps the directory with `.dstack.yml` to `<working dir>/examples`
324324
- ~/.ssh/id_rsa:/root/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
325325

326326
ide: vscode
@@ -329,7 +329,7 @@ ide: vscode
329329
</div>
330330
331331
If the local path is relative, it’s resolved relative to the configuration file.
332-
If the container path is relative, it’s resolved relative to `/workflow`.
332+
If the container path is relative, it’s resolved relative to the [working directory](#working-directory).
333333
334334
The container path is optional. If not specified, it will be automatically calculated:
335335
@@ -340,7 +340,7 @@ type: dev-environment
340340
name: vscode
341341

342342
files:
343-
- ../examples # Maps `examples` (the parent directory of `.dstack.yml`) to `/workflow/examples`
343+
- ../examples # Maps the parent directory of `.dstack.yml` to `<working dir>/../examples`
344344
- ~/.ssh/id_rsa # Maps `~/.ssh/id_rsa` to `/root/.ssh/id_rsa`
345345

346346
ide: vscode
@@ -355,9 +355,9 @@ ide: vscode
355355

356356
### Repos
357357

358-
Sometimes, you may want to mount an entire Git repo inside the container.
358+
Sometimes, you may want to clone an entire Git repo inside the container.
359359

360-
Imagine you have a cloned Git repo containing an `examples` subdirectory with a `.dstack.yml` file:
360+
Imagine you have a Git repo (clonned locally) containing an `examples` subdirectory with a `.dstack.yml` file:
361361

362362
<div editor-title="examples/.dstack.yml">
363363

@@ -366,24 +366,21 @@ type: dev-environment
366366
name: vscode
367367
368368
repos:
369-
# Mounts the parent directory of `examples` (must be a Git repo)
370-
# to `/workflow` (the default working directory)
369+
# Clones the repo from the parent directory (`examples/..`) to `<working dir>`
371370
- ..
372371

373372
ide: vscode
374373
```
375374
376375
</div>
377376
378-
When you run it, `dstack` fetches the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
377+
When you run it, `dstack` clones the repo on the instance, applies your local changes, and mounts it—so the container matches your local repo.
379378

380379
The local path can be either relative to the configuration file or absolute.
381380

382381
??? info "Repo directory"
383-
By default, `dstack` mounts the repo to `/workflow` (the default working directory).
382+
By default, `dstack` clones the repo to the [working directory](#working-directory).
384383

385-
<!-- TODO: In a future version, the default working directory will come from the image, so this should be revisited. -->
386-
387384
You can override the repo directory using either a relative or an absolute path:
388385

389386
<div editor-title="examples/.dstack.yml">
@@ -393,16 +390,30 @@ The local path can be either relative to the configuration file or absolute.
393390
name: vscode
394391
395392
repos:
396-
# Mounts the parent directory of `examples` (must be a Git repo)
397-
# to `/my-repo`
393+
# Clones the repo in the parent directory (`examples/..`) to `/my-repo`
398394
- ..:/my-repo
399395

400396
ide: vscode
401397
```
402398
403399
</div>
404400
405-
If the path is relative, it is resolved against [working directory](#working-directory).
401+
> If the repo directory is relative, it is resolved against [working directory](#working-directory).
402+
403+
If the repo directory is not empty, the run will fail with a runner error.
404+
To override this behavior, you can set `if_exists` to `skip`:
405+
406+
```yaml
407+
type: dev-environment
408+
name: vscode
409+
410+
repos:
411+
- local_path: ..
412+
path: /my-repo
413+
if_exists: skip
414+
415+
ide: vscode
416+
```
406417

407418

408419
??? info "Repo size"
@@ -411,7 +422,7 @@ The local path can be either relative to the configuration file or absolute.
411422
You can increase the 2MB limit by setting the `DSTACK_SERVER_CODE_UPLOAD_LIMIT` environment variable.
412423

413424
??? info "Repo URL"
414-
Sometimes you may want to mount a Git repo without cloning it locally. In this case, simply provide a URL in `repos`:
425+
Sometimes you may want to clone a Git repo within the container without cloning it locally. In this case, simply provide a URL in `repos`:
415426

416427
<div editor-title="examples/.dstack.yml">
417428

@@ -420,7 +431,7 @@ The local path can be either relative to the configuration file or absolute.
420431
name: vscode
421432
422433
repos:
423-
# Clone the specified repo to `/workflow` (the default working directory)
434+
# Clone the repo to `<working dir>`
424435
- https://github.com/dstackai/dstack
425436

426437
ide: vscode
@@ -432,9 +443,9 @@ The local path can be either relative to the configuration file or absolute.
432443
If a Git repo is private, `dstack` will automatically try to use your default Git credentials (from
433444
`~/.ssh/config` or `~/.config/gh/hosts.yml`).
434445

435-
If you want to use custom credentials, you can provide them with [`dstack init`](../reference/cli/dstack/init.md).
446+
> If you want to use custom credentials, ensure to pass them via [`dstack init`](../reference/cli/dstack/init.md) before submitting a run.
436447

437-
> Currently, you can configure up to one repo per run configuration.
448+
Currently, you can configure up to one repo per run configuration.
438449

439450
### Retry policy
440451

0 commit comments

Comments
 (0)