diff --git a/apps/lightwrite/apps/backend/Dockerfile b/apps/lightwrite/apps/backend/Dockerfile new file mode 100644 index 000000000..4f38d3328 --- /dev/null +++ b/apps/lightwrite/apps/backend/Dockerfile @@ -0,0 +1,78 @@ +# Build stage +FROM node:20-alpine AS builder + +# 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 +COPY packages/shared-drizzle-config ./packages/shared-drizzle-config +COPY packages/shared-errors ./packages/shared-errors +COPY packages/shared-nestjs-auth ./packages/shared-nestjs-auth +COPY packages/shared-nestjs-health ./packages/shared-nestjs-health +COPY packages/shared-storage ./packages/shared-storage +COPY packages/shared-tsconfig ./packages/shared-tsconfig + +# Copy lightwrite packages +COPY apps/lightwrite/packages ./apps/lightwrite/packages +COPY apps/lightwrite/apps/backend ./apps/lightwrite/apps/backend + +# Install dependencies +RUN pnpm install --frozen-lockfile --ignore-scripts + +# Build shared packages +WORKDIR /app/packages/shared-errors +RUN pnpm build + +WORKDIR /app/packages/shared-nestjs-auth +RUN pnpm build + +WORKDIR /app/packages/shared-nestjs-health +RUN pnpm build + +WORKDIR /app/packages/shared-storage +RUN pnpm build + +# Build the backend +WORKDIR /app/apps/lightwrite/apps/backend +RUN pnpm build + +# Production stage +FROM node:20-alpine AS production + +# Install pnpm and postgresql-client +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate \ + && apk add --no-cache postgresql-client + +WORKDIR /app + +# Copy everything from builder +COPY --from=builder /app/pnpm-workspace.yaml ./ +COPY --from=builder /app/package.json ./ +COPY --from=builder /app/pnpm-lock.yaml ./ +COPY --from=builder /app/node_modules ./node_modules +COPY --from=builder /app/packages ./packages +COPY --from=builder /app/apps/lightwrite ./apps/lightwrite + +# Copy entrypoint script +COPY apps/lightwrite/apps/backend/docker-entrypoint.sh /usr/local/bin/ +RUN chmod +x /usr/local/bin/docker-entrypoint.sh + +WORKDIR /app/apps/lightwrite/apps/backend + +# Expose port +EXPOSE 3010 + +# Health check +HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:3010/health || exit 1 + +# Run entrypoint script +ENTRYPOINT ["docker-entrypoint.sh"] +CMD ["node", "dist/main.js"] diff --git a/apps/lightwrite/apps/backend/docker-entrypoint.sh b/apps/lightwrite/apps/backend/docker-entrypoint.sh new file mode 100644 index 000000000..2b2b5306c --- /dev/null +++ b/apps/lightwrite/apps/backend/docker-entrypoint.sh @@ -0,0 +1,46 @@ +#!/bin/sh +set -e + +echo "==========================================" +echo " LightWrite Backend Startup" +echo "==========================================" +echo "Environment: ${NODE_ENV:-development}" +echo "Port: ${PORT:-3010}" + +# Wait for database to be ready +if [ -n "$DATABASE_URL" ]; then + echo "Waiting for database..." + + # Extract host and port from DATABASE_URL + DB_HOST=$(echo $DATABASE_URL | sed -n 's/.*@\([^:]*\):.*/\1/p') + DB_PORT=$(echo $DATABASE_URL | sed -n 's/.*:\([0-9]*\)\/.*/\1/p') + + # Default port if not found + DB_PORT=${DB_PORT:-5432} + + # Wait for database to accept connections + max_attempts=30 + attempt=1 + while [ $attempt -le $max_attempts ]; do + if pg_isready -h "$DB_HOST" -p "$DB_PORT" > /dev/null 2>&1; then + echo "Database is ready!" + break + fi + echo "Waiting for database... (attempt $attempt/$max_attempts)" + sleep 2 + attempt=$((attempt + 1)) + done + + if [ $attempt -gt $max_attempts ]; then + echo "Warning: Could not connect to database after $max_attempts attempts" + fi +fi + +# Push database schema (safe for production - only adds missing tables/columns) +if [ "$RUN_DB_PUSH" = "true" ]; then + echo "Pushing database schema..." + npx drizzle-kit push --force || echo "Warning: db:push failed, continuing anyway..." +fi + +echo "Starting application..." +exec "$@" diff --git a/apps/lightwrite/apps/web/Dockerfile b/apps/lightwrite/apps/web/Dockerfile new file mode 100644 index 000000000..5c06a17ec --- /dev/null +++ b/apps/lightwrite/apps/web/Dockerfile @@ -0,0 +1,93 @@ +# Build stage +FROM node:20-alpine AS builder + +# Build arguments for SvelteKit static env vars +ARG PUBLIC_MANA_CORE_AUTH_URL=http://mana-auth:3001 +ARG PUBLIC_BACKEND_URL=http://lightwrite-backend:3010 + +# Set as environment variables for build +ENV PUBLIC_MANA_CORE_AUTH_URL=$PUBLIC_MANA_CORE_AUTH_URL +ENV PUBLIC_BACKEND_URL=$PUBLIC_BACKEND_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 lightwrite web +COPY packages/shared-auth ./packages/shared-auth +COPY packages/shared-auth-ui ./packages/shared-auth-ui +COPY packages/shared-branding ./packages/shared-branding +COPY packages/shared-config ./packages/shared-config +COPY packages/shared-i18n ./packages/shared-i18n +COPY packages/shared-icons ./packages/shared-icons +COPY packages/shared-stores ./packages/shared-stores +COPY packages/shared-tailwind ./packages/shared-tailwind +COPY packages/shared-theme ./packages/shared-theme +COPY packages/shared-theme-ui ./packages/shared-theme-ui +COPY packages/shared-types ./packages/shared-types +COPY packages/shared-ui ./packages/shared-ui +COPY packages/shared-utils ./packages/shared-utils +COPY packages/shared-vite-config ./packages/shared-vite-config + +# Copy lightwrite shared package +COPY apps/lightwrite/packages ./apps/lightwrite/packages + +# Copy lightwrite web +COPY apps/lightwrite/apps/web ./apps/lightwrite/apps/web + +# Install dependencies +RUN pnpm install --frozen-lockfile + +# Build shared packages that need building +WORKDIR /app/packages/shared-vite-config +RUN pnpm build + +WORKDIR /app/packages/shared-auth +RUN pnpm build || true + +# Build the web app +WORKDIR /app/apps/lightwrite/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/lightwrite/apps/web + +# Copy the pnpm store that symlinks point to +COPY --from=builder /app/node_modules/.pnpm /app/node_modules/.pnpm + +# Copy the app's node_modules +COPY --from=builder /app/apps/lightwrite/apps/web/node_modules ./node_modules + +# Copy built application +COPY --from=builder /app/apps/lightwrite/apps/web/build ./build +COPY --from=builder /app/apps/lightwrite/apps/web/package.json ./ + +# Copy entrypoint script +COPY apps/lightwrite/apps/web/docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh + +# 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 +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["node", "build"] diff --git a/apps/lightwrite/apps/web/docker-entrypoint.sh b/apps/lightwrite/apps/web/docker-entrypoint.sh new file mode 100644 index 000000000..9e483bd5e --- /dev/null +++ b/apps/lightwrite/apps/web/docker-entrypoint.sh @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +# This script injects runtime environment variables into the SvelteKit build +# SvelteKit builds env vars at build time, but we need to inject them at runtime +# for Docker deployments where the container runs in different environments + +echo "Starting LightWrite Web with runtime configuration..." +echo "PUBLIC_MANA_CORE_AUTH_URL_CLIENT: ${PUBLIC_MANA_CORE_AUTH_URL_CLIENT:-not set}" +echo "PUBLIC_BACKEND_URL_CLIENT: ${PUBLIC_BACKEND_URL_CLIENT:-not set}" + +# Execute the main command +exec "$@" diff --git a/apps/matrix/apps/web/src/lib/components/chat/RoomSettingsPanel.svelte b/apps/matrix/apps/web/src/lib/components/chat/RoomSettingsPanel.svelte index 671e28701..c0d7e7bc9 100644 --- a/apps/matrix/apps/web/src/lib/components/chat/RoomSettingsPanel.svelte +++ b/apps/matrix/apps/web/src/lib/components/chat/RoomSettingsPanel.svelte @@ -13,6 +13,7 @@ BellSlash, CircleNotch, SquaresFour, + MagnifyingGlass, } from '@manacore/shared-icons'; interface Props { @@ -96,34 +97,44 @@ onclick={onClose} aria-label="Schließen" > +
-
-

