From 2b3210df854d4ceb7010d24d5f35b753f9745ba0 Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Thu, 29 Jan 2026 14:08:19 +0100 Subject: [PATCH] chore(matrix): add Dockerfile and docker-compose config for web app - Add multi-stage Dockerfile for matrix/web - Add matrix-web service to docker-compose.macmini.yml Co-Authored-By: Claude Opus 4.5 --- apps/matrix/apps/web/Dockerfile | 72 +++++++++++++++++++++++++++++++++ docker-compose.macmini.yml | 25 ++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 apps/matrix/apps/web/Dockerfile diff --git a/apps/matrix/apps/web/Dockerfile b/apps/matrix/apps/web/Dockerfile new file mode 100644 index 000000000..24121dbfc --- /dev/null +++ b/apps/matrix/apps/web/Dockerfile @@ -0,0 +1,72 @@ +# Build stage +FROM node:20-alpine AS builder + +# Build arguments for SvelteKit static env vars +ARG PUBLIC_MANA_CORE_AUTH_URL=http://mana-core-auth:3001 + +# Set as environment variables for build +ENV PUBLIC_MANA_CORE_AUTH_URL=$PUBLIC_MANA_CORE_AUTH_URL + +# Install pnpm +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +WORKDIR /app + +# Copy root workspace files +COPY pnpm-workspace.yaml ./ +COPY package.json ./ +COPY pnpm-lock.yaml ./ + +# Copy shared packages needed by matrix web +COPY packages/shared-auth ./packages/shared-auth +COPY packages/shared-i18n ./packages/shared-i18n +COPY packages/shared-icons ./packages/shared-icons +COPY packages/shared-tailwind ./packages/shared-tailwind +COPY packages/shared-theme ./packages/shared-theme +COPY packages/shared-utils ./packages/shared-utils + +# Copy matrix web app +COPY apps/matrix/apps/web ./apps/matrix/apps/web + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Build shared packages that need building +WORKDIR /app/packages/shared-auth +RUN pnpm build || true + +# Build the web app +WORKDIR /app/apps/matrix/apps/web +RUN pnpm exec svelte-kit sync +RUN pnpm build + +# Production stage +FROM node:20-alpine AS production + +# Keep same directory structure as builder so pnpm symlinks resolve correctly +WORKDIR /app/apps/matrix/apps/web + +# Copy the pnpm store that symlinks point to (at /app/node_modules/.pnpm) +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules (contains symlinks to the pnpm store) +COPY --from=builder /app/apps/matrix/apps/web/node_modules ./node_modules + +# Copy built application +COPY --from=builder /app/apps/matrix/apps/web/build ./build +COPY --from=builder /app/apps/matrix/apps/web/package.json ./ + +# Expose port +EXPOSE 5180 + +# Set environment variables +ENV NODE_ENV=production +ENV PORT=5180 +ENV HOST=0.0.0.0 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:5180/health || exit 1 + +# Run the app +CMD ["node", "build"] diff --git a/docker-compose.macmini.yml b/docker-compose.macmini.yml index 3ef4eed25..711bd1d6c 100644 --- a/docker-compose.macmini.yml +++ b/docker-compose.macmini.yml @@ -923,6 +923,31 @@ services: timeout: 10s retries: 3 + # ============================================ + # Matrix Web App (Custom SvelteKit Client) + # ============================================ + + matrix-web: + image: ghcr.io/memo-2023/matrix-web:latest + container_name: manacore-matrix-web + restart: always + depends_on: + synapse: + condition: service_healthy + mana-core-auth: + condition: service_healthy + environment: + NODE_ENV: production + PORT: 5180 + PUBLIC_MANA_CORE_AUTH_URL: https://auth.mana.how + ports: + - "5180:5180" + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:5180/health"] + interval: 30s + timeout: 10s + retries: 3 + # ============================================ # Matrix Mana Bot (Unified Gateway - All Features) # ============================================