feat(build): bundle frontend with vite and matrix-js-sdk, fix HOST in server.js
Build and Publish / Metadata (push) Successful in 1s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 22s

This commit is contained in:
mats committed 2026-09-22 10:29:03 +02:00
1 parent 5ce3b46bab
commit b6cc9f3465
8 files changed
+3421 -9

No files matched your search

+2
View File
@@ -1,2 +1,4 @@
node_modules/
dist/
.codesearch/
+4 -2
View File
@@ -6,9 +6,9 @@ WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
RUN npm ci
COPY server.js tracing.js ./
COPY server.js tracing.js vite.config.mjs ./
COPY public/ ./public/
# Inject build release into index.html if APP_RELEASE is specified
@@ -18,6 +18,8 @@ RUN if [ -n "${APP_RELEASE}" ]; then \
sed -i "s/window.__APP_RELEASE__ || \"dev\"/\"${APP_RELEASE}\"/g" ./public/index.html; \
fi
RUN npm run build && npm prune --omit=dev
ENV PORT=8080 \
HOST=0.0.0.0
+3371
View File
File diff suppressed because it is too large. Load diff
+11
View File
@@ -4,6 +4,7 @@
"version": "0.1.0",
"description": "Discord-clone POC: WebRTC voice chat + screen sharing + spatial audio",
"scripts": {
"build": "vite build",
"start": "node server.js",
"test": "node --test"
},
@@ -16,6 +17,16 @@
"@opentelemetry/sdk-logs": "^0.222.0",
"@opentelemetry/sdk-node": "^0.222.0",
"@opentelemetry/semantic-conventions": "^1.43.0",
"matrix-js-sdk": "^42.4.0",
"ws": "^8.18.0"
},
"devDependencies": {
"@vitejs/plugin-basic-ssl": "^2.3.0",
"esbuild": "^0.28.2",
"vite": "^8.3.0",
"vite-plugin-node-polyfills": "^0.28.0"
},
"allowScripts": {
"esbuild@0.28.2": true
}
}
+1 -3
View File
@@ -1,6 +1,4 @@
/* gibbz voice POC — WebRTC mesh voice + screen share + spatial audio.
POC shortcuts: no auth (voice), no E2E crypto (matrix text), single audio context. */
import * as matrixcs from 'https://cdn.jsdelivr.net/npm/matrix-js-sdk@42.4.0/lib/browser-index.min.js';
import * as matrixcs from 'matrix-js-sdk';
// ---------------------------------------------------------------------------
// state
+1 -1
View File
@@ -120,6 +120,6 @@
<div id="toasts"></div>
<script type="module" src="app.js?v=11"></script>
<script type="module" src="/app.js"></script>
</body>
</html>
+5 -3
View File
@@ -10,7 +10,9 @@ const { WebSocketServer } = require('ws');
const PORT = Number(process.env.PORT || 8080);
const HOST = process.env.HOST || '0.0.0.0';
const PUBLIC_DIR = path.join(__dirname, 'public');
const STATIC_DIR = fs.existsSync(path.join(__dirname, 'dist'))
? path.join(__dirname, 'dist')
: path.join(__dirname, 'public');
// ---------------------------------------------------------------------------
// ICE configuration: env-driven, full JSON override wins.
@@ -74,8 +76,8 @@ const MIME = {
function serveStatic(req, res) {
const urlPath = decodeURIComponent(new URL(req.url, 'http://x').pathname);
let rel = urlPath === '/' ? '/index.html' : urlPath;
const file = path.normalize(path.join(PUBLIC_DIR, rel));
if (!file.startsWith(PUBLIC_DIR)) {
const file = path.normalize(path.join(STATIC_DIR, rel));
if (!file.startsWith(STATIC_DIR)) {
res.writeHead(403).end('forbidden');
return;
}
+26
View File
@@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import path from 'path';
export default defineConfig({
root: 'public',
plugins: [
nodePolyfills({
include: ['buffer', 'crypto', 'events', 'stream', 'util'],
globals: {
Buffer: true,
global: true,
process: true,
},
}),
],
build: {
outDir: '../dist',
emptyOutDir: true,
target: 'esnext',
minify: 'esbuild',
rollupOptions: {
input: path.resolve(import.meta.dirname, 'public/index.html'),
},
},
});