From dbc582735723061dccb3e20960e24b9b9e191220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Tue, 28 Apr 2026 18:51:46 +0400 Subject: [PATCH] Fix node_modules install + optimize go install by mounting go mod folder into VM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- contrib/lima/provision.sh | 40 +++++++++++++++++++-------------------- contrib/lima/sandbox.sh | 2 +- pkg/bootstrap/builder.go | 4 ++-- pkg/probod/probod.go | 4 ++-- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/contrib/lima/provision.sh b/contrib/lima/provision.sh index 9f59d2293..3ea34f8b4 100755 --- a/contrib/lima/provision.sh +++ b/contrib/lima/provision.sh @@ -11,7 +11,7 @@ export LIMA_CIDATA_USER export DEBIAN_FRONTEND=noninteractive -GO_VERSION="1.26.1" +GO_VERSION="1.26.2" NODE_MAJOR=24 NPM_VERSION="11.8.0" @@ -71,8 +71,6 @@ chmod +x /etc/profile.d/go.sh export PATH="/usr/local/go/bin:$PATH" export HOME="${HOME:-/root}" -GOBIN=/usr/local/bin /usr/local/go/bin/go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" -GOBIN=/usr/local/bin /usr/local/go/bin/go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" GOBIN=/usr/local/bin /usr/local/go/bin/go install "github.com/mitranim/gow@${GOW_VERSION}" if ! command -v node &>/dev/null || ! node --version | grep -q "v${NODE_MAJOR}"; then @@ -137,21 +135,6 @@ ACME_ROOT_CA="$(cat /workspace/compose/pebble/certs/rootCA.pem)" \ # because it contains secrets. Transfer ownership so probod can read it. chown "${LIMA_USER}:${LIMA_USER}" /etc/probod/config.yml "${OAUTH2_SIGNING_KEY_PATH}" -# Populate VM-local node_modules with Linux-native binaries (esbuild, etc.). -# The host's node_modules is macOS; `probo-node-modules.service` bind-mounts an -# empty tree over /workspace/node_modules, and we install into it once here so -# `make build` and the dev servers can run without cross-platform mismatches. -if [ -z "$(ls -A /var/lib/probo/node_modules 2>/dev/null)" ]; then - su - "${LIMA_USER}" -c "cd /workspace && npm ci" -fi - -# Generate go and ts files for probod and apps, and create embedded files for probod -make -C /workspace generate WITH_APPS=1 -make -C /workspace embed - -echo "VITE_API_URL=http://${VM_IP}:8080" > /workspace/apps/console/.env -echo "VITE_API_URL=http://${VM_IP}:8080" > /workspace/apps/trust/.env - # Bind-mount VM-local node_modules over the shared workspace to avoid # platform conflicts between macOS host and Linux VM native binaries. cat > /etc/systemd/system/probo-node-modules.service << EOF @@ -171,6 +154,22 @@ ExecStartPost=/bin/chown ${LIMA_USER}:${LIMA_USER} /var/lib/probo/node_modules WantedBy=multi-user.target EOF +systemctl daemon-reload +systemctl enable --now probo-node-modules.service + +# Populate VM-local node_modules with Linux-native binaries (esbuild, etc.). +# The host's node_modules is macOS; `probo-node-modules.service` bind-mounts an +# empty tree over /workspace/node_modules, and we install into it once here so +# the dev servers can run without cross-platform mismatches. +su - "${LIMA_USER}" -c "cd /workspace && npm ci" + +# Generate go and ts files for probod and apps, and create embedded files for probod +make -C /workspace generate WITH_APPS=1 +make -C /workspace embed + +echo "VITE_API_URL=http://${VM_IP}:8080" > /workspace/apps/console/.env +echo "VITE_API_URL=http://${VM_IP}:8080" > /workspace/apps/trust/.env + # Install systemd services for the sandbox cat > /etc/systemd/system/probo-stack.service << EOF [Unit] @@ -214,7 +213,7 @@ cat > /etc/systemd/system/probo-console.service << EOF [Unit] Description=Probo Console Dev Server Requires=probo-node-modules.service -After=probod.service probo-node-modules.service +After=probo-node-modules.service [Service] Type=simple @@ -232,7 +231,7 @@ cat > /etc/systemd/system/probo-trust.service << EOF [Unit] Description=Probo Trust Dev Server Requires=probo-node-modules.service -After=probod.service probo-node-modules.service +After=probo-node-modules.service [Service] Type=simple @@ -247,6 +246,5 @@ WantedBy=multi-user.target EOF systemctl daemon-reload -systemctl enable --now probo-node-modules.service systemctl enable --now probo-stack.service systemctl enable --now probod.service probo-console.service probo-trust.service diff --git a/contrib/lima/sandbox.sh b/contrib/lima/sandbox.sh index 3e84a7cd1..f4d2ac533 100755 --- a/contrib/lima/sandbox.sh +++ b/contrib/lima/sandbox.sh @@ -61,7 +61,7 @@ cmd_create() { local -a create_args=( --name "${VM_NAME}" --tty=false - --set ".mounts = [{\"location\": \"${REPO_ROOT}\", \"mountPoint\": \"/workspace\", \"writable\": true}]" + --set ".mounts = [{\"location\": \"${REPO_ROOT}\", \"mountPoint\": \"/workspace\", \"writable\": true},{\"location\": \"/Users/${USER}/go\", \"mountPoint\": \"/home/${USER}.guest/go\", \"writable\": true}]" --mount-type virtiofs ) diff --git a/pkg/bootstrap/builder.go b/pkg/bootstrap/builder.go index 87ba8e462..7e20f40aa 100644 --- a/pkg/bootstrap/builder.go +++ b/pkg/bootstrap/builder.go @@ -82,8 +82,8 @@ func (b *Builder) Build() (*probodconfig.FullConfig, error) { }, Pg: probodconfig.PgConfig{ Addr: b.getEnvOrDefault("PG_ADDR", "localhost:5432"), - Username: b.getEnvOrDefault("PG_USERNAME", "postgres"), - Password: b.getEnvOrDefault("PG_PASSWORD", "postgres"), + Username: b.getEnvOrDefault("PG_USERNAME", "probod"), + Password: b.getEnvOrDefault("PG_PASSWORD", "probod"), Database: b.getEnvOrDefault("PG_DATABASE", "probod"), PoolSize: int32(b.getEnvIntOrDefault("PG_POOL_SIZE", 100)), MinPoolSize: int32(b.getEnvIntOrDefault("PG_MIN_POOL_SIZE", 10)), diff --git a/pkg/probod/probod.go b/pkg/probod/probod.go index 16c5ec11b..b106e6094 100644 --- a/pkg/probod/probod.go +++ b/pkg/probod/probod.go @@ -91,8 +91,8 @@ func New() *Implm { }, Pg: PgConfig{ Addr: "localhost:5432", - Username: "postgres", - Password: "postgres", + Username: "probod", + Password: "probod", Database: "probod", PoolSize: 100, MinPoolSize: 10,