v4: the devcontainer starts several gerbeur instances side by side, so that signing in from one to another can be tried on one machine — the dev environment ran a single instance. dev/instances.ts lists them (gerbeur on :3000 and :8000, musique on :3001 and :8001), and dev/start.ts starts an API server, restarted on change, and a Vite server for each instance it's given, by one rule: instance <name> keeps api/sql/<name>.db and api/uploads/<name>/, reads .env, and takes its ports and what sets it apart from its entry, with federation allowed over http on localhost. It prefixes each line of output with the instance's name, and stops every server when one stops, such as a Vite server whose port is taken. The devcontainer is now a compose project (.devcontainer/compose.yaml): the workspace, a one-shot install that runs deno install and draws the icons once, and a service per instance running dev/start.ts for it, all on the host's network as before and sharing Deno's cache through a volume. ffmpeg moves from a feature into the Dockerfile, since the instances' services get no features, and docker-outside-of-docker gives the workspace's terminal their logs and restarts. Outside the devcontainer, deno task dev starts them all, or those named. Each Vite server keeps its own dependency cache. The existing dev uploads move to api/uploads/gerbeur/.
dev/start.ts was checked by hand: musique starting alone on a fresh database, an unknown name refused, a taken port stopping both servers, and Ctrl+C or SIGTERM leaving no server behind. The compose project couldn't be run here (no Docker in the workspace): its YAML parses and resolves as intended, but it is untested; tsc, eslint, deno check, deno fmt, deno lint and doc:lint, which now covers dev/, are clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,12 @@ import { BASE_STYLE, isStyleName } from "./shared/theme.ts";
|
||||
|
||||
const SITE_NAME = process.env.GERBEUR_SITE_NAME || "gerbeur";
|
||||
const SITE_EMOJI = process.env.GERBEUR_SITE_EMOJI || "🚚";
|
||||
const BANDCAMP_PLAYER = process.env.GERBEUR_BANDCAMP_PLAYER?.trim() === "native" ? "native" : "embed";
|
||||
const DEFAULT_STYLE = isStyleName(process.env.GERBEUR_DEFAULT_STYLE?.trim()) ? process.env.GERBEUR_DEFAULT_STYLE!.trim() : BASE_STYLE;
|
||||
const BANDCAMP_PLAYER = process.env.GERBEUR_BANDCAMP_PLAYER?.trim() === "native"
|
||||
? "native"
|
||||
: "embed";
|
||||
const DEFAULT_STYLE = isStyleName(process.env.GERBEUR_DEFAULT_STYLE?.trim())
|
||||
? process.env.GERBEUR_DEFAULT_STYLE!.trim()
|
||||
: BASE_STYLE;
|
||||
const EMAIL_ENABLED = process.env.GERBEUR_SMTPS_URL?.trim() ? "on" : "off";
|
||||
|
||||
// Cache-busting token for the favicon URLs (see index.html). Changes when the
|
||||
@@ -27,9 +31,12 @@ const ICON_VERSION = emojiToCodepoint(SITE_EMOJI);
|
||||
// It is served from here rather than a CDN; the version is in the path so the
|
||||
// files can be cached for good, and bumping the package moves the URL.
|
||||
const EMOJIBASE_DIR = resolve("node_modules/emojibase-data");
|
||||
const EMOJIBASE_VERSION = JSON.parse(readFileSync(join(EMOJIBASE_DIR, "package.json"), "utf8")).version;
|
||||
const EMOJIBASE_VERSION =
|
||||
JSON.parse(readFileSync(join(EMOJIBASE_DIR, "package.json"), "utf8")).version;
|
||||
const EMOJIBASE_URL = `/emojibase/${EMOJIBASE_VERSION}`;
|
||||
const EMOJIBASE_FILES = linguiConfig.locales.flatMap((locale) => [`${locale}/data.json`, `${locale}/messages.json`]);
|
||||
const EMOJIBASE_FILES = linguiConfig.locales.flatMap((
|
||||
locale,
|
||||
) => [`${locale}/data.json`, `${locale}/messages.json`]);
|
||||
|
||||
function emojibase(): Plugin {
|
||||
return {
|
||||
@@ -79,7 +86,10 @@ function precompress(): Plugin {
|
||||
const raw = readFileSync(path);
|
||||
if (raw.length < 1024) return;
|
||||
const br = brotliCompressSync(raw, {
|
||||
params: { [zlib.BROTLI_PARAM_QUALITY]: 11, [zlib.BROTLI_PARAM_SIZE_HINT]: raw.length },
|
||||
params: {
|
||||
[zlib.BROTLI_PARAM_QUALITY]: 11,
|
||||
[zlib.BROTLI_PARAM_SIZE_HINT]: raw.length,
|
||||
},
|
||||
});
|
||||
const gz = gzipSync(raw, { level: 9 });
|
||||
if (br.length < raw.length * 0.9) writeFileSync(`${path}.br`, br);
|
||||
@@ -90,7 +100,12 @@ function precompress(): Plugin {
|
||||
};
|
||||
}
|
||||
|
||||
// Each dev instance (dev/instances.ts) runs a Vite server of its own; sharing
|
||||
// one dependency cache, two of them would rewrite it under each other.
|
||||
const INSTANCE = process.env.GERBEUR_INSTANCE;
|
||||
|
||||
export default defineConfig({
|
||||
cacheDir: INSTANCE ? `node_modules/.vite/${INSTANCE}` : undefined,
|
||||
define: {
|
||||
"import.meta.env.VITE_EMOJIBASE_URL": JSON.stringify(EMOJIBASE_URL),
|
||||
},
|
||||
@@ -108,7 +123,9 @@ export default defineConfig({
|
||||
// left to the bundler, so libraries only the lazy chunks use (the emoji
|
||||
// picker, forms) stay out of the first load.
|
||||
manualChunks(id) {
|
||||
if (/node_modules\/(react|react-dom|scheduler|react-router)\//.test(id)) {
|
||||
if (
|
||||
/node_modules\/(react|react-dom|scheduler|react-router)\//.test(id)
|
||||
) {
|
||||
return "vendor";
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user