Raum-Details

-
-
-
-
- {#if room.avatar} - {room.name} - {:else} - {room.name.charAt(0).toUpperCase()} - {/if} -
+
+
+ {#if room.avatar} + {room.name} + {:else} +
+ {room.name.charAt(0).toUpperCase()} +
+ {/if}
-

{room.name}

+

{room.name}

{#if room.topic} -

{room.topic}

+

{room.topic}

{/if} -

+

{room.memberCount} Mitglieder {#if room.isEncrypted} • Verschlüsselt @@ -132,140 +143,163 @@

-
+
-
+
{#if activeTab === 'members'} -
+
+ {#if searching} - + {/if}
{#if searchResults.length > 0} - +
{/if}
- +
{:else if activeTab === 'widgets'}
{#if widgets.length === 0} -
- -

Keine Widgets in diesem Raum

-

Bots können Widgets hinzufügen

+
+ +

Keine Widgets in diesem Raum

+

Bots können Widgets hinzufügen

{:else}
{#each widgets as widget} -
-
-
-

{widget.name}

- -
- {#if expandedWidget === widget.id} -
- -
- {/if} +
+
+

{widget.name}

+
+ {#if expandedWidget === widget.id} +
+ +
+ {/if}
{/each}
@@ -273,18 +307,29 @@
{:else} -
+
- -
{/if} diff --git a/docker-compose.macmini.yml b/docker-compose.macmini.yml index 1da90f73a..f96f5a842 100644 --- a/docker-compose.macmini.yml +++ b/docker-compose.macmini.yml @@ -592,6 +592,37 @@ services: retries: 3 start_period: 40s + lightwrite-backend: + build: + context: . + dockerfile: apps/lightwrite/apps/backend/Dockerfile + image: lightwrite-backend:local + container_name: mana-app-lightwrite-backend + restart: always + depends_on: + mana-auth: + condition: service_healthy + environment: + NODE_ENV: production + PORT: 3010 + DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-mana123}@postgres:5432/lightwrite + MANA_CORE_AUTH_URL: http://mana-auth:3001 + CORS_ORIGINS: https://lightwrite.mana.how,https://mana.how + S3_ENDPOINT: http://minio:9000 + S3_REGION: us-east-1 + S3_ACCESS_KEY: ${MINIO_ACCESS_KEY:-minioadmin} + S3_SECRET_KEY: ${MINIO_SECRET_KEY:-minioadmin} + S3_BUCKET: lightwrite-storage + RUN_DB_PUSH: "true" + ports: + - "3010:3010" + healthcheck: + test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3010/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + # ============================================ # Tier 4: Matrix Stack (Ports 4000-4099) # ============================================ @@ -1404,6 +1435,35 @@ services: retries: 3 start_period: 40s + lightwrite-web: + build: + context: . + dockerfile: apps/lightwrite/apps/web/Dockerfile + args: + PUBLIC_BACKEND_URL: http://lightwrite-backend:3010 + PUBLIC_MANA_CORE_AUTH_URL: http://mana-auth:3001 + image: lightwrite-web:local + container_name: mana-app-lightwrite-web + restart: always + depends_on: + lightwrite-backend: + condition: service_healthy + environment: + NODE_ENV: production + PORT: 5180 + PUBLIC_BACKEND_URL: http://lightwrite-backend:3010 + PUBLIC_MANA_CORE_AUTH_URL: http://mana-auth:3001 + PUBLIC_BACKEND_URL_CLIENT: https://lightwrite-api.mana.how + PUBLIC_MANA_CORE_AUTH_URL_CLIENT: 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 + start_period: 40s + mana-llm: build: context: ./services/mana-llm