Compare commits

...

2 Commits

Author SHA1 Message Date
Ivan I. Ovchinnikov 84fdb0a8e6 deployment edits 2026-11-23 18:45:05 +03:00
Ivan I. Ovchinnikov 0368d42c1f forgotten file 2026-11-23 09:09:32 +03:00
4 changed files with 53 additions and 8 deletions
+11 -4
View File
@@ -8,13 +8,20 @@ services:
RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}" RUNTIME_IMAGE: "${RUNTIME_IMAGE:-nexus.c68.spacecorp.ru/ci/debian:bookworm-ca}"
container_name: emacs-mattermost-bridge container_name: emacs-mattermost-bridge
restart: unless-stopped restart: unless-stopped
# Контейнер будет использовать /etc/hosts и DNS хост-машины напрямую.
# Это позволяет резолвить любые внутренние домены без знания их IP.
network_mode: "host"
environment: environment:
# При network_mode: "host" привязываемся явно к localhost хоста для безопасности
MM_BRIDGE_LISTEN: "0.0.0.0:8765" MM_BRIDGE_LISTEN: "0.0.0.0:8765"
MM_WEB_LISTEN: "0.0.0.0:8766" MM_WEB_LISTEN: "0.0.0.0:8766"
MM_DATA_DIR: "/data" MM_DATA_DIR: "/data"
RUST_LOG: "mm_bridge=info,mm_web=info,warn" RUST_LOG: "mm_bridge=debug,mm_client=debug,mm_store=debug"
ports:
- "127.0.0.1:8765:8765"
- "127.0.0.1:8766:8766"
volumes: volumes:
- ./data:/data - ./data:/data
# Секция 'ports' игнорируется при network_mode: "host",
# так как порты открываются напрямую на интерфейсах хоста.
+5 -1
View File
@@ -6,6 +6,7 @@ FROM ${RUST_BUILDER_IMAGE} AS builder
# Corporate CA so cargo trusts nexus.local over HTTPS. # Corporate CA so cargo trusts nexus.local over HTTPS.
COPY docker/certs/corporate-ca.crt /usr/local/share/ca-certificates/corporate-ca.crt COPY docker/certs/corporate-ca.crt /usr/local/share/ca-certificates/corporate-ca.crt
RUN update-ca-certificates RUN update-ca-certificates
RUN apt install -y curl
WORKDIR /build WORKDIR /build
@@ -30,7 +31,10 @@ COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh RUN chmod +x /usr/local/bin/entrypoint.sh
USER mmbridge # NOTE: Intentionally no `USER mmbridge` here. The entrypoint runs as root,
# fixes /data ownership, then drops privileges via runuser(1).
# This avoids "Permission denied" on bind-mounted volumes whose host-side
# ownership does not match UID 10001.
ENV MM_BRIDGE_LISTEN=0.0.0.0:8765 ENV MM_BRIDGE_LISTEN=0.0.0.0:8765
ENV MM_WEB_LISTEN=0.0.0.0:8766 ENV MM_WEB_LISTEN=0.0.0.0:8766
+7 -3
View File
@@ -5,15 +5,19 @@ export MM_BRIDGE_LISTEN="${MM_BRIDGE_LISTEN:-0.0.0.0:8765}"
export MM_WEB_LISTEN="${MM_WEB_LISTEN:-0.0.0.0:8766}" export MM_WEB_LISTEN="${MM_WEB_LISTEN:-0.0.0.0:8766}"
export MM_DATA_DIR="${MM_DATA_DIR:-/data}" export MM_DATA_DIR="${MM_DATA_DIR:-/data}"
# Ensure data directory exists with correct ownership.
# Entrypoint runs as root; we fix permissions then drop to mmbridge below.
mkdir -p "${MM_DATA_DIR}" mkdir -p "${MM_DATA_DIR}"
chown -R mmbridge:mmbridge "${MM_DATA_DIR}" 2>/dev/null || true
# Drop privileges to the unprivileged mmbridge user.
if [[ "$#" -eq 0 ]]; then if [[ "$#" -eq 0 ]]; then
exec mm-bridge exec runuser -u mmbridge -- mm-bridge
fi fi
if [[ "$1" == "mm-bridge" ]]; then if [[ "$1" == "mm-bridge" ]]; then
shift shift
exec mm-bridge "$@" exec runuser -u mmbridge -- mm-bridge "$@"
fi fi
exec "$@" exec runuser -u mmbridge -- "$@"
+30
View File
@@ -0,0 +1,30 @@
;;; mattermost-files.el --- File attachment helpers -*- lexical-binding: t; -*-
(require 'mattermost-custom)
(require 'mattermost-protocol)
(defun mattermost--format-file-size (bytes)
"Format BYTES as human-readable size."
(cond
((< bytes 1024) (format "%d B" bytes))
((< bytes (* 1024 1024)) (format "%.1f KB" (/ bytes 1024.0)))
((< bytes (* 1024 1024 1024)) (format "%.1f MB" (/ bytes (* 1024.0 1024.0))))
(t (format "%.1f GB" (/ bytes (* 1024.0 1024.0 1024.0))))))
(defun mattermost--format-file-block (files)
"Return a propertized multi-line string describing FILES plist list."
(mapconcat
(lambda (f)
(let* ((name (or (plist-get f :name) "unknown"))
(size (or (plist-get f :size) 0))
(id (plist-get f :id)))
(propertize
(format " 📎 %s (%s)\n" name (mattermost--format-file-size size))
'mm-file-id id
'mm-file-name name
'mouse-face 'highlight
'help-echo "RET to download and open")))
files
""))
(provide 'mattermost-files)