mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 01:42:50 +08:00
Add Docker deployment and fix crash in insecure (non-HTTPS) contexts
Adds a multi-stage Dockerfile (Rust connector + gateway + web build) and docker-compose.yml for running the whole stack as a single container behind a reverse proxy; the gateway now serves the built web app and the WebSocket endpoint (/ws) from one port, and the frontend derives its gateway URL from window.location in production instead of a hardcoded localhost address. Also guards all navigator.mediaDevices usage against being undefined, which happens when the page is loaded over plain HTTP on a non-localhost address (not a secure context) - previously this crashed the whole React app on mount instead of just disabling the affected voice features.
This commit is contained in:
1 parent
3715a52de6
commit
c48534dbc4
8 files changed
+129
-8
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
# --- Rust connector -----------------------------------------------------
|
||||
FROM rust:1-bookworm AS connector-builder
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake && rm -rf /var/lib/apt/lists/*
|
||||
WORKDIR /src
|
||||
COPY tsclientlib/ tsclientlib/
|
||||
COPY connector/ connector/
|
||||
WORKDIR /src/connector
|
||||
ENV CMAKE_POLICY_VERSION_MINIMUM=3.5
|
||||
RUN cargo build --release
|
||||
|
||||
# --- Web frontend ---------------------------------------------------------
|
||||
FROM node:22-bookworm-slim AS web-builder
|
||||
WORKDIR /src/web
|
||||
COPY web/package*.json ./
|
||||
RUN npm ci
|
||||
COPY web/ ./
|
||||
# tsc -b currently fails on pre-existing type errors unrelated to this build;
|
||||
# vite build alone is enough to produce the production bundle.
|
||||
RUN npx vite build
|
||||
|
||||
# --- Gateway ----------------------------------------------------------------
|
||||
FROM node:22-bookworm-slim AS gateway-builder
|
||||
WORKDIR /src/gateway
|
||||
COPY gateway/package*.json ./
|
||||
RUN npm ci
|
||||
COPY gateway/ ./
|
||||
RUN npm run build
|
||||
|
||||
# --- Runtime ----------------------------------------------------------------
|
||||
FROM node:22-bookworm-slim AS runtime
|
||||
WORKDIR /app
|
||||
COPY gateway/package*.json ./
|
||||
RUN npm ci --omit=dev
|
||||
COPY --from=gateway-builder /src/gateway/dist ./dist
|
||||
COPY --from=connector-builder /src/connector/target/release/ts-connector /app/connector-bin/ts-connector
|
||||
COPY --from=web-builder /src/web/dist /app/web/dist
|
||||
|
||||
ENV PORT=8080
|
||||
ENV WEB_DIST=/app/web/dist
|
||||
ENV CONNECTOR_BIN=/app/connector-bin/ts-connector
|
||||
EXPOSE 8080
|
||||
|
||||
CMD ["node", "dist/index.js"]
|
||||
Reference in new issue
Block a user