@le-space/rootfs 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +20 -6
- package/package.json +1 -1
- package/reference/uc-go-peer/contract.json +58 -0
- package/reference/uc-go-peer/rootfs/Dockerfile.rootfs +24 -0
- package/reference/uc-go-peer/rootfs/build-rootfs-image.sh +94 -0
- package/reference/uc-go-peer/rootfs/build-rootfs.sh +489 -0
- package/reference/uc-go-peer/rootfs/read-rootfs-contract.py +72 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-autotls-refresh.py +144 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-autotls-refresh.service +23 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-bootstrap.service +17 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-bootstrap.sh +118 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-configure.sh +204 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-describe.py +195 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer-setup-server.py +221 -0
- package/reference/uc-go-peer/rootfs/uc-go-peer.service +19 -0
package/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// src/contract.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
2
3
|
import { readFile } from "fs/promises";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
4
5
|
function asObject(value) {
|
|
@@ -132,14 +133,27 @@ function contractShellEnv(contract, contractPath = "") {
|
|
|
132
133
|
ROOTFS_CONTRACT_PORT_FORWARDS_JSON: JSON.stringify(contract.ports)
|
|
133
134
|
};
|
|
134
135
|
}
|
|
136
|
+
function resolveReferencePath(profile, suffix = "") {
|
|
137
|
+
const candidates = [
|
|
138
|
+
new URL(`../reference/${profile}/${suffix}`, import.meta.url),
|
|
139
|
+
new URL(`./reference/${profile}/${suffix}`, import.meta.url)
|
|
140
|
+
];
|
|
141
|
+
for (const candidate of candidates) {
|
|
142
|
+
const resolved = fileURLToPath(candidate);
|
|
143
|
+
if (existsSync(resolved)) {
|
|
144
|
+
return resolved;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return fileURLToPath(candidates[0]);
|
|
148
|
+
}
|
|
135
149
|
function referenceProfileRoot(profile) {
|
|
136
|
-
return
|
|
150
|
+
return resolveReferencePath(profile);
|
|
137
151
|
}
|
|
138
152
|
function referenceProfileContractPath(profile) {
|
|
139
|
-
return
|
|
153
|
+
return resolveReferencePath(profile, "contract.json");
|
|
140
154
|
}
|
|
141
155
|
function referenceProfileRootfsDir(profile) {
|
|
142
|
-
return
|
|
156
|
+
return resolveReferencePath(profile, "rootfs/");
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
// src/build-plan.ts
|
|
@@ -307,7 +321,7 @@ function createHostRootfsExecutionPlan(plan, options = {}) {
|
|
|
307
321
|
reason: "Using host virt-customize/qemu-img toolchain.",
|
|
308
322
|
referenceRootfsDir,
|
|
309
323
|
runCommand: {
|
|
310
|
-
command: "bash",
|
|
324
|
+
command: "/bin/bash",
|
|
311
325
|
args: [path2.join(referenceRootfsDir, "build-rootfs-image.sh")],
|
|
312
326
|
workdir: referenceRootfsDir,
|
|
313
327
|
env: {
|
|
@@ -369,7 +383,7 @@ function createDockerRootfsExecutionPlan(plan, options = {}) {
|
|
|
369
383
|
"-w",
|
|
370
384
|
rootfsMountPath,
|
|
371
385
|
dockerImageTag,
|
|
372
|
-
"bash",
|
|
386
|
+
"/bin/bash",
|
|
373
387
|
path2.posix.join(rootfsMountPath, "build-rootfs-image.sh")
|
|
374
388
|
]
|
|
375
389
|
}
|
|
@@ -532,7 +546,7 @@ function rootfsScriptDir(buildPlan, override) {
|
|
|
532
546
|
function createRootfsScriptCommand(buildPlan, referenceRootfsDir) {
|
|
533
547
|
const scriptDir = rootfsScriptDir(buildPlan, referenceRootfsDir);
|
|
534
548
|
return {
|
|
535
|
-
command: "bash",
|
|
549
|
+
command: "/bin/bash",
|
|
536
550
|
args: [path3.join(scriptDir, "build-rootfs.sh")],
|
|
537
551
|
workdir: scriptDir,
|
|
538
552
|
env: rootfsBuildShellEnv(buildPlan)
|
package/package.json
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"id": "uc-go-peer",
|
|
4
|
+
"displayName": "Universal Connectivity Go Relay",
|
|
5
|
+
"source": {
|
|
6
|
+
"repository": "self",
|
|
7
|
+
"subdirectory": "go-peer"
|
|
8
|
+
},
|
|
9
|
+
"rootfs": {
|
|
10
|
+
"profile": "uc-go-peer",
|
|
11
|
+
"installMode": "prebaked",
|
|
12
|
+
"installDir": "/opt/go-peer",
|
|
13
|
+
"binaryPath": "/usr/local/bin/universal-chat-go",
|
|
14
|
+
"dataDir": "/var/lib/uc-go-peer",
|
|
15
|
+
"envFile": "/etc/default/uc-go-peer"
|
|
16
|
+
},
|
|
17
|
+
"services": {
|
|
18
|
+
"bootstrap": "uc-go-peer-bootstrap.service",
|
|
19
|
+
"main": "uc-go-peer.service",
|
|
20
|
+
"autotlsRefresh": "uc-go-peer-autotls-refresh.service"
|
|
21
|
+
},
|
|
22
|
+
"ports": [
|
|
23
|
+
{
|
|
24
|
+
"port": 22,
|
|
25
|
+
"tcp": true,
|
|
26
|
+
"udp": false,
|
|
27
|
+
"purpose": "SSH"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"port": 80,
|
|
31
|
+
"tcp": true,
|
|
32
|
+
"udp": false,
|
|
33
|
+
"purpose": "Temporary setup endpoint"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"port": 443,
|
|
37
|
+
"tcp": true,
|
|
38
|
+
"udp": false,
|
|
39
|
+
"purpose": "Caddy HTTPS and WSS proxy"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"port": 9097,
|
|
43
|
+
"tcp": true,
|
|
44
|
+
"udp": false,
|
|
45
|
+
"purpose": "libp2p secure websocket listener"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"port": 9095,
|
|
49
|
+
"tcp": true,
|
|
50
|
+
"udp": true,
|
|
51
|
+
"purpose": "libp2p raw TCP and UDP transports"
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
"manifest": {
|
|
55
|
+
"copyTarget": "js-peer/public/rootfs/uc-go-peer/latest.json",
|
|
56
|
+
"notes": "The go-peer image keeps the raw relay on internal port 9095, uses an internal plain websocket backend on 9096 for Caddy, exposes a dedicated internal secure websocket listener on 9097 for AutoTLS/direct WSS, advertises the actual Aleph host port mappings for direct TCP/UDP and AutoTLS websocket transports after deployment, and can optionally add a proxy-backed secure WebSocket address on port 443 via Caddy."
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
FROM debian:12
|
|
2
|
+
|
|
3
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
4
|
+
ENV LIBGUESTFS_BACKEND=direct
|
|
5
|
+
ARG GO_VERSION=1.25.4
|
|
6
|
+
ENV PATH=/usr/local/go/bin:${PATH}
|
|
7
|
+
|
|
8
|
+
RUN apt-get update \
|
|
9
|
+
&& apt-get install -y --no-install-recommends \
|
|
10
|
+
ca-certificates \
|
|
11
|
+
curl \
|
|
12
|
+
jq \
|
|
13
|
+
libguestfs-tools \
|
|
14
|
+
linux-image-amd64 \
|
|
15
|
+
python3 \
|
|
16
|
+
qemu-system-x86 \
|
|
17
|
+
qemu-utils \
|
|
18
|
+
tar \
|
|
19
|
+
&& curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" -o /tmp/go.tgz \
|
|
20
|
+
&& tar -C /usr/local -xzf /tmp/go.tgz \
|
|
21
|
+
&& rm -f /tmp/go.tgz \
|
|
22
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
23
|
+
|
|
24
|
+
WORKDIR /workspace/universal-connectivity/go-peer/aleph
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
5
|
+
ALEPH_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
6
|
+
PROJECT_DIR="${PROJECT_DIR:-$(cd "${SCRIPT_DIR}/../../.." && pwd)}"
|
|
7
|
+
ROOTFS_CONTRACT_FILE="${ROOTFS_CONTRACT_FILE:-${ALEPH_DIR}/root-profiles/uc-go-peer.json}"
|
|
8
|
+
OUT_DIR="${OUT_DIR:-${ALEPH_DIR}/dist-rootfs}"
|
|
9
|
+
BASE_URL="${BASE_URL:-https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2}"
|
|
10
|
+
BASE_IMAGE="${OUT_DIR}/debian-12-genericcloud-amd64.qcow2"
|
|
11
|
+
IMAGE="${OUT_DIR}/aleph-uc-go-peer.qcow2"
|
|
12
|
+
APP_BINARY="${OUT_DIR}/universal-chat-go"
|
|
13
|
+
ROOTFS_IMAGE_SIZE="${ROOTFS_IMAGE_SIZE:-20G}"
|
|
14
|
+
|
|
15
|
+
require() {
|
|
16
|
+
command -v "$1" >/dev/null 2>&1 || {
|
|
17
|
+
echo "Missing required command: $1" >&2
|
|
18
|
+
exit 1
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
require curl
|
|
23
|
+
require qemu-img
|
|
24
|
+
require virt-customize
|
|
25
|
+
require python3
|
|
26
|
+
require go
|
|
27
|
+
|
|
28
|
+
eval "$(python3 "${SCRIPT_DIR}/read-rootfs-contract.py" "${ROOTFS_CONTRACT_FILE}")"
|
|
29
|
+
|
|
30
|
+
ROOTFS_CONTRACT_BINARY_PATH="${ROOTFS_CONTRACT_BINARY_PATH:-/usr/local/bin/universal-chat-go}"
|
|
31
|
+
GUEST_APP_DIR="$(dirname "${ROOTFS_CONTRACT_BINARY_PATH}")"
|
|
32
|
+
|
|
33
|
+
if [ "${ROOTFS_CONTRACT_PROFILE}" != "uc-go-peer" ]; then
|
|
34
|
+
echo "Only the uc-go-peer rootfs profile is supported, got: ${ROOTFS_CONTRACT_PROFILE}" >&2
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
if [ "${ROOTFS_CONTRACT_INSTALL_MODE}" != "prebaked" ]; then
|
|
38
|
+
echo "Only prebaked install mode is supported, got: ${ROOTFS_CONTRACT_INSTALL_MODE}" >&2
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
if [ ! -d "${PROJECT_DIR}/go-peer" ]; then
|
|
42
|
+
echo "Missing go-peer directory: ${PROJECT_DIR}/go-peer" >&2
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
mkdir -p "${OUT_DIR}"
|
|
47
|
+
|
|
48
|
+
echo "Building uc-go-peer image in prebaked mode"
|
|
49
|
+
|
|
50
|
+
if [ ! -f "${BASE_IMAGE}" ]; then
|
|
51
|
+
curl -L "${BASE_URL}" -o "${BASE_IMAGE}"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
cp "${BASE_IMAGE}" "${IMAGE}"
|
|
55
|
+
qemu-img resize "${IMAGE}" "${ROOTFS_IMAGE_SIZE}"
|
|
56
|
+
|
|
57
|
+
echo "Building universal-chat-go outside the guest image"
|
|
58
|
+
(
|
|
59
|
+
cd "${PROJECT_DIR}/go-peer"
|
|
60
|
+
GOMODCACHE="${OUT_DIR}/gomodcache" \
|
|
61
|
+
GOCACHE="${OUT_DIR}/gocache" \
|
|
62
|
+
CGO_ENABLED=0 \
|
|
63
|
+
go build -ldflags="-w -s" -o "${APP_BINARY}" .
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
rm -rf "${OUT_DIR}/gomodcache" "${OUT_DIR}/gocache"
|
|
67
|
+
|
|
68
|
+
virt-customize \
|
|
69
|
+
-a "${IMAGE}" \
|
|
70
|
+
--mkdir "${ROOTFS_CONTRACT_INSTALL_DIR}" \
|
|
71
|
+
--mkdir "${ROOTFS_CONTRACT_DATA_DIR}" \
|
|
72
|
+
--copy-in "${APP_BINARY}:${GUEST_APP_DIR}" \
|
|
73
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-bootstrap.sh:/usr/local/sbin" \
|
|
74
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-configure.sh:/usr/local/sbin" \
|
|
75
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-autotls-refresh.py:/usr/local/sbin" \
|
|
76
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-describe.py:/usr/local/sbin" \
|
|
77
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-setup-server.py:/usr/local/sbin" \
|
|
78
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-bootstrap.service:/etc/systemd/system" \
|
|
79
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer-autotls-refresh.service:/etc/systemd/system" \
|
|
80
|
+
--copy-in "${SCRIPT_DIR}/uc-go-peer.service:/etc/systemd/system" \
|
|
81
|
+
--run-command "chmod 0755 ${ROOTFS_CONTRACT_BINARY_PATH}" \
|
|
82
|
+
--run-command "chmod 0755 /usr/local/sbin/uc-go-peer-bootstrap.sh" \
|
|
83
|
+
--run-command "chmod 0755 /usr/local/sbin/uc-go-peer-configure.sh" \
|
|
84
|
+
--run-command "chmod 0755 /usr/local/sbin/uc-go-peer-autotls-refresh.py" \
|
|
85
|
+
--run-command "chmod 0755 /usr/local/sbin/uc-go-peer-describe.py" \
|
|
86
|
+
--run-command "chmod 0755 /usr/local/sbin/uc-go-peer-setup-server.py" \
|
|
87
|
+
--run-command "INSTALL_DIR=${ROOTFS_CONTRACT_INSTALL_DIR} APP_BINARY=${ROOTFS_CONTRACT_BINARY_PATH} DATA_DIR=${ROOTFS_CONTRACT_DATA_DIR} ENV_FILE=${ROOTFS_CONTRACT_ENV_FILE} SERVICE_USER=uc-go-peer /usr/local/sbin/uc-go-peer-bootstrap.sh base" \
|
|
88
|
+
--run-command "INSTALL_DIR=${ROOTFS_CONTRACT_INSTALL_DIR} APP_BINARY=${ROOTFS_CONTRACT_BINARY_PATH} DATA_DIR=${ROOTFS_CONTRACT_DATA_DIR} ENV_FILE=${ROOTFS_CONTRACT_ENV_FILE} SERVICE_USER=uc-go-peer /usr/local/sbin/uc-go-peer-bootstrap.sh build" \
|
|
89
|
+
--run-command "INSTALL_DIR=${ROOTFS_CONTRACT_INSTALL_DIR} APP_BINARY=${ROOTFS_CONTRACT_BINARY_PATH} DATA_DIR=${ROOTFS_CONTRACT_DATA_DIR} ENV_FILE=${ROOTFS_CONTRACT_ENV_FILE} SERVICE_USER=uc-go-peer /usr/local/sbin/uc-go-peer-bootstrap.sh finalize" \
|
|
90
|
+
--run-command "systemctl enable ${ROOTFS_CONTRACT_BOOTSTRAP_SERVICE}" \
|
|
91
|
+
--run-command "systemctl enable ${ROOTFS_CONTRACT_AUTOTLS_SERVICE}" \
|
|
92
|
+
--run-command "systemctl enable ${ROOTFS_CONTRACT_MAIN_SERVICE}"
|
|
93
|
+
|
|
94
|
+
echo "Rootfs image ready at ${IMAGE}"
|