Open mtojek opened 4 months ago
It is still possible to persist the workspace directory in a docker workspace build using envbuilder an envbuilder
. For example the following snippet uses a docker volume to persist the /workspace
directory. A full example is here.
resource "docker_volume" "workspaces" {
name = "coder-${data.coder_workspace.me.id}"
}
resource "docker_container" "workspace" {
count = data.coder_workspace.me.start_count
image = "ghcr.io/coder/envbuilder:latest"
name = "coder-${data.coder_workspace_owner.me.name}-${lower(data.coder_workspace.me.name)}"
hostname = data.coder_workspace.me.name
# Use the docker gateway if the access URL is 127.0.0.1
env = [
"CODER_AGENT_TOKEN=${coder_agent.main.token}",
"CODER_AGENT_URL=${replace(data.coder_workspace.me.access_url, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")}",
"GIT_URL="https://github.com/coder/envbuilder-starter-devcontainer",
"INIT_SCRIPT=${replace(coder_agent.main.init_script, "/localhost|127\\.0\\.0\\.1/", "host.docker.internal")}",
"FALLBACK_IMAGE=codercom/enterprise-base:ubuntu" # This image runs if builds fail
]
host {
host = "host.docker.internal"
ip = "host-gateway"
}
volumes {
container_path = "/workspaces"
volume_name = docker_volume.workspaces.name
read_only = false
}
}
@matifali this relates to the devcontainer specification and not mounting in a volume via Terraform.
See: https://containers.dev/implementors/json_reference/#mounts
Follow-up: https://github.com/coder/envbuilder/pull/219
Currently, Envbuilder does not support volume mounts at all
Scope: TBD