Compare commits

...

94 Commits

Author SHA1 Message Date
Remy Suen 29879c9c50
Merge pull request #199 from docker/update-release-build-steps
Update the build and documentation around the release process
2025-08-21 09:14:58 -04:00
Remy Suen f8ac9fdddd
Update the build and documentation around the release process
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-21 09:11:03 -04:00
Remy Suen 83879f19b9
Merge pull request #198 from docker/update-language-server-v0.17.0
Update the Docker Language Server to v0.17.0
2025-08-21 08:59:22 -04:00
Remy Suen 3807dd4c7c
Update the Docker Language Server to v0.17.0
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-21 08:54:15 -04:00
Remy Suen dcf0138dc6
Merge pull request #195 from docker/bot/prepare-release-v0.15.0
Prepare for the v0.15.0 release (triggered by rcjsuen)
2025-08-13 12:50:03 -04:00
rcjsuen 3a40496053 Prepare for the v0.15.0 release
This commit was generated by a GitHub Action workflow. It was triggered
by rcjsuen.

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-08-13 16:48:45 +00:00
Remy Suen bc3c31fde7
Merge pull request #194 from docker/automate-release-process
Refactor the GHA workflows to automate part of the release process
2025-08-13 12:41:18 -04:00
Remy Suen a4e868e155
Apply Prettier fixes
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-13 12:29:37 -04:00
Remy Suen 9df84f7b03
Refactor the GHA workflows to automate part of the release process
The current release process includes many manual steps and has a bit of
back and forth and copying and pasting involved. Automating parts of
this process will help make it easier for new people to make a release
and also avoid small errors leading to the release build failing.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-13 12:04:24 -04:00
Remy Suen bd38964ec7
Merge pull request #193 from docker/upload-failure-screenshots
Upload test failure screenshots as artifacts
2025-08-13 09:45:21 -04:00
Remy Suen 45f4d187f9
Upload test failure screenshots as artifacts
If the test fails, we should capture the screenshots and upload them as
artifacts to help with debugging.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-13 09:42:04 -04:00
Remy Suen 4f8ae8fd28
Merge pull request #192 from docker/javascript-format-prettier
Format JavaScript files with Prettier
2025-08-13 09:09:06 -04:00
Remy Suen b26d0fe557
Format JavaScript files with Prettier
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-13 09:04:59 -04:00
Remy Suen 86fcb138e6
Merge pull request #191 from docker/update-language-server-v0.16.0
Update the Docker Language Server to v0.16.0
2025-08-13 08:57:22 -04:00
Remy Suen dbb3458abb
Update the Docker Language Server to v0.16.0
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-13 08:49:05 -04:00
Remy Suen 7af4c38280
Merge pull request #190 from docker/remove-build-workdir
Remove working-directory from the build step
2025-08-12 09:59:35 -04:00
Remy Suen a407622bea
Remove working-directory from the build step
As the build no longer requires checking out the Docker Language
Server's repository either, we should remove the use of the
working-directory attribute to keep the build simple and easy to
understand.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-12 09:56:14 -04:00
Remy Suen 9bd430f7c0
Merge pull request #189 from docker/prettier-format-json
Use Prettier for formatting JSON files
2025-08-10 16:58:18 -04:00
Remy Suen 797a8f926d
Use Prettier for formatting JSON files
Depending on a user's settings, saving the package.json file may cause
the trailing newline character to be removed. Explicitly setting
Prettier as the formatter for JSON files will ensure formatting stays
consistent and pull requests will not be opened with the trailing
newline character removed by mistake.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-10 16:26:13 -04:00
Remy Suen d3e079abc8
Merge pull request #188 from docker/update-vscode-extension-tester
Update vscode-extension-tester to use a newer base VS Code
2025-08-08 08:53:39 -04:00
Remy Suen f2c1806ecc
Update vscode-extension-tester to use a newer base VS Code
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-08 07:45:28 -04:00
Remy Suen 85d0539168
Merge pull request #187 from docker/dockerbake-language-configuration
Add language configuration for dockerbake
2025-08-07 09:37:37 -04:00
Remy Suen 721397fbe5
Add language configuration for dockerbake
Added a language configuration to the extension which will improve the
editing experience by colouring brackets, inserting matching brackets,
and more.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-07 09:30:36 -04:00
Remy Suen 6416e0636f
Merge pull request #186 from docker/prepare-v0.14.0-release
Prepare for the v0.14.0 release
2025-08-06 14:05:13 -04:00
Remy Suen f706ab6c81
Fix the whitespace linting issue
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-06 13:56:53 -04:00
Remy Suen 8798824062
Prepare for the v0.14.0 release
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-06 13:49:49 -04:00
Remy Suen ea0558a0ac
Merge pull request #185 from docker/update-language-server-v0.15.0
Update the Docker Language Server to 0.15.0
2025-08-06 13:37:53 -04:00
Remy Suen 4b9c2bc1d0
Update the Docker Language Server to 0.15.0
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-08-06 13:33:37 -04:00
Remy Suen 11a263a39f
Merge pull request #183 from jsternberg/dap-builder-customize
dap: include additional launch configuration to customize the builder
2025-08-05 06:16:03 -04:00
Jonathan A. Sternberg 561bd5f840
dap: include additional launch configuration to customize the builder
An additional property exists for the DAP launch configuration that
allows setting the `--builder` property for the `buildx` invocation.

This isn't normally possible through `args` because `args` places the
parameters after the invocation of `buildx` while the builder option has
to be before the `buildx` command.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-31 15:20:21 -05:00
Remy Suen 43dac4fd47
Merge pull request #182 from docker/windows-buildx-debugging-fix
Fix working directory path for Buildx debugging
2025-07-30 13:28:42 -04:00
Remy Suen ea92a6881c
Fix working directory path for Buildx debugging
On Windows, there is a leading slash which causes problems. By using
fsPath instead we'll get a regular C:\ path.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-30 13:24:32 -04:00
Remy Suen dc8b84db1b
Merge pull request #180 from docker/state-license-in-readme
State the license used in the readme
2025-07-28 09:36:04 -04:00
Remy Suen 15876b52b2
State the license used in the readme
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-28 09:34:09 -04:00
Remy Suen c4cfe02e4a
Merge pull request #179 from docker/logo-colour-change
Use an alternate logo from the design team
2025-07-25 15:06:24 -04:00
Remy Suen 167393ca86
Use an alternate logo from the design team
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-25 15:02:49 -04:00
Remy Suen fa188d92c4
Merge pull request #178 from docker/language-server-tracing-docs
State where the logs can be found
2025-07-23 16:23:39 -04:00
Remy Suen 2761b8147e
State where the logs can be found
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 16:14:19 -04:00
Remy Suen 9eaaffae76
Merge pull request #177 from docker/language-server-tracing-docs
Add an FAQ entry to explain how to turn on tracing for the language servers
2025-07-23 16:12:51 -04:00
Remy Suen 5188ae6c0c
Add an FAQ entry to explain how to turn on tracing for the language servers
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 16:11:50 -04:00
Remy Suen e0f65c2376
Merge pull request #175 from docker/update-docker-logo
Update logo to the new branding colours
2025-07-23 12:54:52 -04:00
Remy Suen 0c6387ade9
Update logo to the new branding colours
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 12:46:09 -04:00
Remy Suen 95c4a2e3e0
Merge pull request #174 from docker/buildx-dap-documentation
Add documentation about the Buildx debug support
2025-07-23 10:49:06 -04:00
Remy Suen 2e01d11b55
Ignore the Markdown JSONC code block
We do not want Prettier to insert the trailing comma which would make
the JSON invalid.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 10:46:55 -04:00
Remy Suen 7e5f2a45f8
Fix some linting errors
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 10:38:48 -04:00
Remy Suen 759d882c40
Use JSONC so that the comments will be highlighted correctly
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 10:36:42 -04:00
Remy Suen 6118cb6eb2
Add documentation about the Buildx debug support
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-23 10:35:01 -04:00
Remy Suen 275616e6d6
Merge pull request #173 from docker/document-vulnerability-warnings
Document how to disable the vulnerability warnings
2025-07-22 14:43:20 -04:00
Remy Suen 8a7094b572
Fix the linting error
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-22 14:41:25 -04:00
Remy Suen ee0788177a
Document how to disable the vulnerability warnings
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-22 14:37:01 -04:00
Remy Suen 84a3ef00f2
Merge pull request #172 from docker/update-dockerfile-dependencies
Update Dockerfile dependencies
2025-07-22 13:17:42 -04:00
Remy Suen bbfa2dea94
Update dockerfile-ast to 0.7.1
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-22 13:13:26 -04:00
Remy Suen 3e50b9cbd6
Update the Dockerfile Language Server to 0.14.1
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-22 13:01:39 -04:00
dependabot[bot] 0739575d19 Bump form-data from 4.0.2 to 4.0.4
---
updated-dependencies:
- dependency-name: form-data
  dependency-version: 4.0.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-22 10:18:48 +00:00
