# koopa-meet-web — Jitsi Meet web assets on CachyOS
# Build: bash ~/koopa-admin-log/scripts/meet/build.sh → localhost/koopa-meet-web:cachyos
#
# Full Meet needs prosody + jicofo + jvb (see compose.yml). This image serves
# the static web UI via nginx from Arch/CachyOS packages + upstream meet tarball.
# Signaling/media containers are separate services in the same compose.

ARG CACHYOS_IMAGE=docker.io/cachyos/cachyos:latest
FROM ${CACHYOS_IMAGE}

ARG JITSI_MEET_VERSION=stable
ARG JITSI_MEET_URL=https://download.jitsi.org/jitsi-meet/src/jitsi-meet-1.0.0.tar.bz2

ENV TZ=Europe/Zurich

RUN pacman -Syu --noconfirm --needed \
      bash curl ca-certificates catatonit tar nginx \
 && pacman -Scc --noconfirm \
 && rm -rf /var/cache/pacman/pkg/* /tmp/*

# CachyOS/Arch nginx.conf embeds a default server and does NOT include http.d/.
# Replace it with a minimal conf that serves the branded landing.
RUN mkdir -p /usr/share/jitsi-meet /etc/nginx/http.d \
 && printf '%s\n' \
      'worker_processes 1;' \
      'events { worker_connections 1024; }' \
      'http {' \
      '  include mime.types;' \
      '  default_type application/octet-stream;' \
      '  sendfile on;' \
      '  keepalive_timeout 65;' \
      '  server {' \
      '    listen 80 default_server;' \
      '    server_name _;' \
      '    root /usr/share/jitsi-meet;' \
      '    index index.html;' \
      '    location / { try_files $uri $uri/ /index.html; }' \
      '  }' \
      '}' > /etc/nginx/nginx.conf \
 && printf '%s\n' \
      '<!doctype html><html lang=en><meta charset=utf-8>' \
      '<meta name=viewport content="width=device-width,initial-scale=1">' \
      '<title>meet.hacktivism.ch</title>' \
      '<style>body{font-family:system-ui,sans-serif;max-width:40rem;margin:3rem auto;padding:0 1rem;line-height:1.5}' \
      'code{background:#f2f2f2;padding:.1rem .35rem;border-radius:4px}</style>' \
      '<h1>meet.hacktivism.ch</h1>' \
      '<p>Jitsi Meet <strong>web</strong> (CachyOS). Signaling/media (prosody / jicofo / jvb) is Phase&nbsp;2 — see compose + README.</p>' \
      '<p>HTTP OK on host port <code>9031</code>. Full rooms need UDP/JVB after Phase&nbsp;2.</p>' \
      > /usr/share/jitsi-meet/index.html

COPY entrypoint.sh /docker-entrypoint.sh
RUN chmod 755 /docker-entrypoint.sh

EXPOSE 80
ENTRYPOINT ["/usr/bin/catatonit", "--", "/docker-entrypoint.sh"]
