From d06839bb96ab077401d175ac2ab73990fb28ffb2 Mon Sep 17 00:00:00 2001 From: murdle Date: Sat, 28 Feb 2026 18:12:17 +0200 Subject: [PATCH] fix: self hosting --- config/livekit.example.yaml | 5 +++++ fluxer_app/rspack.config.mjs | 2 +- fluxer_gateway/src/guild/guild_data.erl | 18 +++++++++++++++++- fluxer_server/Dockerfile | 19 ++++++++++++++++++- fluxer_server/src/ServiceInitializer.tsx | 7 ++++--- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/config/livekit.example.yaml b/config/livekit.example.yaml index 2359652b..1673ceb6 100644 --- a/config/livekit.example.yaml +++ b/config/livekit.example.yaml @@ -3,6 +3,11 @@ port: 7880 keys: '': '' +webhook: + api_key: '' + urls: + - https://your.domain/api/webhooks/livekit + rtc: tcp_port: 7881 diff --git a/fluxer_app/rspack.config.mjs b/fluxer_app/rspack.config.mjs index edb89d94..7a050b2c 100644 --- a/fluxer_app/rspack.config.mjs +++ b/fluxer_app/rspack.config.mjs @@ -250,7 +250,7 @@ export default () => { output: { path: DIST_DIR, - publicPath: isProduction ? `${CDN_ENDPOINT}/` : '/', + publicPath: '/', workerPublicPath: '/', filename: (pathData) => { if (pathData.chunk?.name === 'sw') { diff --git a/fluxer_gateway/src/guild/guild_data.erl b/fluxer_gateway/src/guild/guild_data.erl index 86fe13b2..6d20c6bd 100644 --- a/fluxer_gateway/src/guild/guild_data.erl +++ b/fluxer_gateway/src/guild/guild_data.erl @@ -93,6 +93,22 @@ get_first_viewable_text_channel(State) -> EveryoneChannelId = find_everyone_viewable_text_channel(Channels, State), {reply, #{channel_id => EveryoneChannelId}, State}. +-spec fetch_voice_states_from_server(guild_state()) -> [map()]. +fetch_voice_states_from_server(State) -> + case maps:get(voice_server_pid, State, undefined) of + Pid when is_pid(Pid) -> + try gen_server:call(Pid, {get_voice_states_list}, 5000) of + VoiceStates when is_list(VoiceStates) -> VoiceStates; + _ -> [] + catch + exit:{timeout, _} -> []; + exit:{noproc, _} -> []; + exit:{normal, _} -> [] + end; + _ -> + guild_voice:get_voice_states_list(State) + end. + -spec get_guild_state(user_id(), guild_state()) -> map(). get_guild_state(UserId, State) -> Data = guild_data_map(State), @@ -107,7 +123,7 @@ get_guild_state(UserId, State) -> undefined -> []; M -> [M] end, - VoiceStates = guild_voice:get_voice_states_list(State), + VoiceStates = fetch_voice_states_from_server(State), VoiceMembers = voice_members_from_states(VoiceStates, AllMembers), Members = merge_members(OwnMemberList, VoiceMembers), MemberCount = maps:get(member_count, State, length(AllMembers)), diff --git a/fluxer_server/Dockerfile b/fluxer_server/Dockerfile index 46ce701c..4f254617 100644 --- a/fluxer_server/Dockerfile +++ b/fluxer_server/Dockerfile @@ -16,6 +16,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ && rm -rf /var/lib/apt/lists/* +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + --default-toolchain stable --profile minimal \ + && rustup target add wasm32-unknown-unknown \ + && cargo install wasm-pack + FROM base AS deps COPY pnpm-workspace.yaml ./ @@ -55,6 +60,13 @@ COPY packages/worker/package.json ./packages/worker/ COPY packages/http_client/package.json ./packages/http_client/ COPY packages/schema/package.json ./packages/schema/ COPY fluxer_server/package.json ./fluxer_server/ + +for pkg in date_utils elasticsearch_search geo_utils geoip i18n kv_client limits \ + list_utils locale markdown_parser media_proxy_utils meilisearch_search \ + mime_utils nats number_utils openapi time; do + COPY packages/${pkg}/package.json ./packages/${pkg}/ +done + COPY fluxer_app/package.json ./fluxer_app/ RUN pnpm install --frozen-lockfile @@ -73,6 +85,8 @@ COPY fluxer_server/ ./fluxer_server/ RUN pnpm --filter @fluxer/marketing build:css +RUN pnpm --filter admin build:css + COPY fluxer_media_proxy/data/model.onnx ./fluxer_media_proxy/data/model.onnx RUN cd fluxer_server && pnpm typecheck @@ -106,6 +120,9 @@ RUN LOGGER_LEVEL=${LOGGER_LEVEL} envsubst '${LOGGER_LEVEL}' < fluxer_gateway/con (cd fluxer_gateway && rebar3 as prod release) FROM deps AS app-build +ARG FLUXER_BUILD_CONFIG="{}" +RUN echo "$FLUXER_BUILD_CONFIG" > /tmp/fluxer-build-config.json +ENV FLUXER_CONFIG=/tmp/fluxer-build-config.json COPY tsconfigs /usr/src/app/tsconfigs @@ -196,4 +213,4 @@ ENV RELEASE_CHANNEL=${RELEASE_CHANNEL} HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:8080/_health || exit 1 -ENTRYPOINT ["pnpm", "start"] +ENTRYPOINT ["pnpm", "--filter", "fluxer_server", "start"] diff --git a/fluxer_server/src/ServiceInitializer.tsx b/fluxer_server/src/ServiceInitializer.tsx index 8fcc4041..df482a74 100644 --- a/fluxer_server/src/ServiceInitializer.tsx +++ b/fluxer_server/src/ServiceInitializer.tsx @@ -277,6 +277,7 @@ function createAppServerInitializer(context: ServiceInitializationContext): Serv const publicUrlHost = new URL(requireValue(config.endpoints.app, 'endpoints.app')).origin; const mediaUrlHost = new URL(requireValue(config.endpoints.media, 'endpoints.media')).origin; + const staticCdnHost = new URL(requireValue(config.endpoints.static_cdn, 'endpoints.static_cdn')).origin; const appServer = createAppServer({ staticDir, @@ -289,10 +290,10 @@ function createAppServerInitializer(context: ServiceInitializationContext): Serv cspDirectives: { defaultSrc: ["'self'"], scriptSrc: ["'self'", "'unsafe-inline'"], - styleSrc: ["'self'", "'unsafe-inline'"], - imgSrc: ["'self'", 'data:', 'blob:', publicUrlHost, mediaUrlHost], + styleSrc: ["'self'", "'unsafe-inline'", staticCdnHost], + imgSrc: ["'self'", 'data:', 'blob:', publicUrlHost, mediaUrlHost, staticCdnHost], connectSrc: ["'self'", 'wss:', 'ws:', publicUrlHost], - fontSrc: ["'self'"], + fontSrc: ["'self'", staticCdnHost], mediaSrc: ["'self'", 'blob:', mediaUrlHost], frameSrc: ["'none'"], },