Remy Suen 94c69474ab
Merge pull request #167 from docker/prepare-v0.13.0-release
Prepare for the v0.13.0 release
2025-07-17 05:44:30 -04:00
Remy Suen ce588474d9
Prepare for the v0.13.0 release
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-17 05:39:35 -04:00
Remy Suen 0bbe953f47
Merge pull request #166 from docker/update-language-server-v0.14.0
Update the language server to v0.14.0
2025-07-16 15:35:30 -04:00
Remy Suen 6d0e077664
Update the language server to v0.14.0
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-16 15:27:27 -04:00
Remy Suen eac9132746
Merge pull request #164 from docker/required-debug-launch-attributes
Make the dockerfile and contextPath attributes required
2025-07-16 15:21:31 -04:00
Remy Suen 03b4c60805
Correct the whitespace issue
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-16 15:17:23 -04:00
Remy Suen eec0881fc1
Remove dockerfile as a required attribute
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-16 15:17:07 -04:00
Remy Suen f50b223a71
Merge pull request #161 from jsternberg/dap-readme-update
dap: update readme for information about debugging
2025-07-16 12:03:45 -04:00
Remy Suen e8602cd013
Make the dockerfile and contextPath attributes required
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-16 10:45:19 -04:00
Remy Suen 3882127f14
Merge pull request #163 from docker/show-language-server-errors
Show errors from the Docker Language Server
2025-07-16 09:38:51 -04:00
Remy Suen 58fb211eaa
Show errors from the Docker Language Server
We do not need to suppress errors from the language server anymore as it
is now pretty stable. Showing the errors will help inform our users and
hopefully lead them to open bugs about any edge cases we have not been
considering.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-16 09:29:59 -04:00
Remy Suen 3642590829
Merge pull request #162 from docker/disable-debug-warning-notification
Prompt the user about the disabled debug setting when launching
2025-07-14 14:20:13 -04:00
Remy Suen aa16d41420
Prompt the user about the disabled debug setting when launching
If the user tries to debug a Dockerfile when the debug setting is
disabled, we still want to be able to warn them that the feature is
disabled and that they can opt-in if desired.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-14 14:16:54 -04:00
Jonathan A. Sternberg 12c5f1378d
dap: update readme for information about debugging
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-11 14:16:08 -05:00
Remy Suen cd0c0f80d0
Merge pull request #160 from jsternberg/dap-stop-on-entry
dap: add stopOnEntry attribute to debugger configuration attributes
2025-07-10 11:34:46 -04:00
Jonathan A. Sternberg f260de99d5
dap: add stopOnEntry attribute to debugger configuration attributes
This adds `stopOnEntry` to the debugger configuration attributes which
will configure whether the debugger stops after the first instruction or
if it continues until the first exception.

This also adds a `contributes.breakpoints` section so vscode will allow
breakpoints to be set.

Some additional activation events have also been added to ensure the
plugin activates even if a dockerfile isn't opened.

The `BUILDX_EXPERIMENTAL` environment variable has been restored because
the pull request planning to remove that hasn't been merged at this
moment so it is still required.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-10 10:31:22 -05:00
Remy Suen 3940e1f16f
Merge pull request #159 from docker/prepare-v0.12.0-release
Prepare for the v0.12.0 release
2025-07-09 13:36:58 -04:00
Remy Suen 167429b3a7
Prepare for the v0.12.0 release
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-09 13:31:18 -04:00
Remy Suen b59e0bb244
Merge pull request #158 from docker/document-required-extensions
Document the required extensions for development
2025-07-09 13:30:01 -04:00
Remy Suen 156b73cd35
Document the required extensions for development
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-09 13:28:51 -04:00
Remy Suen 5373b209e3
Merge pull request #157 from docker/document-experimental-build-debugging
Improve the experimental build debugging feature experience for new users
2025-07-09 13:27:23 -04:00
Remy Suen 9190b7050f
Improve the experimental build debugging feature experience for new users
We should clearly indicate to the user that the feature is under active
development and not intended for general use.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-09 13:23:36 -04:00
Remy Suen ccbb16f8ac
Merge pull request #156 from docker/docker-lsp-v0.13.0-update
Update the Docker Language Server to the 0.13.0 release
2025-07-09 12:58:44 -04:00
Remy Suen afecbb70a5
Update the Docker Language Server to the 0.13.0 release
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-09 12:49:34 -04:00
Remy Suen 74dfa1ebe3
Merge pull request #154 from jsternberg/dap-adapter
debugger: update debugger components
2025-07-07 16:08:30 -04:00
Jonathan A. Sternberg 18a38c7999
debugger: update debugger components
Debugger options have been updated to reflect the current version on
master more closely.

The names have been renamed to `Docker: Build` instead of `Dockerfile
Debug`. The reason for this is to make the naming more consistent and
make it so the bake target could be called `Docker: Bake`.

Initial configurations and configuration snippets now more closely align
with the default attributes most projects should expect.

The vscode extension host debugging now uses `test/workspace` as the
workspace folder and included a default dockerfile that can be used for
testing debugging.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-07-07 13:43:24 -05:00
Remy Suen bb084fb172
Merge pull request #153 from docker/buildx-dap-integration
Add initial buildx DAP integration
2025-07-03 08:52:23 -04:00
Remy Suen 4801c12a0d
Add initial buildx DAP integration
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-03 08:45:30 -04:00
Remy Suen d8f51b4fcd
Merge pull request #152 from docker/improve-compose-setup-steps
Improve Compose setup steps
2025-07-02 09:27:34 -04:00
Remy Suen 362f7ab148
Ignore the misc/ folder
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-02 08:57:21 -04:00
Remy Suen b0b9b63a2b
Update and simplify the FAQ for setting up Compose support
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-02 06:48:59 -04:00
Remy Suen 6a88caada4
Create an empty JSON file that can be publicly accessible
Having a reference empty JSON file that can be publicly and easily
accessible will allow users to more easily follow the steps to disable
Red Hat's YAML extension features for Compose files if they wish.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-07-02 06:09:27 -04:00
Remy Suen bd76d5da33
Merge pull request #150 from docker/prepare-v0.11.0-release
Prepare for the v0.11.0 release
2025-06-23 11:37:49 -04:00
Remy Suen 1ad4c5eed5
Prepare for the v0.11.0 release
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-06-23 11:32:37 -04:00
Remy Suen 853f7fdf00
Merge pull request #149 from docker/divider-line-toggle-setting
Add a setting to toggle the build stage divider lines
2025-06-23 11:25:23 -04:00
Remy Suen d7ec76e87d
Add a setting to toggle the build stage divider lines
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-06-23 11:21:31 -04:00
Remy Suen 6de9f8eb1b
Merge pull request #148 from docker/build-target-divider-lines
Draw divider lines between build targets in a Dockerfile
2025-06-18 16:13:16 -04:00
Remy Suen 578633f12f
Draw divider lines between build targets in a Dockerfile
Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-06-18 16:07:05 -04:00
Remy Suen e81023eaa7
Merge pull request #146 from docker/bundle-dockerfile-language-server
Include the Dockerfile Language Server in the extension
2025-06-17 10:32:10 -04:00
Remy Suen 7611383486
Include the Dockerfile Language Server in the extension
There are two language servers for Dockerfiles. There is the Dockerfile
Language Server written in TypeScript and the Docker Language Server
written in Go (which also supports Compose files and Bake files). The
Dockerfile Language Server provides features that the Docker Language
Server does not provide so bundling it in the extension will improve the
overall editing experience of Dockerfiles.

If Microsoft's Docker extension or the Container Tools extension is
installed, the Dockerfile Language Server will not be started. This is
because Microsoft's extensions already include the Dockerfile Language
Server. If we also started the Dockerfile Language Server on our side
then users may get duplicated information which we want to avoid.

Signed-off-by: Remy Suen <remy.suen@docker.com>
2025-06-17 10:13:55 -04:00
36 changed files with 2614 additions and 302 deletions

View File

