Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add dockerRunArgs setting #52

Merged
merged 3 commits into from
Jul 24, 2024
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.7.2]

### Added

* Added `dockerRunArgs` setting.

## [0.7.1]

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ This extension contributes the following settings:
* `ledgerDevTools.onboardingPin`: Set the device quick onboarding PIN code.
* `ledgerDevTools.onboardingSeed`: Set the device quick onboarding 24-word Seed phrase.
* `ledgerDevTools.dockerImage`: Set the Ledger developer tools Docker image.
* `ledgerDevTools.dockerRunArgs`: Any additional command line args to pass to the `docker run` command for the Ledger developer tools Docker image.
* `ledgerDevTools.additionalReqsPerApp`: Add prerequisites for current app's functional tests (for instance 'apk add python3-protobuf').
* `ledgerDevTools.keepTerminal`: Indicates to keep the Terminal window opened after a successful task execution.
* `ledgerDevTools.containerUpdateRetries`: Set the max number of Container Update retries.
Expand All @@ -72,6 +73,10 @@ This extension contributes the following settings:

## Release Notes

## 0.7.2

* Added `dockerRunArgs` setting.

## 0.7.1

* Fix regression on AppName detection on Windows platform
Expand Down
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ledger-dev-tools",
"displayName": "Ledger Dev Tools",
"description": "Tools to accelerate development of apps for Ledger devices.",
"version": "0.7.1",
"version": "0.7.2",
"publisher": "LedgerHQ",
"license": "Apache",
"icon": "resources/ledger-square.png",
Expand Down Expand Up @@ -165,6 +165,12 @@
"default": "ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest",
"description": "Ledger developer tools Docker image."
},
"ledgerDevTools.dockerRunArgs": {
"type": "string",
"scope": "resource",
"default": "",
"description": "Additional arguments to pass to the 'docker run' command for the Ledger developer tools Docker image."
agrojean-ledger marked this conversation as resolved.
Show resolved Hide resolved
},
"ledgerDevTools.onboardingPin": {
"type": "string",
"default": "1234",
Expand Down
11 changes: 8 additions & 3 deletions src/taskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class TaskProvider implements vscode.TaskProvider {
private packageName?: string;
private tasks: MyTask[] = [];
private currentApp?: App;
private dockerRunArgs: string = "";
private taskSpecs: TaskSpec[] = [
{
group: "Docker Container",
Expand Down Expand Up @@ -244,6 +245,10 @@ export class TaskProvider implements vscode.TaskProvider {
this.buildDir = this.currentApp.buildDirPath;
this.workspacePath = this.currentApp.folderUri.path;
this.packageName = this.currentApp.packageName;

const appConf = vscode.workspace.getConfiguration("ledgerDevTools", this.appFolderUri);
this.dockerRunArgs = appConf.get<string>("dockerRunArgs") || "";

this.checkDisabledTasks();
this.pushAllTasks();
this.treeProvider.addAllTasksToTree(this.taskSpecs);
Expand Down Expand Up @@ -280,14 +285,14 @@ export class TaskProvider implements vscode.TaskProvider {
// Checks if a container with the name ${this.containerName} exists, and if it does, it is stopped and removed before a new container is created using the same name and other specified configuration parameters
if (platform === "linux") {
// Linux
exec = `docker ps -a --format '{{.Names}}' | grep -q ${this.containerName} && (docker container stop ${this.containerName} && docker container rm ${this.containerName}) ; docker pull ${this.image} && docker run --user $(id -u):$(id -g) --privileged -e DISPLAY=$DISPLAY -v '/dev/bus/usb:/dev/bus/usb' -v '/tmp/.X11-unix:/tmp/.X11-unix' -v '${this.workspacePath}:/app' -t -d --name ${this.containerName} ${this.image}`;
exec = `docker ps -a --format '{{.Names}}' | grep -q ${this.containerName} && (docker container stop ${this.containerName} && docker container rm ${this.containerName}) ; docker pull ${this.image} && docker run --user $(id -u):$(id -g) --privileged -e DISPLAY=$DISPLAY -v '/dev/bus/usb:/dev/bus/usb' -v '/tmp/.X11-unix:/tmp/.X11-unix' -v '${this.workspacePath}:/app' ${this.dockerRunArgs} -t -d --name ${this.containerName} ${this.image}`;
} else if (platform === "darwin") {
// macOS
exec = `xhost + ; docker ps -a --format '{{.Names}}' | grep -q ${this.containerName} && (docker container stop ${this.containerName} && docker container rm ${this.containerName}) ; docker pull ${this.image} && docker run --user $(id -u):$(id -g) --privileged -e DISPLAY='host.docker.internal:0' -v '/tmp/.X11-unix:/tmp/.X11-unix' -v '${this.workspacePath}:/app' -t -d --name ${this.containerName} ${this.image}`;
exec = `xhost + ; docker ps -a --format '{{.Names}}' | grep -q ${this.containerName} && (docker container stop ${this.containerName} && docker container rm ${this.containerName}) ; docker pull ${this.image} && docker run --user $(id -u):$(id -g) --privileged -e DISPLAY='host.docker.internal:0' -v '/tmp/.X11-unix:/tmp/.X11-unix' -v '${this.workspacePath}:/app' ${this.dockerRunArgs} -t -d --name ${this.containerName} ${this.image}`;
} else {
// Assume windows
const winWorkspacePath = this.workspacePath.substring(1); // Remove first '/' from windows workspace path URI. Otherwise it is not valid.
exec = `if (docker ps -a --format '{{.Names}}' | Select-String -Quiet ${this.containerName}) { docker container stop ${this.containerName}; docker container rm ${this.containerName} }; docker pull ${this.image}; docker run --privileged -e DISPLAY='host.docker.internal:0' -v '${winWorkspacePath}:/app' -t -d --name ${this.containerName} ${this.image}`;
exec = `if (docker ps -a --format '{{.Names}}' | Select-String -Quiet ${this.containerName}) { docker container stop ${this.containerName}; docker container rm ${this.containerName} }; docker pull ${this.image}; docker run --privileged -e DISPLAY='host.docker.internal:0' -v '${winWorkspacePath}:/app' ${this.dockerRunArgs} -t -d --name ${this.containerName} ${this.image}`;
}
}

Expand Down