From 3e0a20b9d3812fe0e2b7b215869beb270d8eea2a Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Tue, 1 Aug 2023 21:07:37 +0000 Subject: [PATCH 1/5] update devcontainer config files --- .devcontainer/Dockerfile | 25 ----------- .devcontainer/devcontainer.json | 55 ++++++++++++------------- .devcontainer/installWPILibExtension.sh | 6 +++ 3 files changed, 32 insertions(+), 54 deletions(-) delete mode 100644 .devcontainer/Dockerfile create mode 100755 .devcontainer/installWPILibExtension.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index b2f10212..00000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/java/.devcontainer/base.Dockerfile - -# [Choice] Java version: 11, 16 -ARG VARIANT="16" -FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT} - -# [Option] Install Maven -ARG INSTALL_MAVEN="false" -ARG MAVEN_VERSION="" -# [Option] Install Gradle -ARG INSTALL_GRADLE="false" -ARG GRADLE_VERSION="" -RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \ - && if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi - -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="none" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 172c7662..2be099c0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,40 +1,37 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/java +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/java { "name": "Java", - "build": { - "dockerfile": "Dockerfile", - "args": { - // Update the VARIANT arg to pick a Java version: 11, 16 - "VARIANT": "11", - // Options - "INSTALL_MAVEN": "false", - "INSTALL_GRADLE": "false", - "NODE_VERSION": "none" - } - }, + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/java:1-17-bullseye", - // Set *default* container specific settings.json values on container create. - "settings": { - "java.home": "/docker-java-home" + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "false", + "installGradle": "true" + } }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "redhat.java", - "ms-vscode.cpptools", - "vcjava.vscode-java-debug", - "ms-toolsai.jupyter", - "vcjava.vscode-java-dependency", - "wpilibsuite.vscode-wpilib" - ], // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "java -version", + "postCreateCommand": "./.devcontainer/installWPILibExtension.sh", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "extensions": [ + "redhat.java", + "ms-vscode.cpptools", + "vcjava.vscode-java-debug", + "ms-toolsai.jupyter", + "vcjava.vscode-java-dependency" + ] + } + } - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" } diff --git a/.devcontainer/installWPILibExtension.sh b/.devcontainer/installWPILibExtension.sh new file mode 100755 index 00000000..6377bbdf --- /dev/null +++ b/.devcontainer/installWPILibExtension.sh @@ -0,0 +1,6 @@ +# Modified from ChatGPT suggestions +WPILIB_VSIX_URL=$(curl -s "https://api.github.com/repos/wpilibsuite/vscode-wpilib/releases/latest" | jq -r '.assets[] | select(.name | test(".vsix$")) | .browser_download_url') +INSTALL_LOCATION="/tmp/wpilib-extension/latest.vsix" +echo "$WPILIB_VSIX_URL" +curl --create-dirs -L -o "$INSTALL_LOCATION" "$WPILIB_VSIX_URL" +code --install-extension "$INSTALL_LOCATION" From ee63768d24f21eccd8a70d62b06f3ac1242daa17 Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Tue, 1 Aug 2023 21:18:43 +0000 Subject: [PATCH 2/5] use postStartCommand to install WPILib extension --- .devcontainer/devcontainer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2be099c0..c7472a62 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "./.devcontainer/installWPILibExtension.sh", + // "postCreateCommand": "", // Configure tool-specific properties. "customizations": { @@ -30,7 +30,9 @@ "vcjava.vscode-java-dependency" ] } - } + }, + + "postStartCommand": "./.devcontainer/installWPILibExtension.sh" // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" From fc185a084c0319ef5af5837d1cf9b96264d536a9 Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Tue, 1 Aug 2023 21:20:56 +0000 Subject: [PATCH 3/5] use postAttachCommand to install WPILib extension --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c7472a62..4caec834 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -32,7 +32,7 @@ } }, - "postStartCommand": "./.devcontainer/installWPILibExtension.sh" + "postAttachCommand": "./.devcontainer/installWPILibExtension.sh" // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" From b70b91ff92f9a645212d9231f49ad3d959fbe0a9 Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Tue, 1 Aug 2023 21:40:39 +0000 Subject: [PATCH 4/5] use bookworm container build --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4caec834..7960f823 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,7 +3,7 @@ { "name": "Java", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile - "image": "mcr.microsoft.com/devcontainers/java:1-17-bullseye", + "image": "mcr.microsoft.com/devcontainers/java:1-17-bookworm", "features": { "ghcr.io/devcontainers/features/java:1": { From ca245b8b5adaca75f7003a5b5b34f886f833554c Mon Sep 17 00:00:00 2001 From: CoolSpy3 Date: Tue, 1 Aug 2023 21:49:14 +0000 Subject: [PATCH 5/5] exit terminal after installing the WPILib extension --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7960f823..9ecad411 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -32,7 +32,7 @@ } }, - "postAttachCommand": "./.devcontainer/installWPILibExtension.sh" + "postAttachCommand": "./.devcontainer/installWPILibExtension.sh && exit" // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root"