@ -1,16 +1,22 @@
name: Build
run-name: "Build: ${{ github.event_name != 'workflow_dispatch' && 'Automatic' || 'Release' }}"
on:
push:
branches:
- "**"
- '**'
tags:
- v*
paths-ignore:
- '**/*.md'
pull_request:
branches:
- '**'
paths-ignore:
- '**/*.md'
workflow_dispatch:
jobs:
test-latest:
runs-on: ubuntu-latest
@ -29,11 +35,11 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "22.x"
node-version: '22.x'
- uses: actions/setup-go@v5
with:
go-version: "1.23.8"
go-version: '1.23.8'
- run: npm install
working-directory: vscode-extension
@ -52,6 +58,12 @@ jobs:
- run: xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm test
working-directory: vscode-extension
- uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: /tmp/test-resources/screenshots/
test-release:
runs-on: ubuntu-latest
@ -60,7 +72,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "22.x"
node-version: '22.x'
- run: npm install
@ -68,7 +80,14 @@ jobs:
- run: xvfb-run --auto-servernum --server-args='-screen 0 1920x1080x24' npm test
build:
- uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: /tmp/test-resources/screenshots/
upload:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
needs:
- test-latest
@ -77,42 +96,33 @@ jobs:
strategy:
matrix:
os: [alpine, linux, win32, darwin]
arch: [amd64, arm64]
nodearch: [x64, arm64]
include:
- arch: amd64
nodearch: x64
- arch: arm64
nodearch: arm64
- os: win32
nodeos: win32
ext: .exe
- os: darwin
nodeos: darwin
ext: ""
ext: ''
- os: linux
nodeos: linux
ext: ""
ext: ''
- os: alpine
nodeos: linux
ext: ""
ext: ''
steps:
- name: actions/checkout@v4 (docker/vscode-extension)
uses: actions/checkout@v4
with:
path: vscode-extension
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22.x"
node-version: '22.x'
- working-directory: vscode-extension
run: |
- run: |
NODE_OS=${{ matrix.nodeos }} NODE_ARCH=${{ matrix.nodearch }} npm install
- name: Set variables
id: set-variables
working-directory: vscode-extension
run: |
VERSION=$(npm pkg get version | tr -d \")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
@ -120,44 +130,113 @@ jobs:
SHA=$(git rev-parse --short HEAD)
echo "SHA=$SHA" >> "$GITHUB_OUTPUT"
- name: Build the extension (refs/heads)
if: startsWith(github.ref, 'refs/heads')
- name: Build the extension
env:
VERSION: ${{ steps.set-variables.outputs.VERSION }}
SHA: ${{ steps.set-variables.outputs.SHA }}
working-directory: vscode-extension
run: |
npm install -g @vscode/vsce
vsce package --target ${{ matrix.os }}-${{ matrix.nodearch }} -o docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-$VERSION-$SHA.vsix
- name: actions/upload-artifact@v4 (refs/heads)
if: startsWith(github.ref, 'refs/heads')
uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v4
with:
name: docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}-${{ steps.set-variables.outputs.SHA }}.vsix
path: vscode-extension/docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}-${{ steps.set-variables.outputs.SHA }}.vsix
path: docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}-${{ steps.set-variables.outputs.SHA }}.vsix
if-no-files-found: error
- name: Build the extension (refs/tags/v)
if: startsWith(github.ref, 'refs/tags/v')
create-release:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
needs:
- test-latest
- test-release
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Set variables
id: set-variables
run: |
VERSION=$(npm pkg get version | tr -d \")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Generate release notes
run: |
node build/releaser.mjs generate-release-notes > release-notes.tmp
- name: Get current date
id: date
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 https://github.com/softprops/action-gh-release/commit/c062e08bd532815e2082a85e87e3ef29c3e6d191
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: v${{ steps.set-variables.outputs.version }} - ${{ steps.date.outputs.current_date }}
tag_name: v${{ steps.set-variables.outputs.version }}
body_path: release-notes.tmp
fail_on_unmatched_files: true
upload-release-binaries:
runs-on: ubuntu-latest
needs:
- create-release
strategy:
matrix:
os: [alpine, linux, win32, darwin]
nodearch: [x64, arm64]
include:
- os: win32
nodeos: win32
ext: .exe
- os: darwin
nodeos: darwin
ext: ''
- os: linux
nodeos: linux
ext: ''
- os: alpine
nodeos: linux
ext: ''
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.x'
- run: |
NODE_OS=${{ matrix.nodeos }} NODE_ARCH=${{ matrix.nodearch }} npm install
- name: Set variables
id: set-variables
run: |
VERSION=$(npm pkg get version | tr -d \")
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
- name: Build the extension
env:
VERSION: ${{ steps.set-variables.outputs.VERSION }}
working-directory: vscode-extension
run: |
npm install -g @vscode/vsce
vsce package --target ${{ matrix.os }}-${{ matrix.nodearch }} -o docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-$VERSION.vsix
- name: actions/upload-artifact@v4 (refs/tags/v)
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/v')
- uses: actions/upload-artifact@v4
with:
name: docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}.vsix
path: vscode-extension/docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}.vsix
path: docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}.vsix
if-no-files-found: error
- uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 https://github.com/softprops/action-gh-release/commit/c062e08bd532815e2082a85e87e3ef29c3e6d191
if: startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: vscode-extension/docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}.vsix
tag_name: v${{ steps.set-variables.outputs.version }}
files: docker-vscode-extension-${{ matrix.os }}-${{ matrix.nodearch }}-${{ steps.set-variables.outputs.VERSION }}.vsix
if-no-files-found: error

76
.github/workflows/prepare-release.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: Prepare release
on:
workflow_dispatch:
inputs:
version_type:
description: Version type
required: true
default: minor
type: choice
options:
- patch
- minor
- major
permissions:
contents: write
pull-requests: write
jobs:
prepare-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Update versions in package.json and package-lock.json
id: version
run: |
npm version ${{ github.event.inputs.version_type }} --no-git-tag-version
NEW_VERSION=$(npm pkg get version | tr -d \")
echo "New version (${{ github.event.inputs.version_type }}): $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Update changelog to version ${{ steps.version.outputs.new_version }}
run: |
node build/releaser.mjs update-changelog ${{ steps.version.outputs.new_version }}
- name: Configure Git
run: |
git config --local user.email "${{ github.actor }}@users.noreply.github.com"
git config --local user.name "${{ github.actor }}"
- name: Create pull request
# https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.8
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: main
branch: bot/prepare-release-v${{ steps.version.outputs.new_version }}
commit-message: |
Prepare for the v${{ steps.version.outputs.new_version }} release
This commit was generated by a GitHub Action workflow. It was triggered
by ${{ github.actor }}.
signoff: true
delete-branch: true
title: 'Prepare for the v${{ steps.version.outputs.new_version }} release (triggered by ${{ github.actor }})'
body: |
This pull request was generated by `./github/workflows/prepare-release.yml`.
It modifies the following three files:
- `CHANGELOG.md` (update the section header to ${{ steps.version.outputs.new_version }} with today's date in UTC and the links at the bottom)
- `package.json` (update version number to ${{ steps.version.outputs.new_version }} )
- `package-lock.json` (update version number to ${{ steps.version.outputs.new_version }})
draft: false
add-paths: |
CHANGELOG.md
package.json
package-lock.json
assignees: ${{ github.actor }}
reviewers: ${{ github.actor }}

View File

@ -9,8 +9,5 @@ bin
.vscode-test/
.test-extensions
syntaxes/
.github/workflows/build.yml
misc/
*/coverage

5
.vscode/launch.json vendored
View File

@ -10,7 +10,8 @@
"type": "extensionHost",
"request": "launch",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/test/workspace"
],
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
@ -18,4 +19,4 @@
"preLaunchTask": "${defaultBuildTask}"
}
]
}
}

View File

@ -1,6 +1,12 @@
// Place your settings in this file to overwrite default and user settings.
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},

View File

