Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev Containers: Support volume mounts of devcontainer spec #220

Open
mtojek opened this issue Jun 5, 2024 · 2 comments
Open

Dev Containers: Support volume mounts of devcontainer spec #220

mtojek opened this issue Jun 5, 2024 · 2 comments

Comments

@mtojek
Copy link
Member

mtojek commented Jun 5, 2024

Follow-up: #219

Currently, Envbuilder does not support volume mounts at all

Scope: TBD

@coder-labeler coder-labeler bot added enhancement spike Investigation to prove feasibility or validate an idea labels Jun 5, 2024
@mtojek mtojek changed the title Support volume mounts Dev Containers: Support volume mounts Jun 5, 2024
@matifali
Copy link
Member

matifali commented Jun 5, 2024

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
  }
}

@mtojek mtojek removed the spike Investigation to prove feasibility or validate an idea label Jun 6, 2024
@johnstcn johnstcn changed the title Dev Containers: Support volume mounts Dev Containers: Support volume mounts of devcontainer spec Jun 10, 2024
@johnstcn
Copy link
Member

@matifali this relates to the devcontainer specification and not mounting in a volume via Terraform.

See: https://containers.dev/implementors/json_reference/#mounts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants