From 41d737283dd5f366feb6fd6aadbab95cfa827b43 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 10 Sep 2024 12:57:18 +0100 Subject: [PATCH 1/4] chore(README.md): add instructions for local iteration without a Git repo --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ae8ab99..743a134c 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ docker run -it --rm \ Edit `.devcontainer/Dockerfile` to add `htop`: ```bash -$ vim .devcontainer/Dockerfile +vim .devcontainer/Dockerfile ``` ```diff @@ -53,6 +53,22 @@ Exit the container, and re-run the `docker run` command... after the build compl > If you need to bypass this behavior for any reason, you can bypass this safety check by setting > `ENVBUILDER_FORCE_SAFE=true`. +If you don't have a remote Git repo or you want to quickly iterate with some +local files, simply omit `ENVBUILDER_GIT_URL` and instead mount the directory +containing your code to `/workspaces/empty` inside the Envbuilder container. + +For example: + +```shell +# Create a sample Devcontainer and Dockerfile in the current directory +printf '{"build": { "dockerfile": "Dockerfile"}}' > devcontainer.json +printf 'FROM debian:bookworm\nRUN apt-get update && apt-get install -y cowsay' > Dockerfile + +# Run envbuilder with the current directory mounted into `/workspaces/empty`. +# The instructions to add /usr/games to $PATH have been omitted for brevity. +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='/usr/games/cowsay "happy hacking"' -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest +``` + ## Usage with Coder Coder provides sample From fb0b47dbe09072d5c6871aeb2d9596f52fd307b5 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 10 Sep 2024 13:03:51 +0100 Subject: [PATCH 2/4] add note regarding ENVBUILDER_DEVCONTAINER_DIR --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 743a134c..1a83ec47 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,16 @@ printf 'FROM debian:bookworm\nRUN apt-get update && apt-get install -y cowsay' > docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='/usr/games/cowsay "happy hacking"' -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest ``` +If your `devcontainer.json` is not present in the root of the workspace folder, +you may need to specify the relative path to the file with +`ENVBUILDER_DEVCONTAINER_DIR`: + +```shell +ls build/ +Dockerfile devcontainer.json +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='echo $PATH' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/workspaces/empty envbuilder:latest +``` + ## Usage with Coder Coder provides sample From dcfe5635a4d5353758e88df04cdd0743fabe89ec Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 10 Sep 2024 13:04:27 +0100 Subject: [PATCH 3/4] fixup! add note regarding ENVBUILDER_DEVCONTAINER_DIR --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a83ec47..49b531ef 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ you may need to specify the relative path to the file with ```shell ls build/ Dockerfile devcontainer.json -docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='echo $PATH' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/workspaces/empty envbuilder:latest +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='echo $PATH' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest ``` ## Usage with Coder From c494224cbdd3427a5fa27a275bc07b2838f5b82a Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 10 Sep 2024 13:47:31 +0100 Subject: [PATCH 4/4] mention ENVBUILDER_WORKSPACE_FOLDER --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 49b531ef..28bfe098 100644 --- a/README.md +++ b/README.md @@ -66,17 +66,24 @@ printf 'FROM debian:bookworm\nRUN apt-get update && apt-get install -y cowsay' > # Run envbuilder with the current directory mounted into `/workspaces/empty`. # The instructions to add /usr/games to $PATH have been omitted for brevity. -docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='/usr/games/cowsay "happy hacking"' -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash' -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest ``` -If your `devcontainer.json` is not present in the root of the workspace folder, -you may need to specify the relative path to the file with -`ENVBUILDER_DEVCONTAINER_DIR`: +Alternatively, if you prefer to mount your project files elsewhere, tell +Envbuilder where to find them by specifying `ENVBUILDER_WORKSPACE_FOLDER`: + +```shell +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash ' -e ENVBUILDER_WORKSPACE_FOLDER=/src -v $PWD:/src ghcr.io/coder/envbuilder:latest +``` + +By default, Envbuilder will look for a `devcontainer.json` or `Dockerfile` in +both `${ENVBUILDER_WORKSPACE_FOLDER}` and `${ENVBUILDER_WORKSPACE_FOLDER}/.devcontainer`. +You can control where it looks with `ENVBUILDER_DEVCONTAINER_DIR` if needed. ```shell ls build/ Dockerfile devcontainer.json -docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='echo $PATH' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/workspaces/empty ghcr.io/coder/envbuilder:latest +docker run -it --rm -e ENVBUILDER_INIT_SCRIPT='bash' -e ENVBUILDER_DEVCONTAINER_DIR=build -v $PWD:/src ghcr.io/coder/envbuilder:latest ``` ## Usage with Coder