@ -7,6 +7,7 @@ out/**
resources/readme/**
src/**
test/**
misc/**
.gitignore
.yarnrc
webpack.config.js

View File

@ -2,6 +2,169 @@
All notable changes to the Docker DX extension will be documented in this file.
## [Unreleased]
### Added
- Dockerfile
- textDocument/inlayHint
- show when an image was last pushed ([docker/docker-language-server#431](https://github.com/docker/docker-language-server/issues/431))
- Compose
- textDocument/completion
- suggest image tags for images from Docker Hub ([docker/docker-language-server#375](https://github.com/docker/docker-language-server/issues/375))
- textDocument/documentLink
- support providing links for the `env_file` attribute of a service object ([docker/docker-language-server#436](https://github.com/docker/docker-language-server/issues/436))
- support providing links for the `env_file` for included paths ([docker/docker-language-server#438](https://github.com/docker/docker-language-server/issues/438))
- Bake
- textDocument/completion
- provide local file and folder name suggestions ([docker/docker-language-server#414](https://github.com/docker/docker-language-server/issues/414))
- `context` attribute in a `target` block
- `contexts` attribute in a `target` block
- `dockerfile` attribute in a `target` block
### Fixed
- Dockerfile
- textDocument/hover
- ignore 4XX errors when hovering over images with a non-standard tag ([docker/docker-language-server#371](https://github.com/docker/docker-language-server/issues/371))
- Compose
- textDocument/completion
- correct file system suggestions if an absolute path is used ([docker/docker-language-server#443](https://github.com/docker/docker-language-server/issues/443))
- textDocument/documentLink
- stop returning links for alias nodes in included paths ([docker/docker-language-server#439](https://github.com/docker/docker-language-server/issues/439))
- Bake
- textDocument/completion
- check the type of the block before suggesting items ([docker/docker-language-server#422](https://github.com/docker/docker-language-server/issues/422))
## [0.15.0] - 2025-08-13
### Added
- added a language configuration for the `dockerbake` language to improve the editing experience ([#184](https://github.com/docker/vscode-extension/issues/184))
- Compose
- updated Compose schema to the latest version
### Fixed
- Bake
- textDocument/hover
- fix error when hovering inside a comment ([docker/docker-language-server#410](https://github.com/docker/docker-language-server/issues/410))
## [0.14.0] - 2025-08-06
### Added
- Compose
- textDocument/completion
- provide local file and folder name suggestions when modifying simple strings
- service volumes ([docker/docker-language-server#376](https://github.com/docker/docker-language-server/issues/376))
- `context` attribute of a `build` object of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `dockerfile` attribute of a `build` object of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `file` attribute of a `credential_spec` object of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `env_file` of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `path` attribute of an `env_file` array item of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `file` attribute of an `extends` object of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `label_file` of a service ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `file` attribute of a config ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `file` attribute of a secret ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- string items of include objects ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `env_file` attribute of include objects ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
- `path` attribute of include objects ([docker/docker-language-server#403](https://github.com/docker/docker-language-server/issues/403))
### Fixed
- fix Dockerfile Language Server crash with tabbed heredoc delimiters ([#171](https://github.com/docker/vscode-extension/issues/171))
- fix Buildx debugger integration so that it works on Windows ([#181](https://github.com/docker/vscode-extension/issues/181))
- allow switching the builder used for debug sessions ([#183](https://github.com/docker/vscode-extension/pull/183))
- Compose
- textDocument/completion
- fix build stage lookups for files in a folder under the `\\wsl$` host ([docker/docker-language-server#382](https://github.com/docker/docker-language-server/issues/382))
- textDocument/documentLink
- improve handling of malformed image attribute values with registry prefixes ([docker/docker-language-server#369](https://github.com/docker/docker-language-server/issues/369))
- convert links properly if a WSL URI with a dollar sign is used ([docker/docker-language-server#366](https://github.com/docker/docker-language-server/issues/366))
- Bake
- textDocument/codeLens
- refactor the URI handling code so it will accept a WSL URI with a dollar sign ([docker/docker-language-server#388](https://github.com/docker/docker-language-server/issues/388))
- textDocument/completion
- fix build stage and ARG name inference completion items for files in a folder under the `\\wsl$` host ([docker/docker-language-server#396](https://github.com/docker/docker-language-server/issues/396))
- textDocument/definition
- handle WSL URIs with a dollar sign properly to fix build stage lookups on those hosts ([docker/docker-language-server#390](https://github.com/docker/docker-language-server/issues/390))
- handle WSL URIs with a dollar sign properly to fix build ARG reference lookups on those hosts ([docker/docker-language-server#393](https://github.com/docker/docker-language-server/issues/393))
- textDocument/documentLink
- convert links properly if a WSL URI with a dollar sign is used ([docker/docker-language-server#378](https://github.com/docker/docker-language-server/issues/378))
- textDocument/inlayHint
- refactor the URI handling code so it will process a WSL URI with a dollar sign correctly ([docker/docker-language-server#395](https://github.com/docker/docker-language-server/issues/395))
- textDocument/inlineCompletion
- convert links properly if a WSL URI with a dollar sign is used ([docker/docker-language-server#384](https://github.com/docker/docker-language-server/issues/384))
- textDocument/publishDiagnostics
- update the URI handling so that a WSL URI with a dollar sign can be scanned for errors ([docker/docker-language-server#386](https://github.com/docker/docker-language-server/issues/386))
## [0.13.0] - 2025-07-17
### Added
- Compose
- textDocument/documentLink
- add anchor resolution for all supported document links ([docker/docker-language-server#348](https://github.com/docker/docker-language-server/issues/348))
- return document links for the `file` attribute of a service object's `extends` attribute object ([docker/docker-language-server#172](https://github.com/docker/docker-language-server/issues/172))
- provide document links for models on Docker Hub and Hugging Face ([docker/docker-language-server#356](https://github.com/docker/docker-language-server/issues/356))
- return document links for the `label_file` attribute of a service object ([docker/docker-language-server#360](https://github.com/docker/docker-language-server/issues/360))
- textDocument/hover
- support hovering over referenced models ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
### Changed
- errors with the Docker Language Server will no longer be hidden
### Fixed
- stop the language server from crashing when opened inside a WSL folder with a dollar sign ([#165](https://github.com/docker/vscode-extension/issues/165))
- Compose
- textDocument/completion
- prevent wildcard object attribute suggestions if the text cursor is not at the right indentation for attributes to be inserted ([docker/docker-language-server#342](https://github.com/docker/docker-language-server/issues/342))
- textDocument/documentLink
- fix bounds index error if a quoted string just has a registry and the colon character at the end ([docker/docker-language-server#351](https://github.com/docker/docker-language-server/issues/351))
## [0.12.0] - 2025-07-09
### Added
- a new experimental `docker.extension.enableBuildDebugging` setting for developing and testing the upcoming build debugging feature
- this feature is under active development and is not ready for general use
- Compose
- update schema to the latest version
- textDocument/completion
- support completing model object names ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
- textDocument/definition
- support jumping to referenced model objects ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
- textDocument/documentHighlight
- support highlighting referenced models objects ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
- textDocument/documentLink
- support recursing into anchors when searching for document links ([docker/docker-language-server#329](https://github.com/docker/docker-language-server/issues/329))
- return document links for the `file` attribute of a service object's `credential_spec` ([docker/docker-language-server#338](https://github.com/docker/docker-language-server/issues/338))
- textDocument/documentSymbol
- show model objects in the document symbol tree ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
- textDocument/prepareRename
- allow preparing rename on model objects ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
- textDocument/rename
- support renaming model objects ([docker/docker-language-server#343](https://github.com/docker/docker-language-server/issues/343))
### Fixed
- Compose
- textDocument/completion
- prevent errors if an empty JSON object is the content of the YAML file ([docker/docker-language-server#330](https://github.com/docker/docker-language-server/issues/330))
- check character offset before processing to prevent errors ([docker/docker-language-server#333](https://github.com/docker/docker-language-server/issues/333))
## [0.11.0] - 2025-06-23
### Added
- Dockerfile
- include the Dockerfile Language Server written in TypeScript into the extension
- draw horizontal lines between each `FROM` instruction to help users visually distinguish the different parts of a Dockerfile ([#147](https://github.com/docker/vscode-extension/issues/147))
- a new `docker.extension.editor.dockerfileBuildStageDecorationLines` setting to toggle the divider lines, defaults to `true`
## [0.10.0] - 2025-06-12
### Added
@ -340,7 +503,12 @@ All notable changes to the Docker DX extension will be documented in this file.
- error reporting
- Compose outline support
[Unreleased]: https://github.com/docker/vscode-extension/compare/v0.10.0...main
[Unreleased]: https://github.com/docker/docker-language-server/compare/v0.15.0...main
[0.15.0]: https://github.com/docker/docker-language-server/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/docker/vscode-extension/compare/v0.13.0...v0.14.0
[0.13.0]: https://github.com/docker/vscode-extension/compare/v0.12.0...v0.13.0
[0.12.0]: https://github.com/docker/vscode-extension/compare/v0.11.0...v0.12.0
[0.11.0]: https://github.com/docker/vscode-extension/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/docker/vscode-extension/compare/v0.9.0...v0.10.0
[0.9.0]: https://github.com/docker/vscode-extension/compare/v0.8.1...v0.9.0
[0.8.1]: https://github.com/docker/vscode-extension/compare/v0.8.0...v0.8.1

81
DEBUGGING.md Normal file
View File

@ -0,0 +1,81 @@
# Build Debugging
> ⚠️ This feature is under **active** development and there may be breaking changes as we continue experimenting and fine tuning it. If you have feedback about this feature, please [open an issue](https://github.com/docker/vscode-extension/issues) or [start a discussion thread](https://github.com/docker/vscode-extension/discussions) and let us know what you think.
## Overview
Buildx provides an implementation of the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/). This means development tools that support and implement the protocol can interface with Buildx directly and step through the build process in real-time.
## Requirements
To use the build debugging feature, you will need to have [Buildx](https://github.com/docker/buildx) installed. The minimum supported version is v0.26.1. You can install Buildx manually by following the instructions [here](https://github.com/docker/buildx?tab=readme-ov-file#manual-download).
1. Run `docker buildx version` to check your Buildx version.
2. Run `BUILDX_EXPERIMENTAL=1 docker buildx dap` to check that the `dap` subcommand is available in your Buildx installation.
3. Search for "docker enable build debugging" in the VS Code settings (<kbd>Ctrl+,</kbd> or <kbd>Command+,</kbd>) and enable the experimental "Enable Build Debugging" setting.
4. Restart VS Code for the setting to take effect.
![Use the settings page to enable the build debugging feature](resources/debugging/settings.png)
## Features
### Debugging without a Launch Configuration
The Docker DX extension will fill in a debug configuration on a best effort basis. If you do not have a `launch.json` file or if it does not define any launch configurations, you can start debugging by simply opening a Dockerfile and then clicking on the "Run and Debug" button in the "Run and Debug" side panel.
![Use the "Run and Debug" button to launch a debug session without a launch.json file](resources/debugging/debug-without-config.png)
### Debugging with a Launch Configuration
For more complicated build configurations, you can use the `launch.json` to define launch configurations for the buildx debugger.
<!-- prettier-ignore -->
```jsonc
{
"type": "dockerfile", // required, must not be modified
"request": "launch", // required, must not be modified
"name": "Docker: Build", // required, configurable
"dockerfile": "Dockerfile", // required, configurable
"contextPath": "${workspaceFolder}",
"target": "test", // optional, should be a build stage in the Dockerfile
"args": [
// additional arguments for the build command
"--build-arg",
"NODE_ENV=development"
],
"stopOnEntry": true, // if the debugger should suspend on the first line, defaults to false
}
```
### Setting Breakpoints
The build debugger integration supports setting line breakpoints on an instruction. Visual Studio Code offers various ways for setting a breakpoint which you can read more about [here](https://code.visualstudio.com/docs/debugtest/debugging#_breakpoints).
![Add breakpoints by clicking on the left side of the editor](resources/debugging/add-breakpoints.png)
### Opening a Shell Inside the Image Being Built
> ⚠️ Note that this feature is still being fine tuned.
When crafting a Dockerfile in the beginning, it is common to make changes and rerun the build again and again. With the shell exec feature, you can quickly open a shell for the image you are building and test commands there before copying them back into your Dockerfile.
1. Set a breakpoint in the build.
2. When the build process has been suspended, open the Debug Console.
3. Type in `exec` and press <kbd>Enter</kbd>.
4. A new terminal with a shell inside the paused build image will be opened.
![Run exec in the Debug Console to open a terminal](resources/debugging/debug-exec-invoke.png)
![The opened terminal can be interfaced with for debugging in real-time](resources/debugging/debug-exec-shell.png)
### Inspecting Variables
The Variables pane in Visual Studio Code lets you view the value of `ARG` and `ENV` variables. The pane can help clarify what a value is if variable substitutions are involved.
![The opened terminal can be interfaced with for debugging in real-time](resources/debugging/variables.png)
## Troubleshooting
If you encounter errors or issues with this feature, the DAP logs may help. Open the Output panel and select "Docker Buildx DAP" from the drop down.
![The opened terminal can be interfaced with for debugging in real-time](resources/debugging/dap-logs.png)

37
FAQ.md
View File

@ -12,6 +12,30 @@ Please refer to [this blog post](https://www.docker.com/blog/docker-dx-extension
For information regarding telemetry, please refer to [TELEMETRY.md](./TELEMETRY.md).
### Where can I find the language server logs?
The language server logs can be enabled by modifying your settings. After turning them on, you can look for "Docker Language Server" and/or "Docker Language Server" in the Output view.
```JSONC
{
// Docker Language Server (https://github.com/docker/docker-language-server)
"dockerLanguageClient.trace.server": "verbose",
// Dockerfile Language Server (https://github.com/rcjsuen/dockerfile-language-server)
"dockerfile-language-server.trace.server": "verbose"
}
```
### How can I disable warnings related to vulnerabilities in images?
To disable everything, you can set the `docker.lsp.experimental.vulnerabilityScanning` setting to `false`.
If you would like to disable specific warnings about vulnerabilities, you can opt in or out of them individually as well.
- `docker.lsp.experimental.scout.criticalHighVulnerabilities`
- `docker.lsp.experimental.scout.notPinnedDigest`
- `docker.lsp.experimental.scout.recommendedTag`
- `docker.lsp.experimental.scout.vulnerabilities`
### I am seeing duplicated editor features (such as code completion suggestions, hover tooltips, etc.) in Compose files.
Do you have any of the following extensions installed?
@ -23,12 +47,11 @@ Do you have any of the following extensions installed?
If yes, you can refer to the steps below to remove the duplicates. Alternatively, if you would prefer to disable the Compose editing features that _this_ extension is providing, you can set the `docker.extension.enableComposeLanguageServer` setting to `false` and then restart Visual Studio Code.
- [Red Hat's YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) (powered by [redhat-developer/yaml-language-server](https://github.com/redhat-developer/yaml-language-server))
1. To disable duplicates from this extension, create a JSON file with `{}` as its content and save it somewhere. Let's say it is at `/home/user/empty.json`.
2. Open the [Command Palette](https://code.visualstudio.com/api/ux-guidelines/command-palette) in Visual Studio Code and open "Preferences: Open User Settings (JSON)".
3. Set `docker.extension.enableComposeLanguageServer` to `true` by following the snippet below.
4. Create an object attribute for `yaml.schemas` if it does not already exist.
5. Inside the `yaml.schemas` object, map your empty JSON file to Compose YAML files by following the snippet below.
6. YAML files named `compose*y*ml` or `docker-compose*y*ml` will now no longer have the Compose schema associated with them in Red Hat's extension so Red Hat's extension will stop providing YAML features for Compose files. This admittedly is a strange way to disable YAML features for a given file but it is the only known workaround for resolving this until [redhat-developer/vscode-yaml#1088](https://github.com/redhat-developer/vscode-yaml/issues/1088) is implemented.
1. To disable duplicates from this extension, open the [Command Palette](https://code.visualstudio.com/api/ux-guidelines/command-palette) in Visual Studio Code and open "Preferences: Open User Settings (JSON)".
2. Set `docker.extension.enableComposeLanguageServer` to `true` by following the snippet below.
3. Create an object attribute for `yaml.schemas` if it does not already exist.
4. Inside the `yaml.schemas` object, copy the URL to [this empty JSON file](https://raw.githubusercontent.com/docker/vscode-extension/6a88caada42b57090df7ce91ec2a6561b422afe1/misc/empty.json) to Compose YAML files by following the snippet below.
5. YAML files named `compose*y*ml` or `docker-compose*y*ml` will now no longer have the Compose schema associated with them in Red Hat's extension so Red Hat's extension will stop providing YAML features for Compose files. This admittedly is a strange way to disable YAML features for a given file but it is the only known workaround for resolving this until [redhat-developer/vscode-yaml#245](https://github.com/redhat-developer/vscode-yaml/issues/245) is implemented.
```JSONC
{
@ -40,7 +63,7 @@ If yes, you can refer to the steps below to remove the duplicates. Alternatively
// this tells Red Hat's YAML extension to consider Compose YAML
// files as not having a schema so it will stop suggesting code
// completion items, hover tooltips, and so on
"/home/user/empty.json": ["compose*y*ml", "docker-compose*y*ml"]
"https://raw.githubusercontent.com/docker/vscode-extension/6a88caada42b57090df7ce91ec2a6561b422afe1/misc/empty.json": ["compose*y*ml", "docker-compose*y*ml"]
}
}
```

View File

@ -30,7 +30,7 @@ If you are on an unsupported system, let us know of your interest in this extens
You can get linting checks from [BuildKit](https://github.com/moby/buildkit) and [BuildX](https://github.com/docker/buildx) when editing your Dockerfiles.
Any references to images with vulnerabilities are also flagged. Note: This is an experimental feature.
Any references to images with vulnerabilities are also flagged. This is an **experimental** feature and may change in the future. Refer to our [FAQ.md](./FAQ.md) to see how you can opt in or out of these warnings.
Errors are visible directly in your editor or you can look at them by opening up the Problems panel (<kbd>Ctrl+Shift+M</kbd> on Windows/Linux, <kbd>Shift+Command+M</kbd> on Mac).
@ -56,6 +56,12 @@ The extension provides inline suggestions to generate a Bake target to correspon
![Suggesting Bake targets based on the content of the local Dockerfile](resources/readme/docker-bake-inline-completion.png)
### Build Debugging (EXPERIMENTAL)
This feature is under active development and requires version `v0.26.1` of `docker buildx` or newer. This is disabled by default. Open [DEBUGGING.md](./DEBUGGING.md) to learn more about this feature in Visual Studio Code and how to enable it.
For information about Buildx and the Debug Adapter Protocol, go [here](https://github.com/docker/buildx/blob/master/docs/dap.md). If you have any bugs, feature requests, or feedback about Buildx's support for Debug Adapter Protocol, please report them [here](https://github.com/docker/buildx/issues/new/choose).
## Builds
[GitHub Actions](https://github.com/docker/vscode-extension/actions) builds eight `.vsix` files - one for each platform combination (Windows, macOS, Linux, Alpine Linux x `amd64`/`arm64`).
@ -64,6 +70,11 @@ Note: The language server binary from these builds are not signed and/or notariz
## Development
To develop this extension, you should first make sure you have the following extensions installed:
- [Prettier - Code formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [TypeScript + Webpack Problem Matchers](https://marketplace.visualstudio.com/items?itemName=amodio.tsl-problem-matcher)
To debug the VS Code extension, clone this repository and then run `npm install`. This will download a binary of the [Docker Language Server](https://github.com/docker/docker-language-server/releases) to the `bin` folder. If you would like to test your own custom build of the language server, simply replace the file in the `bin` folder with your own binary.
### Debugging both the extension and language server
@ -77,6 +88,19 @@ To debug the VS Code extension, clone this repository and then run `npm install`
Run `npm test` to launch the UI tests.
### Releasing
Follow the following steps to create a new release of the Docker DX Visual Studio Code extension:
1. Run the "[prepare release](https://github.com/docker/vscode-extension/actions/workflows/prepare-release.yml)" workflow with the desired bump in semantic versioning. This workflow will update `CHANGELOG.md`, `package.json`, and `package-lock.json` and create a pull request with the three files.
2. Review the generated [pull request](https://github.com/docker/vscode-extension/pulls).
1. The pull request's description will describe the changes to the three files. Verify that the changes make sense.
2. If the changes look good and the builds and checks have completed and passed, approve the pull request and merge it manually.
3. Now that the pull request has been merged into the `main` branch, a build named "Build: Automatic" will be triggered. Wait for the automated build from the "[build](https://github.com/docker/vscode-extension/actions/workflows/build.yml)" workflow to complete.
4. If the build has completed successfully, use the "Run workflow" button to manually trigger the "[build](https://github.com/docker/vscode-extension/actions/workflows/build.yml)" workflow.
5. This manually triggered workflow will start a "Build: Release" which will run the tests, create the release, build the binaries, and attach the binaries to the release.
6. When the workflow has completed, open the [releases](https://github.com/docker/vscode-extension/releases) page. It should have been automatically generated by the workflow and the resulting VSIX files should be attached to the release.
## Telemetry
The Docker DX extension collects telemetry. We collect this telemetry so that we can improve the extension by understanding usage patterns and catching crashes and errors for diagnostic purposes. Note that if you have already opted out of sending telemetry in Visual Studio Code then no telemetry will be sent.
@ -86,3 +110,7 @@ See [TELEMETRY.md](./TELEMETRY.md) for details about what kind of telemetry we c
## FAQ
Please refer to [FAQ.md](./FAQ.md) for our list of frequently asked questions.
## License
[Apache License Version 2.0](./LICENSE)

View File

@ -77,7 +77,7 @@ async function downloadLanguageServerBinary() {
const platform = getPlatform();
const arch = getArch();
const suffix = platform === 'windows' ? '.exe' : '';
const version = '0.12.0';
const version = '0.17.0';
const binaryFile = `docker-language-server-${platform}-${arch}-v${version}${suffix}`;
const targetFile = `docker-language-server-${platform}-${arch}${suffix}`;
const url = `https://github.com/docker/docker-language-server/releases/download/v${version}/${binaryFile}`;

170
build/releaser.mjs Normal file
View File

@ -0,0 +1,170 @@
import * as fs from 'fs';
import * as readline from 'readline';
const changelogPath = 'CHANGELOG.md';
const args = process.argv.slice(2);
if (args.length < 1) {
console.error(
`Usage: node releaser.mjs <update-changelog|generate-release-notes> [args...]`,
);
process.exit(1);
}
const command = args[0].toLowerCase();
if (command === 'update-changelog') {
if (args.length < 2) {
console.error(`Usage: node releaser.js update-changelog <version>`);
process.exit(1);
}
const version = args[1];
if (!/^\d+\.\d+\.\d+$/.test(version)) {
console.error(`Error: version must be in format x.y.z (e.g., 1.2.3)`);
process.exit(1);
}
updateChangelog(changelogPath, changelogPath, version)
.then(() =>
console.log(`Successfully updated CHANGELOG.md with version ${version}`),
)
.catch((err) => {
console.error(`Error: ${err.message}`);
process.exit(1);
});
} else if (command === 'generate-release-notes') {
generateReleaseNotes(changelogPath)
.then((content) => console.log(content))
.catch((err) => {
console.error(`Error: ${err.message}`);
process.exit(1);
});
} else {
console.error(
`Error: unknown command '${command}'. Use 'update-changelog' or 'generate-release-notes'`,
);
process.exit(1);
}
function readFileLines(filePath) {
return new Promise((resolve, reject) => {
const lines = [];
const rl = readline.createInterface({
input: fs.createReadStream(filePath),
crlfDelay: Infinity,
});
rl.on('line', (line) => lines.push(line));
rl.on('close', () => resolve(lines));
rl.on('error', reject);
});
}
async function updateChangelog(inputPath, outputPath, newVersion) {
const lines = await readFileLines(inputPath);
let unreleasedIndex = -1;
let nextVersionIndex = -1;
let linksStartIndex = -1;
let previousVersion = '';
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
if (line.includes('## [Unreleased]')) {
unreleasedIndex = i;
} else if (
nextVersionIndex === -1 &&
unreleasedIndex !== -1 &&
line.startsWith('## [') &&
!line.includes('Unreleased')
) {
nextVersionIndex = i;
const match = line.match(/^## \[([0-9]+\.[0-9]+\.[0-9]+)\]/);
if (match) {
previousVersion = match[1];
}
} else if (
linksStartIndex === -1 &&
line.startsWith('[') &&
line.includes(']: https://github.com/')
) {
linksStartIndex = i;
break;
}
}
if (unreleasedIndex === -1) {
throw new Error("could not find 'Unreleased' section in changelog");
}
if (nextVersionIndex === -1 || !previousVersion) {
throw new Error(
"could not find previous version section after 'Unreleased'",
);
}
if (linksStartIndex === -1) {
throw new Error('could not find links section in changelog');
}
const today = new Date().toISOString().split('T')[0];
lines[unreleasedIndex] = `## [${newVersion}] - ${today}`;
const updatedLinks = updateLinks(
lines.slice(linksStartIndex),
newVersion,
previousVersion,
);
const updatedContent = lines.slice(0, linksStartIndex).concat(updatedLinks);
await fs.promises.writeFile(outputPath, updatedContent.join('\n') + '\n');
}
function updateLinks(linkLines, newVersion, previousVersion) {
// first link unreleased, second link with the new tag
const newLinks = [
`[Unreleased]: https://github.com/docker/docker-language-server/compare/v${newVersion}...main`,
`[${newVersion}]: https://github.com/docker/docker-language-server/compare/v${previousVersion}...v${newVersion}`,
];
// all other links can be from the original, after skipping the first one
for (let i = 1; i < linkLines.length; i++) {
newLinks.push(linkLines[i]);
}
return newLinks;
}
async function generateReleaseNotes(filePath) {
const lines = await readFileLines(filePath);
let firstHeader = -1,
secondHeader = -1;
for (let i = 0; i < lines.length; i++) {
if (lines[i].startsWith('## ')) {
if (firstHeader === -1) {
firstHeader = i;
} else if (secondHeader === -1) {
secondHeader = i;
break;
}
}
}
if (secondHeader === -1) {
throw new Error('could not find two ## headers in the changelog');
}
// remove leading and trailing empty newlines
const content = lines.slice(firstHeader + 1, secondHeader);
while (content.length > 0 && content[0].trim() === '') {
content.shift();
}
while (content.length > 0 && content[content.length - 1].trim() === '') {
content.pop();
}
return content.join('\n');
}

View File

@ -0,0 +1,27 @@
{
"comments": {
"blockComment": ["/*", "*/"],
"lineComment": {
"comment": "//",
"noIndent": false
}
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
{ "open": "{", "close": "}" },
{ "open": "[", "close": "]" },
{ "open": "(", "close": ")" },
{ "open": "\"", "close": "\"", "notIn": ["string"] },
{ "open": "/*", "close": " */", "notIn": ["string"] }
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""]
]
}

