Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 58 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ publish = false
crate-type = ["cdylib"]

[dependencies]
serde = {version = "1.0", features = ["derive"]}
serde_json = "1.0"
zed_extension_api = "0.7.0"
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,34 @@ To support matching filenames other than `Dockerfile` you can add [`file_types`]
```json
{
"file_types": {
"Dockerfile": [ "Dockerfile.*" ]
"Dockerfile": ["Dockerfile.*"]
}
}
```

## Debugging

The extension supports debugging Dockerfile builds with [Buildx](https://github.com/docker/buildx). The minimal required version of Buildx is v0.28.0. To get Buildx, we recommend installing or updating [Docker Desktop](https://docs.docker.com/install/). You may alternatively install Buildx manually by following the instructions [here](https://github.com/docker/buildx?tab=readme-ov-file#manual-download).

You can validate your Buildx installation by running `BUILDX_EXPERIMENTAL=1 docker buildx dap`.

You can create a debug configuration by modifying your project's `.zed/debug.json`.

```json
{
"label": "Docker: Build", // required, configurable
"adapter": "buildx-dockerfile", // required, must not be modified
"request": "launch", // required, must not be modified
"contextPath": "/home/username/worktree", // optional, defaults to ${ZED_WORKTREE_ROOT}
"dockerfile": "/home/username/worktree/Dockerfile", // optional, defaults to ${ZED_WORKTREE_ROOT}/Dockerfile
"target": "test", // optional, should be a build stage in the Dockerfile
"stopOnEntry": true, // if the debugger should suspend on the first line, defaults to false
"args": [
// additional arguments for the build command
"--build-arg",
"NODE_ENV=development"
]
}
```

While a build has been suspended, you can evaluate `exec` to open a shell into the Docker image that has been built up to that point in time.
38 changes: 38 additions & 0 deletions debug_adapter_schemas/buildx-dockerfile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"type": "object",
"required": ["request"],
"properties": {
"dockerfile": {
"type": "string",
"description": "The absolute path to the Dockerfile to debug",
"default": "${ZED_WORKTREE_ROOT}/Dockerfile"
},
"contextPath": {
"type": "string",
"description": "Path to the context of the Docker build",
"default": "${ZED_WORKTREE_ROOT}"
},
"request": {
"type": "string",
"description": "The type of debug session to run, must be launch",
"enum": ["launch"],
"default": "launch"
},
"target": {
"type": "string",
"description": "The build stage target to build"
},
"stopOnEntry": {
"type": "boolean",
"description": "Whether the build should stop in the beginning"
},
"args": {
"type": "array",
"description": "Command line arguments to pass to the build command",
"items": {
"type": "string"
},
"default": []
}
}
}
3 changes: 3 additions & 0 deletions extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ language = "Dockerfile"
[grammars.dockerfile]
repository = "https://github.com/camdencheek/tree-sitter-dockerfile"
commit = "868e44ce378deb68aac902a9db68ff82d2299dd0"

[debug_adapters.buildx-dockerfile]
schema_path = "./debug_adapter_schemas/buildx-dockerfile.json"
Loading