-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreact-native-linux.yaml
More file actions
175 lines (156 loc) · 6.21 KB
/
react-native-linux.yaml
File metadata and controls
175 lines (156 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Lima template for react-native-linux development.
#
# Usage:
# limactl start --name=rn-linux ./scripts/vm/react-native-linux.yaml
# limactl shell rn-linux
#
# Or use the wrapper scripts under scripts/vm/.
#
# Once booted, connect to the VNC display from macOS:
# open vnc://127.0.0.1:5901 # password: rnlinux
#
# Inside the VNC session you get an Xfce desktop. Run the app there with:
# cd /workspaces/react-native-linux/template/linux/build
# ./rn-linux-app
# Ubuntu 24.04 LTS. The cloud image is small and the runtime is what we
# actually target in CI.
images:
- location: 'https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img'
arch: 'x86_64'
- location: 'https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img'
arch: 'aarch64'
# 4 CPUs + 6 GB RAM is enough for a Hermes-from-source build.
cpus: 4
memory: '6GiB'
# 30 GiB sparse — qcow2 only allocates what's actually written, so the host
# disk impact starts ~3-4 GiB and grows with the build. The hard ceiling
# matters because Hermes + Folly + RN headers can hit ~12 GiB.
disk: '30GiB'
# Use Apple's Virtualization framework + virtiofs on Apple Silicon hosts
# for near-bare-metal mount performance and no macFUSE dependency. Falls
# back gracefully on x86_64 hosts (Lima auto-selects qemu).
vmType: 'vz'
mountType: 'virtiofs'
# Disable Lima's built-in containerd/nerdctl install. We don't run
# containers from this VM; skipping shaves ~3-5 minutes off boot and
# stops it from competing with our own provisioning for the 10-minute
# hostagent timer.
containerd:
system: false
user: false
# Mount the repo into the guest at /workspaces/react-native-linux (the
# devcontainer convention). We intentionally don't mount under the user's
# home directory because Lima's vz vmType creates the guest home at
# `/home/{user}.guest`, not `/home/{user}.linux`, and the mismatch made
# earlier provisioning paths fragile.
mounts:
- location: '{{.Home}}/code/lucid-softworks/react-native-linux'
mountPoint: '/workspaces/react-native-linux'
writable: true
# Forward TigerVNC out to the host so a macOS VNC viewer can connect.
portForwards:
- guestPort: 5901
hostPort: 5901
- guestPort: 8081 # Metro, in case Metro runs inside the VM
hostPort: 8081
# Provision the guest. Single `provision:` block; Lima runs the entries in
# order. Splitting them out into multiple top-level `provision:` keys is a
# common footgun — the last one wins and earlier ones are silently dropped.
provision:
- mode: system
script: |
#!/bin/bash
set -euxo pipefail
export DEBIAN_FRONTEND=noninteractive
# Add the NodeSource Node 20.x repo BEFORE the big apt install,
# so the `nodejs` package is the v20 LTS our pnpm 9.x needs
# (Ubuntu 24.04's default `nodejs` is v18, which Corepack now
# refuses).
apt-get update
apt-get install -y --no-install-recommends curl ca-certificates gnupg
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt-get install -y --no-install-recommends \
build-essential cmake ninja-build pkg-config \
clang clang-format clang-tidy \
git \
libgtk-4-dev libglib2.0-dev \
libboost-dev libboost-context-dev libboost-filesystem-dev \
libboost-program-options-dev libboost-regex-dev libboost-system-dev \
libboost-thread-dev \
libdouble-conversion-dev libfmt-dev libgflags-dev libgoogle-glog-dev \
libssl-dev libsodium-dev libzstd-dev liblz4-dev libsnappy-dev \
libevent-dev \
python3 python3-pip \
xvfb tigervnc-standalone-server tigervnc-common tigervnc-tools \
xfce4 xfce4-terminal dbus-x11 \
fonts-noto-core fonts-noto-color-emoji \
gnome-themes-extra \
nodejs \
less file unzip
# corepack ships with node 20; force-activate pnpm@9.12.0 so
# `pnpm <cmd>` inside the repo uses the same version CI does.
npm install -g corepack@latest || true
corepack enable
corepack prepare pnpm@9.12.0 --activate
- mode: user
script: |
#!/bin/bash
set -euxo pipefail
mkdir -p "$HOME/.vnc"
# TigerVNC password: 'rnlinux'. Stored in the standard obfuscated format.
echo "rnlinux" | vncpasswd -f > "$HOME/.vnc/passwd"
chmod 600 "$HOME/.vnc/passwd"
cat > "$HOME/.vnc/xstartup" <<'XSTART'
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec dbus-launch --exit-with-session startxfce4
XSTART
chmod 755 "$HOME/.vnc/xstartup"
- mode: system
script: |
#!/bin/bash
set -euxo pipefail
LIMA_USER="{{.User}}"
# Resolve the user's actual home dir at runtime — Lima's vz path is
# `/home/{user}.guest` but historically was `.linux`. Looking it up
# via getent keeps this template robust across Lima versions.
LIMA_HOME="$(getent passwd "${LIMA_USER}" | cut -d: -f6)"
cat > /etc/systemd/system/rn-linux-vnc.service <<UNIT
[Unit]
Description=TigerVNC for react-native-linux dev (display :1)
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=${LIMA_USER}
Environment=HOME=${LIMA_HOME}
WorkingDirectory=${LIMA_HOME}
ExecStart=/usr/bin/tigervncserver :1 -geometry 1440x900 -localhost no -rfbauth ${LIMA_HOME}/.vnc/passwd
ExecStop=/usr/bin/tigervncserver -kill :1
Restart=on-failure
[Install]
WantedBy=multi-user.target
UNIT
systemctl daemon-reload
systemctl enable --now rn-linux-vnc.service || true
probes:
- description: 'VNC port reachable'
script: |
#!/bin/bash
set -eu
timeout 60s bash -c "until ss -tln | grep -q ':5901'; do sleep 1; done"
hint: |
VNC server did not come up. Check:
limactl shell rn-linux -- journalctl -u rn-linux-vnc.service -n 50
message: |
--- react-native-linux VM is ready ---
Repo is mounted at: /workspaces/react-native-linux (inside the VM)
VNC server: display :1, password "rnlinux"
Connect from macOS:
open vnc://127.0.0.1:5901
Then inside the VM:
cd /workspaces/react-native-linux
pnpm install
pnpm cmake:configure
pnpm cmake:build