lasuite-docs-collaboration-server: init at 3.3.0

This commit is contained in:
soyouzpanda 2025-04-25 18:11:05 +02:00
parent d2c305e288
commit 5d737e24b0
No known key found for this signature in database
2 changed files with 143 additions and 0 deletions

View file

@ -0,0 +1,43 @@
From ab1de49ad9c23e73cddc4dd82a9fede4f56d28d0 Mon Sep 17 00:00:00 2001
From: soyouzpanda <soyouzpanda@soyouzpanda.fr>
Date: Tue, 29 Apr 2025 17:09:51 +0200
Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=A8(frontend)=20support=20`=5FFILE`?=
=?UTF-8?q?=20envuronment=20variables=20for=20secrets?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Allow configuration variables that handles secrets to be read from a
file given in an environment variable.
---
src/frontend/servers/y-provider/src/env.ts | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/servers/y-provider/src/env.ts b/servers/y-provider/src/env.ts
index fe281930..e0e02cf5 100644
--- a/servers/y-provider/src/env.ts
+++ b/servers/y-provider/src/env.ts
@@ -1,11 +1,16 @@
+import { readFileSync } from 'fs';
+
export const COLLABORATION_LOGGING =
process.env.COLLABORATION_LOGGING || 'false';
export const COLLABORATION_SERVER_ORIGIN =
process.env.COLLABORATION_SERVER_ORIGIN || 'http://localhost:3000';
-export const COLLABORATION_SERVER_SECRET =
- process.env.COLLABORATION_SERVER_SECRET || 'secret-api-key';
-export const Y_PROVIDER_API_KEY =
- process.env.Y_PROVIDER_API_KEY || 'yprovider-api-key';
+export const COLLABORATION_SERVER_SECRET = process.env
+ .COLLABORATION_SERVER_SECRET_FILE
+ ? readFileSync(process.env.COLLABORATION_SERVER_SECRET_FILE, 'utf-8')
+ : process.env.COLLABORATION_SERVER_SECRET || 'secret-api-key';
+export const Y_PROVIDER_API_KEY = process.env.Y_PROVIDER_API_KEY_FILE
+ ? readFileSync(process.env.Y_PROVIDER_API_KEY_FILE, 'utf-8')
+ : process.env.Y_PROVIDER_API_KEY || 'yprovider-api-key';
export const PORT = Number(process.env.PORT || 4444);
export const SENTRY_DSN = process.env.SENTRY_DSN || '';
export const COLLABORATION_BACKEND_BASE_URL =
--
2.47.2

View file

@ -0,0 +1,100 @@
{
lib,
fetchFromGitHub,
stdenv,
fetchYarnDeps,
nodejs,
fixup-yarn-lock,
yarn,
makeWrapper,
}:
stdenv.mkDerivation rec {
pname = "lasuite-docs-collaboration-server";
version = "3.3.0";
src = fetchFromGitHub {
owner = "suitenumerique";
repo = "docs";
tag = "v${version}";
hash = "sha256-SLTNkK578YhsDtVBS4vH0E/rXx+rXZIyXMhqwr95QEA=";
};
sourceRoot = "source/src/frontend";
patches = [
# Support for $ENVIRONMENT_VARIABLE_FILE to be able to pass secret file
# See: https://github.com/suitenumerique/docs/pull/912
./environment_variables.patch
];
offlineCache = fetchYarnDeps {
yarnLock = "${src}/src/frontend/yarn.lock";
hash = "sha256-ei4xj+W2j5O675cpMAG4yCB3cPLeYwMhqKTacPWFjoo=";
};
nativeBuildInputs = [
nodejs
fixup-yarn-lock
yarn
makeWrapper
];
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
yarn config --offline set yarn-offline-mirror "$offlineCache"
fixup-yarn-lock yarn.lock
# Fixup what fixup-yarn-lock does not fix. Result in error if not fixed.
substituteInPlace yarn.lock \
--replace-fail '"@fastify/otel@https://codeload.github.com/getsentry/fastify-otel/tar.gz/ae3088d65e286bdc94ac5d722573537d6a6671bb"' '"@fastify/otel@^0.8.0"'
yarn install \
--frozen-lockfile \
--force \
--production=false \
--ignore-engines \
--ignore-platform \
--ignore-scripts \
--no-progress \
--non-interactive \
--offline
patchShebangs node_modules
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
yarn --offline COLLABORATION_SERVER run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{lib,bin}
cp -r {apps,node_modules,packages,servers} $out/lib
makeWrapper ${lib.getExe nodejs} "$out/bin/docs-collaboration-server" \
--add-flags "$out/lib/servers/y-provider/dist/start-server.js" \
--set NODE_PATH "$out/lib/node_modules"
runHook postInstall
'';
meta = {
description = "A collaborative note taking, wiki and documentation platform that scales. Built with Django and React. Opensource alternative to Notion or Outline";
homepage = "https://github.com/suitenumerique/docs";
changelog = "https://github.com/suitenumerique/docs/blob/${src.tag}/CHANGELOG.md";
mainProgram = "docs-collaboration-server";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ soyouzpanda ];
platforms = lib.platforms.all;
};
}