feat: add fluxer upstream source and self-hosting documentation

- Clone of github.com/fluxerapp/fluxer (official upstream)
- SELF_HOSTING.md: full VM rebuild procedure, architecture overview,
  service reference, step-by-step setup, troubleshooting, seattle reference
- dev/.env.example: all env vars with secrets redacted and generation instructions
- dev/livekit.yaml: LiveKit config template with placeholder keys
- fluxer-seattle/: existing seattle deployment setup scripts
This commit is contained in:
Vish
2026-03-13 00:55:14 -07:00
parent 5ceda343b8
commit 3b9d759b4b
5859 changed files with 1923440 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
ARG BUILD_SHA
ARG BUILD_NUMBER
ARG BUILD_TIMESTAMP
ARG RELEASE_CHANNEL=nightly
FROM node:24-bookworm-slim AS base
WORKDIR /usr/src/app
RUN corepack enable && corepack prepare pnpm@10.26.0 --activate
FROM base AS deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY patches/ ./patches/
COPY packages/ ./packages/
COPY fluxer_marketing/package.json ./fluxer_marketing/
RUN pnpm install --frozen-lockfile
FROM deps AS build
COPY tsconfigs /usr/src/app/tsconfigs
COPY fluxer_marketing/tsconfig.json ./fluxer_marketing/
COPY fluxer_marketing/src ./fluxer_marketing/src
WORKDIR /usr/src/app
RUN pnpm --filter @fluxer/config generate
RUN pnpm --filter @fluxer/marketing build:css \
&& mkdir -p fluxer_marketing/public/static \
&& cp -r packages/marketing/public/static/. fluxer_marketing/public/static/
FROM base AS prod-deps
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY patches/ ./patches/
COPY packages/ ./packages/
COPY fluxer_marketing/package.json ./fluxer_marketing/
RUN pnpm install --frozen-lockfile --prod
COPY --from=build /usr/src/app/packages/marketing/public /usr/src/app/packages/marketing/public
FROM node:24-bookworm-slim
ARG BUILD_SHA
ARG BUILD_NUMBER
ARG BUILD_TIMESTAMP
ARG RELEASE_CHANNEL
WORKDIR /usr/src/app/fluxer_marketing
RUN apt-get update && apt-get install -y --no-install-recommends \
curl && \
rm -rf /var/lib/apt/lists/*
RUN corepack enable && corepack prepare pnpm@10.26.0 --activate
COPY --from=prod-deps /usr/src/app/node_modules /usr/src/app/node_modules
COPY --from=prod-deps /usr/src/app/fluxer_marketing/node_modules ./node_modules
COPY --from=prod-deps /usr/src/app/packages /usr/src/app/packages
COPY --from=build /usr/src/app/packages/config/src/ConfigSchema.json /usr/src/app/packages/config/src/ConfigSchema.json
COPY --from=build /usr/src/app/packages/config/src/MasterZodSchema.generated.tsx /usr/src/app/packages/config/src/MasterZodSchema.generated.tsx
COPY tsconfigs /usr/src/app/tsconfigs
COPY --from=build /usr/src/app/fluxer_marketing/tsconfig.json ./tsconfig.json
COPY --from=build /usr/src/app/fluxer_marketing/src ./src
COPY --from=build /usr/src/app/fluxer_marketing/public ./public
COPY fluxer_marketing/package.json ./
RUN mkdir -p /usr/src/app/.cache/corepack && \
chown -R nobody:nogroup /usr/src/app
ENV HOME=/usr/src/app
ENV COREPACK_HOME=/usr/src/app/.cache/corepack
ENV NODE_ENV=production
ENV FLUXER_MARKETING_PORT=8080
ENV BUILD_SHA=${BUILD_SHA}
ENV BUILD_NUMBER=${BUILD_NUMBER}
ENV BUILD_TIMESTAMP=${BUILD_TIMESTAMP}
ENV RELEASE_CHANNEL=${RELEASE_CHANNEL}
USER nobody
EXPOSE 8080
CMD ["pnpm", "start"]

View File

@@ -0,0 +1,29 @@
{
"name": "fluxer_marketing",
"private": true,
"type": "module",
"scripts": {
"build:css": "pnpm --filter @fluxer/marketing build:css",
"build:css:watch": "pnpm --filter @fluxer/marketing build:css:watch",
"dev": "tsx watch --clear-screen=false src/index.tsx",
"start": "pnpm build:css && tsx src/index.tsx",
"typecheck": "tsgo --noEmit"
},
"dependencies": {
"@fluxer/cache": "workspace:*",
"@fluxer/config": "workspace:*",
"@fluxer/hono": "workspace:*",
"@fluxer/initialization": "workspace:*",
"@fluxer/kv_client": "workspace:*",
"@fluxer/logger": "workspace:*",
"@fluxer/marketing": "workspace:*",
"@fluxer/rate_limit": "workspace:*",
"hono": "catalog:",
"tsx": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
"@typescript/native-preview": "catalog:"
},
"packageManager": "pnpm@10.29.3"
}

View File

@@ -0,0 +1,90 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import {Config} from '@app/Config';
import {Logger} from '@app/Logger';
import type {ICacheService} from '@fluxer/cache/src/ICacheService';
import {KVCacheProvider} from '@fluxer/cache/src/providers/KVCacheProvider';
import {createServiceTelemetry} from '@fluxer/hono/src/middleware/TelemetryAdapters';
import type {IKVProvider} from '@fluxer/kv_client/src/IKVProvider';
import {KVClient} from '@fluxer/kv_client/src/KVClient';
import {createMarketingApp} from '@fluxer/marketing/src/App';
import {resolveMarketingPublicDir} from '@fluxer/marketing/src/PublicDir';
import {throwKVRequiredError} from '@fluxer/rate_limit/src/KVRequiredError';
import {RateLimitService} from '@fluxer/rate_limit/src/RateLimitService';
import type {Context, Hono} from 'hono';
export interface MarketingApp {
app: Hono;
shutdown: () => void;
}
export function createApp(): MarketingApp {
let rateLimitService: RateLimitService | null = null;
if (Config.rateLimit) {
if (!Config.kvUrl) {
throwKVRequiredError({
serviceName: 'fluxer_marketing',
configPath: 'Config.kvUrl',
});
}
const kvProvider = createKVProvider(Config.kvUrl, Logger);
const cacheService: ICacheService = new KVCacheProvider({client: kvProvider});
rateLimitService = new RateLimitService(cacheService);
}
const telemetry = createServiceTelemetry({
serviceName: 'fluxer-marketing',
skipPaths: ['/_health', '/static'],
});
const {app, shutdown} = createMarketingApp({
config: {
env: Config.env,
port: Config.port,
host: Config.host,
secretKeyBase: Config.secretKeyBase,
basePath: Config.basePath,
apiEndpoint: Config.apiEndpoint,
appEndpoint: Config.appEndpoint,
staticCdnEndpoint: Config.staticCdnEndpoint,
marketingEndpoint: Config.marketingEndpoint,
geoipDbPath: Config.geoipDbPath,
trustCfConnectingIp: Config.trustCfConnectingIp,
releaseChannel: Config.releaseChannel,
buildTimestamp: Config.buildTimestamp,
rateLimit: Config.rateLimit,
},
logger: Logger,
publicDir: resolveMarketingPublicDir(),
rateLimitService: rateLimitService ?? undefined,
metricsCollector: telemetry.metricsCollector,
tracing: telemetry.tracing,
});
app.get('/_health', (c: Context) => c.json({status: 'ok'}));
return {app, shutdown};
}
function createKVProvider(kvUrl: string, _logger: typeof Logger): IKVProvider {
return new KVClient({url: kvUrl});
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import {loadConfig} from '@fluxer/config/src/ConfigLoader';
import {
extractBaseServiceConfig,
extractBuildInfoConfig,
extractKVClientConfig,
} from '@fluxer/config/src/ServiceConfigSlices';
import {normalizeBasePath} from '@fluxer/marketing/src/UrlUtils';
const master = await loadConfig();
const marketingConfig = master.services.marketing;
if (!marketingConfig) {
throw new Error('services.marketing configuration is required for standalone marketing service');
}
export const Config = {
...extractBaseServiceConfig(master),
...extractKVClientConfig(master),
...extractBuildInfoConfig(),
port: marketingConfig.port,
host: marketingConfig.host,
secretKeyBase: marketingConfig.secret_key_base,
basePath: normalizeBasePath(marketingConfig.base_path),
apiEndpoint: master.endpoints.api,
appEndpoint: master.endpoints.app,
staticCdnEndpoint: master.endpoints.static_cdn,
marketingEndpoint: stripPath(master.endpoints.marketing),
geoipDbPath: master.geoip.maxmind_db_path,
trustCfConnectingIp: master.proxy.trust_cf_connecting_ip,
rateLimit: null,
};
export type Config = typeof Config;
function stripPath(value: string): string {
const url = new URL(value);
url.pathname = '';
url.search = '';
url.hash = '';
return url.toString().replace(/\/$/, '');
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import type {JSX as HonoJSX} from 'hono/jsx';
declare global {
namespace JSX {
type Element = HonoJSX.Element;
interface IntrinsicAttributes extends HonoJSX.IntrinsicAttributes {}
interface IntrinsicElements extends HonoJSX.IntrinsicElements {}
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import {Config} from '@app/Config';
import {createServiceInstrumentation} from '@fluxer/initialization/src/CreateServiceInstrumentation';
export const shutdownInstrumentation = createServiceInstrumentation({
serviceName: 'fluxer-marketing',
config: Config,
});

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import {createLogger, type Logger as FluxerLogger} from '@fluxer/logger/src/Logger';
export const Logger = createLogger('fluxer-marketing');
export type Logger = FluxerLogger;

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see <https://www.gnu.org/licenses/>.
*/
import {createApp} from '@app/App';
import {Config} from '@app/Config';
import {shutdownInstrumentation} from '@app/Instrument';
import {Logger} from '@app/Logger';
import {createServer, setupGracefulShutdown} from '@fluxer/hono/src/Server';
import '@app/Instrument';
const {app, shutdown} = createApp();
const server = createServer(app, {port: Config.port});
Logger.info({port: Config.port}, `Starting Fluxer Marketing on port ${Config.port}`);
setupGracefulShutdown(
async () => {
shutdown();
await shutdownInstrumentation();
await new Promise<void>((resolve) => {
server.close(() => resolve());
});
},
{logger: Logger},
);

View File

@@ -0,0 +1,12 @@
{
"extends": "../tsconfigs/service.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "hono/jsx",
"paths": {
"@app/*": ["./src/*"],
"@fluxer/*": ["./../packages/*", "./../packages/*/src/index.tsx"]
}
},
"include": ["src/**/*"]
}