添加 docker runsh 命令
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const assert = require("assert");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { buildScript } = require("./restore-run");
|
||||
|
||||
const inspectPath = path.join(__dirname, "testcase-inspect.json");
|
||||
const expectedPath = path.join(__dirname, "testcase-run.sh");
|
||||
|
||||
const inspectData = JSON.parse(fs.readFileSync(inspectPath, "utf8"));
|
||||
const info = Array.isArray(inspectData) ? inspectData[0] : inspectData;
|
||||
const actual = buildScript(info);
|
||||
const expected = fs.readFileSync(expectedPath, "utf8").replace(/\r\n/g, "\n");
|
||||
|
||||
assert.strictEqual(actual, expected);
|
||||
assert.ok(actual.includes("name=freshrss"));
|
||||
assert.ok(actual.includes("img=freshrss/freshrss:latest"));
|
||||
assert.ok(actual.includes('-v "$(pwd)/data:/var/www/FreshRSS/data"'));
|
||||
assert.ok(actual.includes('-v "$(pwd)/extensions:/var/www/FreshRSS/extensions"'));
|
||||
assert.strictEqual((actual.match(/-p 8082:80\/tcp/g) || []).length, 1);
|
||||
|
||||
console.log("restore-run testcase passed");
|
||||
@@ -0,0 +1,272 @@
|
||||
[
|
||||
{
|
||||
"Id": "71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338",
|
||||
"Created": "2026-06-09T08:40:16.386743045Z",
|
||||
"Path": "./Docker/entrypoint.sh",
|
||||
"Args": [
|
||||
"/bin/bash",
|
||||
"-o",
|
||||
"pipefail",
|
||||
"-c",
|
||||
"([ -z \"$CRON_MIN\" ] || cron) && \t. /etc/apache2/envvars && \texec apache2 -D FOREGROUND $([ -n \"$OIDC_ENABLED\" ] && [ \"$OIDC_ENABLED\" -ne 0 ] && echo \"-D OIDC_ENABLED\")"
|
||||
],
|
||||
"State": {
|
||||
"Status": "running",
|
||||
"Running": true,
|
||||
"Paused": false,
|
||||
"Restarting": false,
|
||||
"OOMKilled": false,
|
||||
"Dead": false,
|
||||
"Pid": 2178,
|
||||
"ExitCode": 0,
|
||||
"Error": "",
|
||||
"StartedAt": "2026-06-11T03:36:17.818299057Z",
|
||||
"FinishedAt": "2026-06-11T03:36:11.0220238Z"
|
||||
},
|
||||
"Image": "sha256:fc6e4cf934a2d62c5da897c9fd011ef29dc3c83948ef3581d2a526fc90789622",
|
||||
"ResolvConfPath": "/var/lib/docker/containers/71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338/resolv.conf",
|
||||
"HostnamePath": "/var/lib/docker/containers/71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338/hostname",
|
||||
"HostsPath": "/var/lib/docker/containers/71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338/hosts",
|
||||
"LogPath": "/var/lib/docker/containers/71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338/71ba6f6111c86b9cc72fd144717357a40a3c472794bae99cc17b7fd887648338-json.log",
|
||||
"Name": "/freshrss",
|
||||
"RestartCount": 0,
|
||||
"Driver": "overlay2",
|
||||
"Platform": "linux",
|
||||
"MountLabel": "",
|
||||
"ProcessLabel": "",
|
||||
"AppArmorProfile": "docker-default",
|
||||
"ExecIDs": null,
|
||||
"HostConfig": {
|
||||
"Binds": [
|
||||
"/app/freshrss/extensions:/var/www/FreshRSS/extensions",
|
||||
"/app/freshrss/data:/var/www/FreshRSS/data"
|
||||
],
|
||||
"ContainerIDFile": "",
|
||||
"LogConfig": {
|
||||
"Type": "json-file",
|
||||
"Config": {
|
||||
"max-file": "3",
|
||||
"max-size": "10m"
|
||||
}
|
||||
},
|
||||
"NetworkMode": "bridge",
|
||||
"PortBindings": {
|
||||
"80/tcp": [
|
||||
{
|
||||
"HostIp": "",
|
||||
"HostPort": "8082"
|
||||
}
|
||||
]
|
||||
},
|
||||
"RestartPolicy": {
|
||||
"Name": "unless-stopped",
|
||||
"MaximumRetryCount": 0
|
||||
},
|
||||
"AutoRemove": false,
|
||||
"VolumeDriver": "",
|
||||
"VolumesFrom": null,
|
||||
"ConsoleSize": [
|
||||
30,
|
||||
118
|
||||
],
|
||||
"CapAdd": null,
|
||||
"CapDrop": null,
|
||||
"CgroupnsMode": "private",
|
||||
"Dns": [],
|
||||
"DnsOptions": [],
|
||||
"DnsSearch": [],
|
||||
"ExtraHosts": null,
|
||||
"GroupAdd": null,
|
||||
"IpcMode": "private",
|
||||
"Cgroup": "",
|
||||
"Links": null,
|
||||
"OomScoreAdj": 0,
|
||||
"PidMode": "",
|
||||
"Privileged": false,
|
||||
"PublishAllPorts": false,
|
||||
"ReadonlyRootfs": false,
|
||||
"SecurityOpt": null,
|
||||
"UTSMode": "",
|
||||
"UsernsMode": "",
|
||||
"ShmSize": 67108864,
|
||||
"Runtime": "runc",
|
||||
"Isolation": "",
|
||||
"CpuShares": 0,
|
||||
"Memory": 0,
|
||||
"NanoCpus": 0,
|
||||
"CgroupParent": "",
|
||||
"BlkioWeight": 0,
|
||||
"BlkioWeightDevice": [],
|
||||
"BlkioDeviceReadBps": [],
|
||||
"BlkioDeviceWriteBps": [],
|
||||
"BlkioDeviceReadIOps": [],
|
||||
"BlkioDeviceWriteIOps": [],
|
||||
"CpuPeriod": 0,
|
||||
"CpuQuota": 0,
|
||||
"CpuRealtimePeriod": 0,
|
||||
"CpuRealtimeRuntime": 0,
|
||||
"CpusetCpus": "",
|
||||
"CpusetMems": "",
|
||||
"Devices": [],
|
||||
"DeviceCgroupRules": null,
|
||||
"DeviceRequests": null,
|
||||
"MemoryReservation": 0,
|
||||
"MemorySwap": 0,
|
||||
"MemorySwappiness": null,
|
||||
"OomKillDisable": null,
|
||||
"PidsLimit": null,
|
||||
"Ulimits": [],
|
||||
"CpuCount": 0,
|
||||
"CpuPercent": 0,
|
||||
"IOMaximumIOps": 0,
|
||||
"IOMaximumBandwidth": 0,
|
||||
"MaskedPaths": [
|
||||
"/proc/asound",
|
||||
"/proc/acpi",
|
||||
"/proc/kcore",
|
||||
"/proc/keys",
|
||||
"/proc/latency_stats",
|
||||
"/proc/timer_list",
|
||||
"/proc/timer_stats",
|
||||
"/proc/sched_debug",
|
||||
"/proc/scsi",
|
||||
"/sys/firmware",
|
||||
"/sys/devices/virtual/powercap"
|
||||
],
|
||||
"ReadonlyPaths": [
|
||||
"/proc/bus",
|
||||
"/proc/fs",
|
||||
"/proc/irq",
|
||||
"/proc/sys",
|
||||
"/proc/sysrq-trigger"
|
||||
]
|
||||
},
|
||||
"GraphDriver": {
|
||||
"Data": {
|
||||
"LowerDir": "/var/lib/docker/overlay2/d9852f484fa657d12db8ed58e4f61fa9d937a63b2c02326bc859aa03f3c6a6f9-init/diff:/var/lib/docker/overlay2/e16b5110bbde48cd9070a8bea52ca1b49a6c7a6ae17abc23bc2f2152aa851dbb/diff:/var/lib/docker/overlay2/6d104177f8014ee6b291525597ac93c48cce1d6e3f45f8390330dbee8f536d89/diff:/var/lib/docker/overlay2/640758ad6ad59ac4f5825afc463879a4da93264dcbe96cfd06653d494689b1c4/diff:/var/lib/docker/overlay2/51e3461fd7fed56b0595c7c83e8c0edd6a67ae72ef9a59d2a29d6bb808847204/diff:/var/lib/docker/overlay2/b7de361f0da3dea53c4bcc25a9bbde40efaaf7933147da3b95ed8e7d4d718ad4/diff:/var/lib/docker/overlay2/1ee479d5e4ed919312b4792bec9fd9a2425ee199b4b7ff911572f272b2ba2449/diff:/var/lib/docker/overlay2/4d45f37889ffe243f232f86582a4c3b8125b13b397cacfc0193a79af39158190/diff",
|
||||
"MergedDir": "/var/lib/docker/overlay2/d9852f484fa657d12db8ed58e4f61fa9d937a63b2c02326bc859aa03f3c6a6f9/merged",
|
||||
"UpperDir": "/var/lib/docker/overlay2/d9852f484fa657d12db8ed58e4f61fa9d937a63b2c02326bc859aa03f3c6a6f9/diff",
|
||||
"WorkDir": "/var/lib/docker/overlay2/d9852f484fa657d12db8ed58e4f61fa9d937a63b2c02326bc859aa03f3c6a6f9/work"
|
||||
},
|
||||
"Name": "overlay2"
|
||||
},
|
||||
"Mounts": [
|
||||
{
|
||||
"Type": "bind",
|
||||
"Source": "/app/freshrss/data",
|
||||
"Destination": "/var/www/FreshRSS/data",
|
||||
"Mode": "",
|
||||
"RW": true,
|
||||
"Propagation": "rprivate"
|
||||
},
|
||||
{
|
||||
"Type": "bind",
|
||||
"Source": "/app/freshrss/extensions",
|
||||
"Destination": "/var/www/FreshRSS/extensions",
|
||||
"Mode": "",
|
||||
"RW": true,
|
||||
"Propagation": "rprivate"
|
||||
}
|
||||
],
|
||||
"Config": {
|
||||
"Hostname": "71ba6f6111c8",
|
||||
"Domainname": "",
|
||||
"User": "",
|
||||
"AttachStdin": false,
|
||||
"AttachStdout": false,
|
||||
"AttachStderr": false,
|
||||
"ExposedPorts": {
|
||||
"80/tcp": {}
|
||||
},
|
||||
"Tty": false,
|
||||
"OpenStdin": false,
|
||||
"StdinOnce": false,
|
||||
"Env": [
|
||||
"TZ=Asia/Shanghai",
|
||||
"CRON_MIN=*/30",
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"COPY_LOG_TO_SYSLOG=On",
|
||||
"COPY_SYSLOG_TO_STDERR=On",
|
||||
"DATA_PATH=",
|
||||
"FRESHRSS_ENV=",
|
||||
"LISTEN=",
|
||||
"OIDC_ENABLED=",
|
||||
"TRUSTED_PROXY="
|
||||
],
|
||||
"Cmd": [
|
||||
"/bin/bash",
|
||||
"-o",
|
||||
"pipefail",
|
||||
"-c",
|
||||
"([ -z \"$CRON_MIN\" ] || cron) && \t. /etc/apache2/envvars && \texec apache2 -D FOREGROUND $([ -n \"$OIDC_ENABLED\" ] && [ \"$OIDC_ENABLED\" -ne 0 ] && echo \"-D OIDC_ENABLED\")"
|
||||
],
|
||||
"Image": "freshrss/freshrss:latest",
|
||||
"Volumes": null,
|
||||
"WorkingDir": "/var/www/FreshRSS",
|
||||
"Entrypoint": [
|
||||
"./Docker/entrypoint.sh"
|
||||
],
|
||||
"OnBuild": null,
|
||||
"Labels": {
|
||||
"org.opencontainers.image.created": "2026-05-20T17:58:29.110Z",
|
||||
"org.opencontainers.image.description": "A free, self-hostable news aggregator…",
|
||||
"org.opencontainers.image.documentation": "https://freshrss.github.io/FreshRSS/",
|
||||
"org.opencontainers.image.licenses": "AGPL-3.0",
|
||||
"org.opencontainers.image.revision": "b2c50115baa36c217e939ee3ea8ecfae52f91abd",
|
||||
"org.opencontainers.image.source": "https://github.com/FreshRSS/FreshRSS",
|
||||
"org.opencontainers.image.title": "FreshRSS",
|
||||
"org.opencontainers.image.url": "https://freshrss.org/",
|
||||
"org.opencontainers.image.vendor": "FreshRSS",
|
||||
"org.opencontainers.image.version": "1.29.1"
|
||||
}
|
||||
},
|
||||
"NetworkSettings": {
|
||||
"Bridge": "",
|
||||
"SandboxID": "78f7f8cccc0810fcdadb3d0e7bff0fe16156a46ab4b0feb7a4ebd6e80e5e330d",
|
||||
"SandboxKey": "/var/run/docker/netns/78f7f8cccc08",
|
||||
"Ports": {
|
||||
"80/tcp": [
|
||||
{
|
||||
"HostIp": "0.0.0.0",
|
||||
"HostPort": "8082"
|
||||
},
|
||||
{
|
||||
"HostIp": "::",
|
||||
"HostPort": "8082"
|
||||
}
|
||||
]
|
||||
},
|
||||
"HairpinMode": false,
|
||||
"LinkLocalIPv6Address": "",
|
||||
"LinkLocalIPv6PrefixLen": 0,
|
||||
"SecondaryIPAddresses": null,
|
||||
"SecondaryIPv6Addresses": null,
|
||||
"EndpointID": "14c4ae2de08b7c68dfe8a757933088247f4c4ffd8c3d1236ff919da0422a655c",
|
||||
"Gateway": "172.17.0.1",
|
||||
"GlobalIPv6Address": "",
|
||||
"GlobalIPv6PrefixLen": 0,
|
||||
"IPAddress": "172.17.0.3",
|
||||
"IPPrefixLen": 16,
|
||||
"IPv6Gateway": "",
|
||||
"MacAddress": "02:42:ac:11:00:03",
|
||||
"Networks": {
|
||||
"bridge": {
|
||||
"IPAMConfig": null,
|
||||
"Links": null,
|
||||
"Aliases": null,
|
||||
"MacAddress": "02:42:ac:11:00:03",
|
||||
"DriverOpts": null,
|
||||
"NetworkID": "2e5dc7af2729566328476edc3fe4594e9f6b39adabbdcda5b7cc26fcbe073224",
|
||||
"EndpointID": "14c4ae2de08b7c68dfe8a757933088247f4c4ffd8c3d1236ff919da0422a655c",
|
||||
"Gateway": "172.17.0.1",
|
||||
"IPAddress": "172.17.0.3",
|
||||
"IPPrefixLen": 16,
|
||||
"IPv6Gateway": "",
|
||||
"GlobalIPv6Address": "",
|
||||
"GlobalIPv6PrefixLen": 0,
|
||||
"DNSNames": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
name=freshrss
|
||||
img=freshrss/freshrss:latest
|
||||
|
||||
docker run -d \
|
||||
--name "$name" \
|
||||
--restart unless-stopped \
|
||||
-w /var/www/FreshRSS \
|
||||
-e TZ=Asia/Shanghai \
|
||||
-e 'CRON_MIN=*/30' \
|
||||
-e PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
|
||||
-e COPY_LOG_TO_SYSLOG=On \
|
||||
-e COPY_SYSLOG_TO_STDERR=On \
|
||||
-e DATA_PATH= \
|
||||
-e FRESHRSS_ENV= \
|
||||
-e LISTEN= \
|
||||
-e OIDC_ENABLED= \
|
||||
-e TRUSTED_PROXY= \
|
||||
-p 8082:80/tcp \
|
||||
-v "$(pwd)/data:/var/www/FreshRSS/data" \
|
||||
-v "$(pwd)/extensions:/var/www/FreshRSS/extensions" \
|
||||
--entrypoint ./Docker/entrypoint.sh \
|
||||
"$img" /bin/bash -o pipefail -c '([ -z "$CRON_MIN" ] || cron) && . /etc/apache2/envvars && exec apache2 -D FOREGROUND $([ -n "$OIDC_ENABLED" ] && [ "$OIDC_ENABLED" -ne 0 ] && echo "-D OIDC_ENABLED")'
|
||||
@@ -11,6 +11,32 @@ async function createRemote() {
|
||||
return remote
|
||||
}
|
||||
|
||||
function writeFixtureProject(tempDir, version, content) {
|
||||
const projectDir = path.resolve(tempDir, `fixture-${version}`);
|
||||
fs.mkdirSync(projectDir, { recursive: true });
|
||||
|
||||
const filePath = path.resolve(projectDir, "myapp.txt");
|
||||
fs.writeFileSync(filePath, content, "utf-8");
|
||||
|
||||
fs.writeFileSync(path.resolve(projectDir, "meta.json"), JSON.stringify({
|
||||
id: "myapp",
|
||||
version,
|
||||
desc: "test app",
|
||||
official_url: "https://example.test/myapp",
|
||||
dist: [
|
||||
{
|
||||
path: filePath,
|
||||
os: "any",
|
||||
platform: "any",
|
||||
filename: "myapp.txt",
|
||||
type: "data"
|
||||
}
|
||||
]
|
||||
}, null, 4), "utf-8");
|
||||
|
||||
return projectDir;
|
||||
}
|
||||
|
||||
let tempDir;
|
||||
let localStore;
|
||||
|
||||
@@ -98,3 +124,4 @@ describe("remote module public API", () => {
|
||||
expect(fs.existsSync(path.resolve(localStore, "modules", "myapp", "versions", "1.0.0"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user