Skip to content

Commit 9185b0b

Browse files
committed
Modify scripts to use fnndsc/utils container
1 parent c607b7a commit 9185b0b

File tree

7 files changed

+68
-39
lines changed

7 files changed

+68
-39
lines changed

README.md

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,8 @@ npm ci
7171

7272
No extra dependencies are required when using the "public" server.
7373

74-
If you intend on developing with the "local" server, you need to install extra dependencies which are used for downloading sample data files and utility scripts. These dependencies are:
75-
76-
- [GNU coreutils](https://www.gnu.org/software/coreutils/)
77-
- [GNU bash](https://www.gnu.org/software/bash/)
78-
- [GNU parallel](https://www.gnu.org/software/parallel/)
79-
- [GNU make](https://www.gnu.org/software/make/)
80-
- [find](https://www.gnu.org/software/findutils/)
81-
- [curl](https://curl.se/)
82-
83-
Here are the installation instructions for various Linux distros.
84-
85-
```shell
86-
# for Ubuntu, Debian
87-
sudo apt install -y make parallel curl
88-
89-
# for Arch Linux
90-
sudo pacman -S make parallel curl
91-
92-
# for NixOS or home-manger
93-
nix-shell -p coreutils findutils bash gnumake parallel curl
94-
95-
# MacOS or Linux using homebrew
96-
brew install coreutils findutils bash make parallel curl
97-
```
74+
If you intend on developing with the "local" server, you will need **Docker** and Docker Compose
75+
to run the backend and helper scripts.
9876

9977
### 2. Run the development server
10078

biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://biomejs.dev/schemas/1.1.2/schema.json",
33
"files": {
4-
"include": ["src/**", "tests/**", "./*.{ts,json}"],
4+
"include": ["src/**", "tests/**", "./*.ts", "./*.json", "testing/*.mjs"],
55
"ignore": ["package-lock.json"]
66
},
77
"organizeImports": {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"minichris:down": "cd testing/miniChRIS && ./unmake.sh",
2626
"minichris:wipe": "./testing/miniChRIS/scripts/clear_pacsfiles.sh",
2727
"chrisomatic": "testing/chrisomatic.sh",
28-
"get-dicoms": "./testing/get_dicoms.sh",
28+
"get-dicoms": "./testing/getDicoms.mjs",
2929
"list-mrns": "./testing/miniChRIS/scripts/list_mrns.sh",
3030
"lint": "biome lint .",
3131
"fix": "biome check --apply .",

testing/getDicoms.mjs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env node
2+
// Purpose: download sample DICOM files and upload them to Orthanc.
3+
4+
import * as childProcess from "node:child_process";
5+
import * as os from "node:os";
6+
import * as path from "node:path";
7+
8+
const UTILS_IMAGE = "ghcr.io/fnndsc/utils:fc56615";
9+
10+
function main() {
11+
runUtils("testing/sample_dicoms", ["make", "neuro"]);
12+
runUtils("testing", [
13+
"./miniChRIS/scripts/upload2orthanc.sh",
14+
"./sample_dicoms/data",
15+
]);
16+
}
17+
18+
main();
19+
20+
/**
21+
* Run a command using docker in the utils image.
22+
*
23+
* @param workDir {string} relative working directory
24+
* @param args {string[]} command to run
25+
*/
26+
function runUtils(workDir, args) {
27+
const { uid, gid } = os.userInfo();
28+
childProcess.execFileSync(
29+
"docker",
30+
[
31+
"run",
32+
"--rm",
33+
...getTtyArgs(),
34+
"--net=host",
35+
"-u",
36+
`${uid}:${gid}`,
37+
"-v",
38+
`${getHere()}:/ChRIS_ui`,
39+
"-w",
40+
path.join("/ChRIS_ui", workDir),
41+
UTILS_IMAGE,
42+
...args,
43+
],
44+
{ stdio: "inherit" },
45+
);
46+
}
47+
48+
/**
49+
* @returns {string} the directory of the NPM project
50+
*/
51+
function getHere() {
52+
return childProcess
53+
.execFileSync("npm", ["prefix"], { encoding: "utf-8" })
54+
.trim();
55+
}
56+
57+
/**
58+
* @returns {string[]} tty-related flags to use for `docker run`
59+
*/
60+
function getTtyArgs() {
61+
return process.env.GITHUB_CI ? [] : ["-t"];
62+
}

testing/get_dicoms.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)