Fix node_modules install + optimize go install by mounting go mod folder into VM
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -11,7 +11,7 @@ export LIMA_CIDATA_USER
|
|||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
GO_VERSION="1.26.1"
|
GO_VERSION="1.26.2"
|
||||||
NODE_MAJOR=24
|
NODE_MAJOR=24
|
||||||
NPM_VERSION="11.8.0"
|
NPM_VERSION="11.8.0"
|
||||||
|
|
||||||
@@ -71,8 +71,6 @@ chmod +x /etc/profile.d/go.sh
|
|||||||
export PATH="/usr/local/go/bin:$PATH"
|
export PATH="/usr/local/go/bin:$PATH"
|
||||||
export HOME="${HOME:-/root}"
|
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}"
|
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
|
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.
|
# because it contains secrets. Transfer ownership so probod can read it.
|
||||||
chown "${LIMA_USER}:${LIMA_USER}" /etc/probod/config.yml "${OAUTH2_SIGNING_KEY_PATH}"
|
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
|
# Bind-mount VM-local node_modules over the shared workspace to avoid
|
||||||
# platform conflicts between macOS host and Linux VM native binaries.
|
# platform conflicts between macOS host and Linux VM native binaries.
|
||||||
cat > /etc/systemd/system/probo-node-modules.service << EOF
|
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
|
WantedBy=multi-user.target
|
||||||
EOF
|
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
|
# Install systemd services for the sandbox
|
||||||
cat > /etc/systemd/system/probo-stack.service << EOF
|
cat > /etc/systemd/system/probo-stack.service << EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
@@ -214,7 +213,7 @@ cat > /etc/systemd/system/probo-console.service << EOF
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Probo Console Dev Server
|
Description=Probo Console Dev Server
|
||||||
Requires=probo-node-modules.service
|
Requires=probo-node-modules.service
|
||||||
After=probod.service probo-node-modules.service
|
After=probo-node-modules.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
@@ -232,7 +231,7 @@ cat > /etc/systemd/system/probo-trust.service << EOF
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Probo Trust Dev Server
|
Description=Probo Trust Dev Server
|
||||||
Requires=probo-node-modules.service
|
Requires=probo-node-modules.service
|
||||||
After=probod.service probo-node-modules.service
|
After=probo-node-modules.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
@@ -247,6 +246,5 @@ WantedBy=multi-user.target
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable --now probo-node-modules.service
|
|
||||||
systemctl enable --now probo-stack.service
|
systemctl enable --now probo-stack.service
|
||||||
systemctl enable --now probod.service probo-console.service probo-trust.service
|
systemctl enable --now probod.service probo-console.service probo-trust.service
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ cmd_create() {
|
|||||||
local -a create_args=(
|
local -a create_args=(
|
||||||
--name "${VM_NAME}"
|
--name "${VM_NAME}"
|
||||||
--tty=false
|
--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
|
--mount-type virtiofs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ func (b *Builder) Build() (*probodconfig.FullConfig, error) {
|
|||||||
},
|
},
|
||||||
Pg: probodconfig.PgConfig{
|
Pg: probodconfig.PgConfig{
|
||||||
Addr: b.getEnvOrDefault("PG_ADDR", "localhost:5432"),
|
Addr: b.getEnvOrDefault("PG_ADDR", "localhost:5432"),
|
||||||
Username: b.getEnvOrDefault("PG_USERNAME", "postgres"),
|
Username: b.getEnvOrDefault("PG_USERNAME", "probod"),
|
||||||
Password: b.getEnvOrDefault("PG_PASSWORD", "postgres"),
|
Password: b.getEnvOrDefault("PG_PASSWORD", "probod"),
|
||||||
Database: b.getEnvOrDefault("PG_DATABASE", "probod"),
|
Database: b.getEnvOrDefault("PG_DATABASE", "probod"),
|
||||||
PoolSize: int32(b.getEnvIntOrDefault("PG_POOL_SIZE", 100)),
|
PoolSize: int32(b.getEnvIntOrDefault("PG_POOL_SIZE", 100)),
|
||||||
MinPoolSize: int32(b.getEnvIntOrDefault("PG_MIN_POOL_SIZE", 10)),
|
MinPoolSize: int32(b.getEnvIntOrDefault("PG_MIN_POOL_SIZE", 10)),
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ func New() *Implm {
|
|||||||
},
|
},
|
||||||
Pg: PgConfig{
|
Pg: PgConfig{
|
||||||
Addr: "localhost:5432",
|
Addr: "localhost:5432",
|
||||||
Username: "postgres",
|
Username: "probod",
|
||||||
Password: "postgres",
|
Password: "probod",
|
||||||
Database: "probod",
|
Database: "probod",
|
||||||
PoolSize: 100,
|
PoolSize: 100,
|
||||||
MinPoolSize: 10,
|
MinPoolSize: 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user