Skip to content

Commit dca9600

Browse files
committed
docs
1 parent dcc54f7 commit dca9600

File tree

4 files changed

+327
-163
lines changed

4 files changed

+327
-163
lines changed

docs/src/components/BuildConfigTool.astro

Lines changed: 69 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,37 @@ const configOptions: ConfigOption[] = [
8383
type: "select",
8484
allowCustom: true,
8585
},
86+
{
87+
variable: "qbt_docker_volume",
88+
label: "Docker Volume Mapping",
89+
description: "Volume mapping for Docker container (host:container format)",
90+
defaultVal: "~/qbt:/root",
91+
options: [
92+
{
93+
value: "~/qbt:/root",
94+
label: "~/qbt:/root",
95+
description: "Default volume mapping to home directory",
96+
},
97+
{
98+
value: "./qbt:/root",
99+
label: "./qbt:/root",
100+
description: "Current directory volume mapping",
101+
},
102+
{
103+
value: "/tmp/qbt:/root",
104+
label: "/tmp/qbt:/root",
105+
description: "Temporary directory volume mapping",
106+
},
107+
{
108+
value: "custom",
109+
label: "Custom...",
110+
description: "Enter custom volume mapping",
111+
},
112+
],
113+
category: "basic",
114+
type: "select",
115+
allowCustom: true,
116+
},
86117
{
87118
variable: "qbt_libtorrent_version",
88119
label: "Libtorrent Version",
@@ -1047,7 +1078,7 @@ const advancedOptions = configOptions.filter(
10471078
<div class="config-options">
10481079
{
10491080
basicOptions.map((option) => (
1050-
<div class="config-option" data-docker-only={option.variable === "qbt_docker_base" || option.variable === "qbt_docker_port" ? "true" : undefined}>
1081+
<div class="config-option" data-docker-only={option.variable === "qbt_docker_base" || option.variable === "qbt_docker_port" || option.variable === "qbt_docker_volume" ? "true" : undefined}>
10511082
<div class="option-info">
10521083
<h4>{option.label}</h4>
10531084
</div>
@@ -1310,7 +1341,7 @@ const advancedOptions = configOptions.filter(
13101341
const currentValue = getSelectValue(select);
13111342

13121343
// Skip invalid or Docker-specific variables for native builds
1313-
if (!variable || variable === "qbt_docker_base" || variable === "qbt_docker_port") {
1344+
if (!variable || variable === "qbt_docker_base" || variable === "qbt_docker_port" || variable === "qbt_docker_volume") {
13141345
return;
13151346
}
13161347

@@ -1369,7 +1400,7 @@ const advancedOptions = configOptions.filter(
13691400
const currentValue = getSelectValue(select);
13701401

13711402
// Skip invalid or Docker-specific variables for native builds
1372-
if (!variable || variable === "qbt_docker_base" || variable === "qbt_docker_port") {
1403+
if (!variable || variable === "qbt_docker_base" || variable === "qbt_docker_port" || variable === "qbt_docker_volume") {
13731404
return;
13741405
}
13751406

@@ -1384,15 +1415,19 @@ const advancedOptions = configOptions.filter(
13841415
}
13851416
});
13861417

1418+
// Add download and chmod commands
1419+
const downloadCommands = `curl -sL usrdx.github.io/s/qbt.bash -o qbt.bash && \\
1420+
chmod +x qbt.bash`;
1421+
13871422
if (envVars.length === 0) {
1388-
return baseCommand;
1423+
return `${downloadCommands}\n${baseCommand}`;
13891424
}
13901425

13911426
// Format with line breaks using backslashes
13921427
const envVarsFormatted = envVars
13931428
.map((envVar) => `${envVar} \\`)
13941429
.join("\n");
1395-
return `${envVarsFormatted}\n${baseCommand}`;
1430+
return `${downloadCommands}\n${envVarsFormatted}\n${baseCommand}`;
13961431
}
13971432

13981433
function generateDockerCommand() {
@@ -1413,6 +1448,7 @@ const advancedOptions = configOptions.filter(
14131448
let packageManager = "apk update && apk add bash git curl";
14141449
let shell = "/bin/ash";
14151450
let portMapping = "8080:8080";
1451+
let volumeMapping = "~/qbt:/root";
14161452

14171453
selects.forEach((select) => {
14181454
const variable = select.dataset.variable;
@@ -1443,6 +1479,12 @@ const advancedOptions = configOptions.filter(
14431479
return; // Don't include this in env vars
14441480
}
14451481

1482+
// Handle volume mapping selection
1483+
if (variable === "qbt_docker_volume") {
1484+
volumeMapping = currentValue || defaultValue || "~/qbt:/root";
1485+
return; // Don't include this in env vars
1486+
}
1487+
14461488
// Only include variables that differ from default and are not empty
14471489
if (
14481490
currentValue !== defaultValue &&
@@ -1456,7 +1498,7 @@ const advancedOptions = configOptions.filter(
14561498
if (envVars.length === 0) {
14571499
return `docker run -it -w /root \\
14581500
\t-p ${portMapping} \\
1459-
\t-v ~/qbt:/root \\
1501+
\t-v ${volumeMapping} \\
14601502
\t${baseImage} ${shell} -c \\
14611503
\t'${packageManager} && \\
14621504
\t${scriptCommand}'`;
@@ -1468,7 +1510,7 @@ const advancedOptions = configOptions.filter(
14681510
.join("\n");
14691511
return `docker run -it -w /root \\
14701512
\t-p ${portMapping} \\
1471-
\t-v ~/qbt:/root \\
1513+
\t-v ${volumeMapping} \\
14721514
\t${baseImage} ${shell} -c \\
14731515
\t'${packageManager} && \\
14741516
${envVarsFormatted}
@@ -1493,6 +1535,7 @@ ${envVarsFormatted}
14931535
let packageManager = "apk update && apk add bash git curl";
14941536
let shell = "/bin/ash";
14951537
let portMapping = "8080:8080";
1538+
let volumeMapping = "~/qbt:/root";
14961539

14971540
selects.forEach((select) => {
14981541
const variable = select.dataset.variable;
@@ -1523,6 +1566,12 @@ ${envVarsFormatted}
15231566
return; // Don't include this in env vars
15241567
}
15251568

1569+
// Handle volume mapping selection
1570+
if (variable === "qbt_docker_volume") {
1571+
volumeMapping = currentValue || defaultValue || "~/qbt:/root";
1572+
return; // Don't include this in env vars
1573+
}
1574+
15261575
// Only include variables that differ from default and are not empty
15271576
if (
15281577
currentValue !== defaultValue &&
@@ -1533,11 +1582,16 @@ ${envVarsFormatted}
15331582
}
15341583
});
15351584

1585+
// Extract local directory from volume mapping (part before the colon)
1586+
const localDir = volumeMapping.split(':')[0];
1587+
15361588
if (envVars.length === 0) {
1537-
return `docker run -it -w /root \\
1589+
return `curl --create-dirs -sL usrdx.github.io/s/qbt.bash -o ${localDir}/qbt.bash && \\
1590+
chmod +x ${localDir}/qbt.bash && \\
1591+
docker run -it -w /root \\
15381592
\t-p ${portMapping} \\
1539-
\t-v ~/qbt:/root \\
1540-
\t-v ./qbt.bash:/root/qbt.bash \\
1593+
\t-v ${volumeMapping} \\
1594+
\t-v ${localDir}/qbt.bash:/root/qbt.bash \\
15411595
\t${baseImage} ${shell} -c \\
15421596
\t'${packageManager} && \\
15431597
\t${scriptCommand}'`;
@@ -1547,10 +1601,12 @@ ${envVarsFormatted}
15471601
const envVarsFormatted = envVars
15481602
.map((envVar) => `\t${envVar} \\`)
15491603
.join("\n");
1550-
return `docker run -it -w /root \\
1604+
return `curl --create-dirs -sL usrdx.github.io/s/qbt.bash -o ${localDir}/qbt.bash && \\
1605+
chmod +x ${localDir}/qbt.bash && \\
1606+
docker run -it -w /root \\
15511607
\t-p ${portMapping} \\
1552-
\t-v ~/qbt:/root \\
1553-
\t-v ./qbt.bash:/root/qbt.bash \\
1608+
\t-v ${volumeMapping} \\
1609+
\t-v ${localDir}/qbt.bash:/root/qbt.bash \\
15541610
\t${baseImage} ${shell} -c \\
15551611
\t'${packageManager} && \\
15561612
${envVarsFormatted}

0 commit comments

Comments
 (0)