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:
89
fluxer/fluxer_media_proxy/Dockerfile
Normal file
89
fluxer/fluxer_media_proxy/Dockerfile
Normal file
@@ -0,0 +1,89 @@
|
||||
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 generator
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY patches/ ./patches/
|
||||
COPY packages/config/ ./packages/config/
|
||||
COPY packages/constants/ ./packages/constants/
|
||||
|
||||
RUN pnpm install --frozen-lockfile --filter @fluxer/config...
|
||||
RUN pnpm --filter @fluxer/config generate
|
||||
|
||||
FROM base AS deps
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
gcc \
|
||||
g++ \
|
||||
make \
|
||||
python3 \
|
||||
pkg-config \
|
||||
libssl-dev \
|
||||
libvips-dev && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY patches/ ./patches/
|
||||
COPY packages/ ./packages/
|
||||
COPY fluxer_media_proxy/package.json ./fluxer_media_proxy/
|
||||
|
||||
RUN pnpm install --frozen-lockfile --prod
|
||||
|
||||
FROM node:24-bookworm-slim
|
||||
|
||||
ARG BUILD_SHA
|
||||
ARG BUILD_NUMBER
|
||||
ARG BUILD_TIMESTAMP
|
||||
ARG RELEASE_CHANNEL
|
||||
|
||||
WORKDIR /usr/src/app/fluxer_media_proxy
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
curl \
|
||||
ffmpeg \
|
||||
libvips \
|
||||
libgomp1 \
|
||||
libatomic1 && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@10.26.0 --activate
|
||||
|
||||
COPY --from=deps /usr/src/app/node_modules /usr/src/app/node_modules
|
||||
COPY --from=deps /usr/src/app/fluxer_media_proxy/node_modules ./node_modules
|
||||
COPY --from=deps /usr/src/app/packages /usr/src/app/packages
|
||||
COPY --from=generator /usr/src/app/packages/config/src/ConfigSchema.json /usr/src/app/packages/config/src/ConfigSchema.json
|
||||
COPY --from=generator /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 fluxer_media_proxy/package.json ./
|
||||
COPY fluxer_media_proxy/tsconfig.json ./
|
||||
COPY fluxer_media_proxy/src ./src
|
||||
COPY fluxer_media_proxy/data ./data
|
||||
|
||||
RUN mkdir -p /opt/data /usr/src/app/.cache/corepack && \
|
||||
cp data/model.onnx /opt/data/model.onnx && \
|
||||
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 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"]
|
||||
BIN
fluxer/fluxer_media_proxy/data/model.onnx
Normal file
BIN
fluxer/fluxer_media_proxy/data/model.onnx
Normal file
Binary file not shown.
26
fluxer/fluxer_media_proxy/package.json
Normal file
26
fluxer/fluxer_media_proxy/package.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "fluxer_media_proxy",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch --clear-screen=false src/App.tsx",
|
||||
"start": "tsx src/App.tsx",
|
||||
"typecheck": "tsgo --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluxer/config": "workspace:*",
|
||||
"@fluxer/hono": "workspace:*",
|
||||
"@fluxer/initialization": "workspace:*",
|
||||
"@fluxer/logger": "workspace:*",
|
||||
"@fluxer/media_proxy": "workspace:*",
|
||||
"@fluxer/rate_limit": "workspace:*",
|
||||
"@fluxer/telemetry": "workspace:*",
|
||||
"@opentelemetry/api": "catalog:",
|
||||
"tsx": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "catalog:",
|
||||
"@typescript/native-preview": "catalog:"
|
||||
},
|
||||
"packageManager": "pnpm@10.29.3"
|
||||
}
|
||||
22
fluxer/fluxer_media_proxy/src/App.tsx
Normal file
22
fluxer/fluxer_media_proxy/src/App.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 '@app/Instrument';
|
||||
|
||||
import '@app/AppMain';
|
||||
96
fluxer/fluxer_media_proxy/src/AppMain.tsx
Normal file
96
fluxer/fluxer_media_proxy/src/AppMain.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 {shutdownInstrumentation} from '@app/Instrument';
|
||||
import {Logger} from '@app/Logger';
|
||||
import {createMetrics} from '@app/Metrics';
|
||||
import {createTracing} from '@app/Tracing';
|
||||
import {createServiceTelemetry} from '@fluxer/hono/src/middleware/TelemetryAdapters';
|
||||
import {createServer, setupGracefulShutdown} from '@fluxer/hono/src/Server';
|
||||
import {createMediaProxyApp} from '@fluxer/media_proxy/src/App';
|
||||
import type {MetricsInterface} from '@fluxer/media_proxy/src/types/Metrics';
|
||||
import type {TracingInterface} from '@fluxer/media_proxy/src/types/Tracing';
|
||||
import {createRateLimitService, type RateLimitService} from '@fluxer/rate_limit/src/RateLimitService';
|
||||
import {isTelemetryActive} from '@fluxer/telemetry/src/Telemetry';
|
||||
|
||||
const metrics: MetricsInterface = createMetrics();
|
||||
|
||||
const tracing: TracingInterface = createTracing();
|
||||
|
||||
let rateLimitService: RateLimitService | null = null;
|
||||
rateLimitService = createRateLimitService(null);
|
||||
|
||||
const requestTelemetry = createServiceTelemetry({
|
||||
serviceName: 'fluxer-media-proxy',
|
||||
skipPaths: ['/_health', '/internal/telemetry'],
|
||||
});
|
||||
|
||||
const {app, shutdown} = await createMediaProxyApp({
|
||||
config: {
|
||||
nodeEnv: Config.env,
|
||||
secretKey: Config.mediaProxy.secretKey,
|
||||
requireCloudflareEdge: Config.mediaProxy.requireCloudflareEdge,
|
||||
staticMode: Config.mediaProxy.staticMode,
|
||||
s3: {
|
||||
endpoint: Config.aws.s3Endpoint,
|
||||
region: Config.aws.s3Region,
|
||||
accessKeyId: Config.aws.accessKeyId,
|
||||
secretAccessKey: Config.aws.secretAccessKey,
|
||||
bucketCdn: Config.aws.s3BucketCdn,
|
||||
bucketUploads: Config.aws.s3BucketUploads,
|
||||
bucketStatic: Config.aws.s3BucketStatic,
|
||||
},
|
||||
},
|
||||
logger: Logger,
|
||||
metrics,
|
||||
tracing,
|
||||
requestMetricsCollector: requestTelemetry.metricsCollector,
|
||||
requestTracing: requestTelemetry.tracing,
|
||||
rateLimitService,
|
||||
rateLimitConfig:
|
||||
Config.rateLimit?.limit != null && Config.rateLimit.window_ms != null
|
||||
? {
|
||||
enabled: true,
|
||||
maxAttempts: Config.rateLimit.limit,
|
||||
windowMs: Config.rateLimit.window_ms,
|
||||
skipPaths: ['/_health'],
|
||||
}
|
||||
: null,
|
||||
onTelemetryRequest: async () => ({
|
||||
telemetry_enabled: isTelemetryActive(),
|
||||
service: 'fluxer_media_proxy',
|
||||
timestamp: new Date().toISOString(),
|
||||
}),
|
||||
});
|
||||
|
||||
const server = createServer(app, {port: Config.server.port});
|
||||
|
||||
Logger.info({port: Config.server.port}, `Starting Fluxer Media Proxy on port ${Config.server.port}`);
|
||||
|
||||
setupGracefulShutdown(
|
||||
async () => {
|
||||
await shutdown();
|
||||
await shutdownInstrumentation();
|
||||
await new Promise<void>((resolve) => {
|
||||
server.close(() => resolve());
|
||||
});
|
||||
},
|
||||
{logger: Logger},
|
||||
);
|
||||
53
fluxer/fluxer_media_proxy/src/Config.tsx
Normal file
53
fluxer/fluxer_media_proxy/src/Config.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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} from '@fluxer/config/src/ServiceConfigSlices';
|
||||
|
||||
const master = await loadConfig();
|
||||
const s3Config = master.s3;
|
||||
if (!s3Config?.buckets) {
|
||||
throw new Error('Media proxy requires S3 bucket configuration');
|
||||
}
|
||||
const mediaProxyBuckets = s3Config.buckets;
|
||||
|
||||
export const Config = {
|
||||
...extractBaseServiceConfig(master),
|
||||
env: master.env === 'test' ? 'development' : master.env,
|
||||
server: {
|
||||
port: master.services.media_proxy.port,
|
||||
},
|
||||
aws: {
|
||||
accessKeyId: s3Config.access_key_id,
|
||||
secretAccessKey: s3Config.secret_access_key,
|
||||
s3Endpoint: s3Config.endpoint,
|
||||
s3Region: s3Config.region,
|
||||
s3BucketCdn: mediaProxyBuckets.cdn,
|
||||
s3BucketUploads: mediaProxyBuckets.uploads,
|
||||
s3BucketStatic: mediaProxyBuckets.static,
|
||||
},
|
||||
mediaProxy: {
|
||||
secretKey: master.services.media_proxy.secret_key,
|
||||
requireCloudflareEdge: master.services.media_proxy.require_cloudflare_edge,
|
||||
staticMode: master.services.media_proxy.static_mode,
|
||||
},
|
||||
rateLimit: master.services.media_proxy.rate_limit ?? null,
|
||||
};
|
||||
|
||||
export type Config = typeof Config;
|
||||
30
fluxer/fluxer_media_proxy/src/Instrument.tsx
Normal file
30
fluxer/fluxer_media_proxy/src/Instrument.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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-media-proxy',
|
||||
config: Config,
|
||||
instrumentations: {
|
||||
aws: true,
|
||||
fetch: true,
|
||||
},
|
||||
});
|
||||
23
fluxer/fluxer_media_proxy/src/Logger.tsx
Normal file
23
fluxer/fluxer_media_proxy/src/Logger.tsx
Normal 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-media-proxy');
|
||||
export type Logger = FluxerLogger;
|
||||
47
fluxer/fluxer_media_proxy/src/Metrics.tsx
Normal file
47
fluxer/fluxer_media_proxy/src/Metrics.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 {
|
||||
CounterParams,
|
||||
GaugeParams,
|
||||
HistogramParams,
|
||||
MetricsInterface,
|
||||
} from '@fluxer/media_proxy/src/types/Metrics';
|
||||
import {recordCounter, recordGauge, recordHistogram} from '@fluxer/telemetry/src/Metrics';
|
||||
import {isTelemetryActive} from '@fluxer/telemetry/src/Telemetry';
|
||||
|
||||
export function createMetrics(): MetricsInterface {
|
||||
return {
|
||||
counter({name, dimensions = {}, value = 1}: CounterParams) {
|
||||
if (!isTelemetryActive()) return;
|
||||
recordCounter({name, dimensions, value});
|
||||
},
|
||||
histogram({name, dimensions = {}, valueMs}: HistogramParams) {
|
||||
if (!isTelemetryActive()) return;
|
||||
recordHistogram({name, dimensions, valueMs});
|
||||
},
|
||||
gauge({name, dimensions = {}, value}: GaugeParams) {
|
||||
if (!isTelemetryActive()) return;
|
||||
recordGauge({name, dimensions, value});
|
||||
},
|
||||
isEnabled() {
|
||||
return isTelemetryActive();
|
||||
},
|
||||
};
|
||||
}
|
||||
35
fluxer/fluxer_media_proxy/src/Tracing.tsx
Normal file
35
fluxer/fluxer_media_proxy/src/Tracing.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 {SpanOptions, TracingInterface} from '@fluxer/media_proxy/src/types/Tracing';
|
||||
import {addSpanEvent as telemetryAddSpanEvent, withSpan as telemetryWithSpan} from '@fluxer/telemetry/src/Tracing';
|
||||
import type {Attributes} from '@opentelemetry/api';
|
||||
|
||||
export function createTracing(): TracingInterface {
|
||||
return {
|
||||
async withSpan<T>(options: SpanOptions, fn: () => Promise<T>): Promise<T> {
|
||||
return telemetryWithSpan(options.name, async () => fn(), {
|
||||
attributes: options.attributes as Attributes | undefined,
|
||||
});
|
||||
},
|
||||
addSpanEvent(name: string, attributes?: Record<string, unknown>): void {
|
||||
telemetryAddSpanEvent(name, attributes as Attributes | undefined);
|
||||
},
|
||||
};
|
||||
}
|
||||
10
fluxer/fluxer_media_proxy/tsconfig.json
Normal file
10
fluxer/fluxer_media_proxy/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../tsconfigs/service.json",
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@app/*": ["./src/*"],
|
||||
"@fluxer/*": ["./../packages/*", "./../packages/*/src/index.tsx"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*"]
|
||||
}
|
||||
Reference in New Issue
Block a user