Skip to content

Commit feec224

Browse files
johnstcnmafredri
authored andcommitted
chore(README.md): add instructions for local iteration without a Git repo (#342)
(cherry picked from commit 9b83cf5)
1 parent d9fcd53 commit feec224

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

+34-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ docker run -it --rm \
3737
Edit `.devcontainer/Dockerfile` to add `htop`:
3838

3939
```bash
40-
$ vim .devcontainer/Dockerfile
40+
vim .devcontainer/Dockerfile
4141
```
4242

4343
```diff
@@ -53,6 +53,39 @@ Exit the container, and re-run the `docker run` command... after the build compl
5353
> If you need to bypass this behavior for any reason, you can bypass this safety check by setting
5454
> `ENVBUILDER_FORCE_SAFE=true`.
5555
56+
If you don't have a remote Git repo or you want to quickly iterate with some
57+
local files, simply omit `ENVBUILDER_GIT_URL` and instead mount the directory
58+
containing your code to `/workspaces/empty` inside the Envbuilder container.
59+
60+
For example:
61+
62+
```shell
63+
# Create a sample Devcontainer and Dockerfile in the current directory
64+
printf '{"build": { "dockerfile": "Dockerfile"}}' > devcontainer.json
65+
printf 'FROM debian:bookworm\nRUN apt-get update && apt-get install -y cowsay' > Dockerfile
66+
67+
# Run envbuilder with the current directory mounted into `/workspaces/empty`.
68+
# The instructions to add /usr/games to $PATH have been omitted for brevity.
69+
docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash' -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest
70+
```
71+
72+
Alternatively, if you prefer to mount your project files elsewhere, tell
73+
Envbuilder where to find them by specifying `ENVBUILDER_WORKSPACE_FOLDER`:
74+
75+
```shell
76+
docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash ' -e ENVBUILDER_WORKSPACE_FOLDER=/src -v $PWD:/src ghcr.io/coder/envbuilder:latest
77+
```
78+
79+
By default, Envbuilder will look for a `devcontainer.json` or `Dockerfile` in
80+
both `${ENVBUILDER_WORKSPACE_FOLDER}` and `${ENVBUILDER_WORKSPACE_FOLDER}/.devcontainer`.
81+
You can control where it looks with `ENVBUILDER_DEVCONTAINER_DIR` if needed.
82+
83+
```shell
84+
ls build/
85+
Dockerfile devcontainer.json
86+
docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/src ghcr.io/coder/envbuilder:latest
87+
```
88+
5689
## Usage with Coder
5790

5891
Coder provides sample

0 commit comments

Comments
 (0)