update
This commit is contained in:
+11
-1
@@ -2,7 +2,11 @@ DATABASE_URL ?= postgres://descrybe:descrybe@localhost:5433/descrybe?sslmode=dis
|
||||
GOOSE ?= go run github.com/pressly/goose/v3/cmd/goose@v3.24.1
|
||||
SQLC ?= go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.29.0
|
||||
|
||||
.PHONY: migrate-up sqlc run worker migrator tidy test vet
|
||||
.PHONY: migrate-up sqlc run worker migrator tidy test vet build build-lowmem
|
||||
|
||||
# Low-RAM compile defaults (~4GB hosts): one package at a time, capped GOMAXPROCS.
|
||||
GO_BUILD_P ?= 1
|
||||
GO_BIN_DIR ?= ../../bin
|
||||
|
||||
migrate-up:
|
||||
$(GOOSE) -dir sql/schema postgres "$(DATABASE_URL)" up
|
||||
@@ -27,3 +31,9 @@ test:
|
||||
|
||||
vet:
|
||||
go vet ./...
|
||||
|
||||
# Sequential api + worker binaries into repo bin/ (see scripts/build.mjs).
|
||||
build build-lowmem:
|
||||
mkdir -p "$(GO_BIN_DIR)"
|
||||
GOMAXPROCS=1 GOMEMLIMIT=768MiB GOGC=50 go build -p=$(GO_BUILD_P) -trimpath -ldflags="-s -w" -o "$(GO_BIN_DIR)/api" ./cmd/api
|
||||
GOMAXPROCS=1 GOMEMLIMIT=768MiB GOGC=50 go build -p=$(GO_BUILD_P) -trimpath -ldflags="-s -w" -o "$(GO_BIN_DIR)/worker" ./cmd/worker
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
"scripts": {
|
||||
"dev": "vite dev --host --strictPort",
|
||||
"build": "vite build",
|
||||
"build:lowmem": "node ../../scripts/build.mjs --web",
|
||||
"start": "node build",
|
||||
"preview": "vite preview",
|
||||
"prepare": "svelte-kit sync || echo '' && node scripts/copy-rapidoc-ui.mjs",
|
||||
|
||||
@@ -4,13 +4,35 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { defineConfig } from "vite";
|
||||
import { DEV_API_PROXY_TARGET, DEV_WEB_PORT } from "../../scripts/dev-ports.mjs";
|
||||
import { detectHostProfile } from "../../scripts/lowmem-env.mjs";
|
||||
|
||||
const monorepoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
||||
|
||||
const profile = detectHostProfile();
|
||||
/** Env wins; otherwise follow auto RAM/CPU tier. */
|
||||
const lowMem =
|
||||
process.env.BUILD_LOW_MEM != null && process.env.BUILD_LOW_MEM !== ""
|
||||
? process.env.BUILD_LOW_MEM !== "0"
|
||||
: profile.lowMem;
|
||||
|
||||
export default defineConfig({
|
||||
// Load PUBLIC_* from monorepo-root .env (same file as the Go API).
|
||||
envDir: monorepoRoot,
|
||||
plugins: [tailwindcss(), sveltekit()],
|
||||
build: {
|
||||
// Gzip size reporting double-reads output and spikes peak RSS on tiny hosts.
|
||||
reportCompressedSize: !lowMem,
|
||||
// Production maps are opt-in; maps roughly double transform memory.
|
||||
sourcemap: process.env.BUILD_SOURCEMAP === "1",
|
||||
// Smaller inlined assets → less heap during transform on 4GB boxes.
|
||||
assetsInlineLimit: lowMem ? 1024 : 4096,
|
||||
rolldownOptions: {
|
||||
checks: {
|
||||
// Informative only; sveltekit-guard resolveId dominates wall time (see Rolldown docs).
|
||||
pluginTimings: process.env.BUILD_PLUGIN_TIMINGS === "1"
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
// true → all interfaces (IPv4 + IPv6). Default localhost is ::1-only on Windows,
|
||||
// which breaks 127.0.0.1 probes and some browser Happy Eyeballs paths.
|
||||
|
||||
Reference in New Issue
Block a user