@le-space/node 0.1.4 → 0.1.6

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 CHANGED
@@ -2109,6 +2109,7 @@ import { readFile as readFile2 } from "fs/promises";
2109
2109
  import { spawn } from "child_process";
2110
2110
 
2111
2111
  // ../rootfs/src/contract.ts
2112
+ import { existsSync } from "fs";
2112
2113
  import { readFile } from "fs/promises";
2113
2114
  import { fileURLToPath } from "url";
2114
2115
  function asObject(value) {
@@ -2223,8 +2224,21 @@ function parseRootfsContract(input) {
2223
2224
  async function readRootfsContractFile(path4) {
2224
2225
  return parseRootfsContract(await readFile(path4, "utf8"));
2225
2226
  }
2227
+ function resolveReferencePath(profile, suffix = "") {
2228
+ const candidates = [
2229
+ new URL(`../reference/${profile}/${suffix}`, import.meta.url),
2230
+ new URL(`./reference/${profile}/${suffix}`, import.meta.url)
2231
+ ];
2232
+ for (const candidate of candidates) {
2233
+ const resolved = fileURLToPath(candidate);
2234
+ if (existsSync(resolved)) {
2235
+ return resolved;
2236
+ }
2237
+ }
2238
+ return fileURLToPath(candidates[0]);
2239
+ }
2226
2240
  function referenceProfileRootfsDir(profile) {
2227
- return fileURLToPath(new URL(`../reference/${profile}/rootfs/`, import.meta.url));
2241
+ return resolveReferencePath(profile, "rootfs/");
2228
2242
  }
2229
2243
 
2230
2244
  // ../rootfs/src/build-plan.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@le-space/node",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Node and GitHub Actions adapters for shared Aleph tooling.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -16,9 +16,9 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@le-space/core": "0.1.4",
20
- "@le-space/shared-types": "0.1.4",
21
- "@le-space/rootfs": "0.1.4",
19
+ "@le-space/core": "0.1.6",
20
+ "@le-space/shared-types": "0.1.6",
21
+ "@le-space/rootfs": "0.1.6",
22
22
  "ethers": "^6.15.0"
23
23
  }
24
24
  }
@@ -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}"