1
misc/empty.json Normal file
View File

@ -0,0 +1 @@
{}

1555
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
"name": "docker",
"displayName": "Docker DX",
"description": "Edit smarter, ship faster with an enhanced Docker-development experience",
"version": "0.10.0",
"icon": "resources/docker-logo-vertical-blue.png",
"version": "0.15.0",
"icon": "resources/logo-256x256.png",
"license": "Apache-2.0",
"engines": {
"vscode": "^1.92.0"
@ -11,14 +11,16 @@
"publisher": "docker",
"categories": [
"Programming Languages",
"Linters"
"Linters",
"Debuggers"
],
"repository": {
"type": "git",
"url": "https://github.com/docker/vscode-extension"
},
"activationEvents": [
"onLanguage:dockerbake",
"onDebugResolve:dockerfile",
"onDebugDynamicConfigurations:dockerfile",
"onLanguage:dockercompose",
"onLanguage:dockerfile"
],
@ -34,6 +36,10 @@
"title": "Scan for CVEs with Docker Scout",
"command": "docker.scout.imageScan",
"enablement": "(view == dockerImages || view == vscode-containers.views.images) && viewItem == image"
},
{
"title": "Build with Debugger",
"command": "docker.debug.editorContents"
}
],
"languages": [
@ -42,7 +48,8 @@
"filenames": [
"docker-bake.hcl",
"docker-bake.override.hcl"
]
],
"configuration": "./configs/dockerbake-language-configuration.json"
}
],
"grammars": [
@ -61,9 +68,90 @@
}
]
},
"breakpoints": [
{
"language": "dockerfile"
}
],
"debuggers": [
{
"type": "dockerfile",
"languages": [
"dockerfile"
],
"label": "Docker: Build",
"configurationAttributes": {
"launch": {
"required": [
"contextPath"
],
"properties": {
"dockerfile": {
"type": "string",
"description": "Relative path from the context to the dockerfile.",
"default": "Dockerfile"
},
"contextPath": {
"type": "string",
"description": "Path to the context.",
"default": "${workspaceFolder}"
},
"target": {
"type": "string",
"description": "Target build stage to build."
},
"stopOnEntry": {
"type": "boolean",
"description": "Stop the docker build on the first instruction.",
"default": false
},
"builder": {
"type": "string",
"description": "Builder to use."
},
"args": {
"type": "array",
"description": "Arguments to pass to the build."
}
}
}
},
"initialConfigurations": [
{
"type": "dockerfile",
"request": "launch",
"name": "Docker: Build",
"dockerfile": "Dockerfile",
"contextPath": "${workspaceFolder}"
}
],
"configurationSnippets": [
{
"label": "Docker: Build",
"description": "A new configuration for debugging a user selected Dockerfile.",
"body": {
"type": "dockerfile",
"request": "launch",
"name": "Docker: Build",
"dockerfile": "${2:Dockerfile}",
"contextPath": "^\"\\${workspaceFolder}\""
}
}
]
}
],
"configuration": {
"title": "Docker DX",
"properties": {
"docker.extension.enableBuildDebugging": {
"type": "boolean",
"description": "Enables build debugging features from the Docker DX extension. This feature is under active development. Note that changing this value requires a restart of Visual Studio Code to take effect.",
"markdownDescription": "Enable build debugging features from the Docker DX extension. This feature is under active development. Note that changing this value requires a **restart** of Visual Studio Code to take effect.",
"default": false,
"tags": [
"experimental"
]
},
"docker.extension.enableComposeLanguageServer": {
"type": "boolean",
"description": "Enable Compose editing features from the Docker DX extension. Note that changing this value requires a restart of Visual Studio Code to take effect.",
@ -77,6 +165,12 @@
"default": true,
"scope": "application"
},
"docker.extension.editor.dockerfileBuildStageDecorationLines": {
"type": "boolean",
"description": "Render a divider line between each build stage of a Dockerfile.",
"default": true,
"scope": "resource"
},
"docker.lsp.telemetry": {
"type": "string",
"description": "Determines what telemetry is collected by Docker. If vscode.env.isTelemetryEnabled is false, then telemetry collection is disabled regardless of what has been set for this configuration value.",
@ -161,6 +255,8 @@
},
"dependencies": {
"@bugsnag/js": "~8.2.0",
"dockerfile-ast": "0.7.1",
"dockerfile-language-server-nodejs": "0.14.1",
"vscode-languageclient": "9.0.1"
},
"devDependencies": {
@ -179,7 +275,8 @@
"prettier": "^3.5.3",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"vscode-extension-tester": "^8.13.0",
"umd-compat-loader": "^2.1.2",
"vscode-extension-tester": "^8.17.0",
"webpack": "^5.92.1",
"webpack-cli": "^5.1.4"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 KiB

BIN
resources/logo-256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

182
src/dap/config.ts Normal file
View File

@ -0,0 +1,182 @@
import * as vscode from 'vscode';
import { registerCommand } from '../extension';
import { getExtensionSetting } from '../utils/settings';
export const DebugEditorContentsCommandId = 'docker.debug.editorContents';
class DebugAdapterExecutableFactory
implements vscode.DebugAdapterDescriptorFactory
{
createDebugAdapterDescriptor(
session: vscode.DebugSession,
): vscode.ProviderResult<vscode.DebugAdapterDescriptor> {
var args = ['buildx'];
if (session.configuration?.builder) {
args = args.concat(['--builder', session.configuration?.builder]);
}
args = args.concat(['dap', 'build']);
if (session.configuration?.args) {
args = args.concat(session.configuration?.args);
}
const options = {
cwd: session.workspaceFolder?.uri.fsPath,
env: { BUILDX_EXPERIMENTAL: '1' },
};
return new vscode.DebugAdapterExecutable('docker', args, options);
}
}
class DockerfileConfigurationProvider
implements vscode.DebugConfigurationProvider
{
resolveDebugConfiguration(
_folder: vscode.WorkspaceFolder | undefined,
config: vscode.DebugConfiguration,
): vscode.ProviderResult<vscode.DebugConfiguration> {
// this can happen when debugging without anything in launch.json
if (!config.type && !config.request && !config.name) {
const editor = vscode.window.activeTextEditor;
if (editor !== undefined && editor.document.languageId === 'dockerfile') {
config.type = 'dockerfile';
config.name = 'Docker: Build';
config.request = 'launch';
config.dockerfile = editor.document.uri.fsPath;
config.contextPath = '${workspaceFolder}';
}
}
return config;
}
}
class DockerfileDebugAdapterTracker implements vscode.DebugAdapterTracker {
constructor(
private id: string,
private name: string,
private channel: vscode.OutputChannel,
) {}
log(logLevel: string, message: any): void {
message.id = this.id;
message.name = this.name;
this.channel.appendLine(
`${new Date().toISOString()} [${logLevel}] ${JSON.stringify(message)}`,
);
}
onWillStartSession(): void {
this.log('debug', { message: 'DAP session about to be started' });
}
onWillStopSession(): void {
this.log('debug', { message: 'DAP session about to be stopped' });
}
onWillReceiveMessage(message: any): void {
this.log('debug', {
message: 'DAP message will be received from the editor',
dapMessage: message,
});
}
onDidSendMessage(message: any): void {
this.log('debug', {
message: 'DAP message has been sent to the editor',
dapMessage: message,
});
}
onExit(code: number | undefined, signal: string | undefined): void {
const message = { message: 'DAP exited', code: code, signal: signal };
if (code === 0) {
this.log('debug', message);
} else {
this.log('error', message);
}
}
onError(error: Error): void {
this.log('error', {
message: 'DAP error occurred',
dapMessage: { error: String(error) },
});
}
}
export function setupDebugging(ctx: vscode.ExtensionContext) {
if (!getExtensionSetting<boolean>('enableBuildDebugging')) {
// the command is still contributed to the Command Palette because of package.json
registerCommand(ctx, DebugEditorContentsCommandId, async () => {
vscode.window.showErrorMessage(
'Build Debugging for Docker is an experimental feature that is under active development. ' +
'Enable the feature by toggling the docker.extension.enableBuildDebugging setting to true and restarting your client.',
);
return Promise.resolve(false);
});
// the debugger is still contributed and technically registered because of package.json
ctx.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider('dockerfile', {
resolveDebugConfiguration(): vscode.ProviderResult<vscode.DebugConfiguration> {
vscode.window.showErrorMessage(
'Build Debugging for Docker is an experimental feature that is under active development. ' +
'Enable the feature by toggling the docker.extension.enableBuildDebugging setting to true and restarting your client.',
);
return undefined;
},
}),
);
return;
}
let channel = vscode.window.createOutputChannel('Docker Buildx DAP', 'log');
registerCommand(
ctx,
DebugEditorContentsCommandId,
async (resource: vscode.Uri) => {
let targetResource = resource;
if (!targetResource && vscode.window.activeTextEditor) {
targetResource = vscode.window.activeTextEditor.document.uri;
}
if (targetResource) {
vscode.debug.startDebugging(undefined, {
type: 'dockerfile',
name: 'Docker: Build',
request: 'launch',
dockerfile: targetResource.fsPath,
contextPath: '${workspaceFolder}',
});
return Promise.resolve(true);
}
return Promise.resolve(false);
},
);
ctx.subscriptions.push(
vscode.debug.registerDebugConfigurationProvider(
'dockerfile',
new DockerfileConfigurationProvider(),
),
);
ctx.subscriptions.push(
vscode.debug.registerDebugAdapterDescriptorFactory(
'dockerfile',
new DebugAdapterExecutableFactory(),
),
);
vscode.debug.registerDebugAdapterTrackerFactory('dockerfile', {
createDebugAdapterTracker(
session,
): vscode.ProviderResult<vscode.DebugAdapterTracker> {
return new DockerfileDebugAdapterTracker(
session.id,
session.name,
channel,
);
},
});
}

View File

@ -21,6 +21,8 @@ import {
inspectExtensionSetting,
} from './utils/settings';
import { redact } from './telemetry/filter';
import { hookDecorators } from './utils/editor';
import { setupDebugging } from './dap/config';
export const BakeBuildCommandId = 'dockerLspClient.bake.build';
export const ScoutImageScanCommandId = 'docker.scout.imageScan';
@ -89,7 +91,7 @@ function registerCommands(ctx: vscode.ExtensionContext) {
});
}
function registerCommand(
export function registerCommand(
ctx: vscode.ExtensionContext,
id: string,
commandCallback: (...args: any[]) => Promise<boolean>,
@ -152,6 +154,8 @@ async function toggleComposeLanguageServerSetting(): Promise<string> {
}
export async function activate(ctx: vscode.ExtensionContext) {
setupDebugging(ctx);
hookDecorators(ctx);
const composeSetting = await toggleComposeLanguageServerSetting();
extensionVersion = String(ctx.extension.packageJSON.version);
Bugsnag.start({

View File

@ -1,64 +0,0 @@
import {
BottomBarPanel,
EditorView,
MarkerType,
ProblemsView,
VSBrowser,
} from 'vscode-extension-tester';
import * as path from 'path';
import { expect } from 'chai';
describe('Docker Bake', function () {
let bottomBar: BottomBarPanel;
before(async function () {
bottomBar = new BottomBarPanel();
await bottomBar.toggle(true);
});
after(async function () {
await bottomBar.toggle(false);
});
describe('Problems', function () {
let view: ProblemsView;
async function problemsExist(view: ProblemsView) {
const markers = await view.getAllVisibleMarkers(MarkerType.Any);
return markers.length > 0;
}
before(async function () {
this.timeout(30000);
view = await bottomBar.openProblemsView();
await VSBrowser.instance.openResources(
path.join('test', 'resources', 'docker-bake.hcl'),
);
await view.getDriver().wait(async function () {
return await problemsExist(view);
}, 15000);
});
after(async function () {
await new EditorView().closeAllEditors();
});
it('Bake file has an error about not being able to find an ARG', async function () {
const errors = await view.getAllVisibleMarkers(MarkerType.Error);
expect(errors.length).equals(1);
const errorText = await errors[0].getText();
expect(errorText).equal(
"Error: 'var' not defined as an ARG in your Dockerfile at line 3 and character 9. generated by Docker DX (docker-language-server)",
);
});
it('Bake file has no warnings', async function () {
const warnings = await view.getAllVisibleMarkers(MarkerType.Warning);
expect(warnings).is.empty;
});
});
});

View File

@ -10,12 +10,21 @@ import * as fs from 'fs';
import * as path from 'path';
import { expect } from 'chai';
describe('Dockerfile', function () {
async function problemsExist(view: ProblemsView) {
const markers = await view.getAllVisibleMarkers(MarkerType.Any);
return markers.length > 0;
}
describe('Problems', function () {
let bottomBar: BottomBarPanel;
let view: ProblemsView;
before(async function () {
this.timeout(30000);
bottomBar = new BottomBarPanel();
await bottomBar.toggle(true);
view = await bottomBar.openProblemsView();
});
after(async function () {
@ -24,18 +33,11 @@ describe('Dockerfile', function () {
describe('Problems', function () {
let editorView: EditorView;
let view: ProblemsView;
async function problemsExist(view: ProblemsView) {
const markers = await view.getAllVisibleMarkers(MarkerType.Any);
return markers.length > 0;
}
before(async function () {
this.timeout(30000);
editorView = new EditorView();
view = await bottomBar.openProblemsView();
const dockerfilePath = path.join('test', 'resources', 'Dockerfile');
fs.writeFileSync(dockerfilePath, 'FROM scratch\nENTRYPOINT ""\n');
@ -92,4 +94,37 @@ describe('Dockerfile', function () {
await editor.save();
});
});
describe('Docker Bake', function () {
before(async function () {
this.timeout(30000);
await VSBrowser.instance.openResources(
path.join('test', 'resources', 'docker-bake.hcl'),
);
await view.getDriver().wait(async function () {
return await problemsExist(view);
}, 15000);
});
after(async function () {
await new EditorView().closeAllEditors();
});
it('Bake file has an error about not being able to find an ARG', async function () {
const errors = await view.getAllVisibleMarkers(MarkerType.Error);
expect(errors.length).equals(1);
const errorText = await errors[0].getText();
expect(errorText).equal(
"Error: 'var' not defined as an ARG in your Dockerfile at line 3 and character 9. generated by Docker DX (docker-language-server)",
);
});
it('Bake file has no warnings', async function () {
const warnings = await view.getAllVisibleMarkers(MarkerType.Warning);
expect(warnings).is.empty;
});
});
});

82
src/utils/editor.ts Normal file
View File

@ -0,0 +1,82 @@
import * as vscode from 'vscode';
import { DockerfileParser } from 'dockerfile-ast';
/**
* Decoration that inserts a horizontal line into the editor.
*/
const decoration = vscode.window.createTextEditorDecorationType({
isWholeLine: true,
borderWidth: '1px 0 0 0',
borderStyle: 'solid',
borderColor: new vscode.ThemeColor('panelTitle.activeBorder'),
});
function getDecorationRanges(document: vscode.TextDocument): vscode.Range[] {
if (
vscode.workspace
.getConfiguration('docker.extension.editor', document)
.get<boolean>('dockerfileBuildStageDecorationLines') &&
document.languageId === 'dockerfile' &&
document.uri.scheme === 'file'
) {
const dockerfile = DockerfileParser.parse(document.getText());
return dockerfile.getFROMs().map((from) => {
const line = from.getRange().start.line;
return new vscode.Range(line, 0, line, 0);
});
}
return [];
}
export function hookDecorators(ctx: vscode.ExtensionContext): void {
vscode.workspace.onDidChangeConfiguration(
(event) => {
if (
event.affectsConfiguration(
'docker.extension.editor.dockerfileBuildStageDecorationLines',
)
) {
vscode.window.visibleTextEditors.forEach((editor) =>
editor.setDecorations(
decoration,
getDecorationRanges(editor.document),
),
);
}
},
null,
ctx.subscriptions,
);
vscode.window.visibleTextEditors.forEach((editor) =>
editor.setDecorations(decoration, getDecorationRanges(editor.document)),
);
vscode.window.onDidChangeVisibleTextEditors(
(editors) => {
for (const editor of editors) {
editor.setDecorations(decoration, getDecorationRanges(editor.document));
}
},
null,
ctx.subscriptions,
);
vscode.workspace.onDidChangeTextDocument(
(event) => {
for (const editor of vscode.window.visibleTextEditors) {
if (
event.document.uri.scheme === editor.document.uri.scheme &&
event.document.uri.path === editor.document.uri.path
) {
editor.setDecorations(
decoration,
getDecorationRanges(editor.document),
);
}
}
},
null,
ctx.subscriptions,
);
}

View File

@ -18,6 +18,11 @@ import {
export class DockerLanguageClient extends LanguageClient {
protected fillInitializeParams(params: InitializeParams): void {
super.fillInitializeParams(params);
const removeOverlappingIssues =
vscode.extensions.getExtension('ms-azuretools.vscode-docker') !==
undefined ||
vscode.extensions.getExtension('ms-azuretools.vscode-containers') !==
undefined;
const dockerConfiguration = vscode.workspace.getConfiguration('docker.lsp');
const extensionConfiguration =
vscode.workspace.getConfiguration('docker.extension');
@ -27,9 +32,7 @@ export class DockerLanguageClient extends LanguageClient {
'enableComposeLanguageServer',
),
},
dockerfileExperimental: {
removeOverlappingIssues: true,
},
dockerfileExperimental: { removeOverlappingIssues },
telemetry: getTelemetryValue(dockerConfiguration.get('telemetry')),
};
params.capabilities.experimental = {

View File

@ -207,7 +207,6 @@ async function createNative(ctx: vscode.ExtensionContext): Promise<boolean> {
const clientOptions: LanguageClientOptions = {
progressOnInitialization: true,
outputChannel: vscode.window.createOutputChannel('Docker Language Server'),
revealOutputChannelOn: RevealOutputChannelOn.Never,
markdown: {
isTrusted: false,
supportHtml: true,
@ -253,9 +252,63 @@ async function createNative(ctx: vscode.ExtensionContext): Promise<boolean> {
return true;
}
async function startDockerfileLanguageServer(
ctx: vscode.ExtensionContext,
): Promise<void> {
const serverModule = ctx.asAbsolutePath(
path.join('dist', 'dockerfile-language-server-nodejs', 'lib', 'server.js'),
);
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: { execArgv: ['--nolazy', '--inspect=6009'] },
},
};
const dockerfileLanguageClient = new LanguageClient(
'dockerfile-language-server',
'Dockerfile Language Server',
serverOptions,
{
documentSelector: [{ language: 'dockerfile', scheme: 'file' }],
middleware: {
handleDiagnostics() {
// leave all error reporting to the Docker Language Server
return [];
},
workspace: {
configuration: (params) => {
return params.items.map((value) => {
if (value.section === 'docker.languageserver.formatter') {
return { ignoreMultilineInstructions: true };
}
return {};
});
},
},
},
},
);
dockerfileLanguageClient.registerProposedFeatures();
await dockerfileLanguageClient.start();
ctx.subscriptions.push(dockerfileLanguageClient);
}
export async function activateDockerNativeLanguageClient(
ctx: vscode.ExtensionContext,
): Promise<boolean> {
if (
vscode.extensions.getExtension('ms-azuretools.vscode-docker') ===
undefined &&
vscode.extensions.getExtension('ms-azuretools.vscode-containers') ===
undefined
) {
// start the Dockerfile Language Server if Microsoft's extensions are not installed
await startDockerfileLanguageServer(ctx);
}
if (await createNative(ctx)) {
registerSettingsToggleCodeActions();
ctx.subscriptions.push(nativeClient);

View File

@ -2,7 +2,8 @@ import * as vscode from 'vscode';
type DockerExtensionSettings =
| 'dockerEngineAvailabilityPrompt'
| 'enableComposeLanguageServer';
| 'enableComposeLanguageServer'
| 'enableBuildDebugging';
/**
* Retrieves the value of a specified setting from the Docker extension's configuration.
@ -10,9 +11,8 @@ type DockerExtensionSettings =
* @param setting - The name of the setting to retrieve.
* @returns The value of the specified setting, or `undefined` if the setting is not found.
*/
export function getExtensionSetting(setting: DockerExtensionSettings) {
return vscode.workspace.getConfiguration('docker.extension').get(setting);
export function getExtensionSetting<T>(setting: DockerExtensionSettings) {
return vscode.workspace.getConfiguration('docker.extension').get<T>(setting);
}
export function inspectExtensionSetting(setting: DockerExtensionSettings) {

View File

@ -3,5 +3,6 @@
"git.autoRepositoryDetection": false,
"telemetry.telemetryLevel": "off",
"workbench.editor.enablePreview": false,
"workbench.secondarySideBar.defaultVisibility": "hidden",
"workbench.startupEditor": "none"
}

15
test/workspace/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
ARG FOO="init"
ARG AAA="init"
FROM busybox AS build1
RUN echo hello > /hello
FROM busybox AS build2
ARG FOO
ARG AAA
RUN echo hi > /hi && cat /fail
FROM scratch
COPY --from=build1 /hello /
RUN cat fail > /
COPY --from=build2 /hi /

View File

@ -12,11 +12,15 @@ const extensionConfig = {
target: 'node', // VS Code extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
entry: {
'./extension': './src/extension.ts',
'./dockerfile-language-server-nodejs/lib/server':
'./node_modules/dockerfile-language-server-nodejs/lib/server.js',
}, // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: {
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
filename: '[name].js',
libraryTarget: 'commonjs2',
},
stats: {
@ -47,6 +51,11 @@ const extensionConfig = {
},
],
},
{
// Unpack UMD module headers used in some modules since webpack doesn't handle them.
test: /dockerfile-language-service|vscode-languageserver-types/,
use: { loader: 'umd-compat-loader' },
},
],
},
devtool: 'nosources-source-map',