mirror of
https://github.com/wekan/wekan.git
synced 2026-11-20 15:45:01 -05:00
A grain has one login (Sandstorm's), one database (FerretDB on SQLite) and one mailbox (the grain's own address), but the .spk carried every login package WeKan has and a FerretDB with the PostgreSQL, MySQL and SAP HANA handlers. releases/sandstorm-slim-spk.sh, used by sandstorm.yml, release-all.yml's build-sandstorm job and build.sh's "Make the .spk package", builds with the package profile of releases/sandstorm-slim.mjs - accounts-password, 2FA, passwordless, lockout, OAuth2/OIDC, CAS, LDAP, SAML and the seven social logins removed from a copy of .meteor/packages for that one build, then restored - trims the bundle for a linux/x64 grain, verifies none of those packages got in and packs with spk pack (meteor-spk pack rebuilds and would undo the trim). sandstorm-src/build-deps.sh builds FerretDB from source with ferretdb_no_postgresql,ferretdb_no_mysql. Under Sandstorm the Admin Panel hides the E-mail, Login, Locked users, SAML, LDAP, OAuth2, CAS, Header login, OAuth providers and Passwordless panes, Attachments / Database migration, the Email-to-card IMAP and webhook settings, the New user button and the password fields; a hidden pane opened by URL lands on the first visible one. POST /users/login and /users/register answer 404 sandstorm-sso-only, database migration is refused and the IMAP/webhook settings are not stored. Without accounts-password the server creates Accounts.emailTemplates with the package's defaults and marks useraccounts initialised, which otherwise stopped the first grain. Against wekan-12.63-sandstorm.spk, built from the same source: 181,307,364 instead of 185,271,476 bytes (-3.8 MiB, -2.1 %), unpacked 26.7 MiB smaller. Docker, Snap and the bundles build from the full package list, and a test fails if that list is slimmed. Tested on a local Sandstorm 0.308: a grain starts, a board, a list and a card are created, and the removed options are not shown. tests/sandstormSlim.test.cjs and tests/playwright/specs/sandstorm-slim.e2e.js pin it. Design: docs/Platforms/FOSS/Container/Sandstorm/Smaller-wekan-spk.md. Thanks to xet7 !
69 lines
3.5 KiB
JavaScript
69 lines
3.5 KiB
JavaScript
// ============================================================================
|
|
// WeKan Server Entry Point
|
|
//
|
|
// Uses require() to guarantee bootstrap runs before any model code.
|
|
// ============================================================================
|
|
|
|
// 0. Secrets from files (#5724): MAIL_URL_FILE and S3_SECRET_KEY_FILE fill
|
|
// MAIL_URL and S3_SECRET_KEY before any code reads them. Never the values
|
|
// in the log - only where each came from.
|
|
{
|
|
const { applySecretFiles, retiredSecretFiles } = require('/models/lib/envSecretFiles');
|
|
const report = applySecretFiles(process.env);
|
|
for (const [name, source] of Object.entries(report)) {
|
|
if (source === 'file') console.log(`[secrets] ${name} read from ${name}_FILE`);
|
|
else if (source.startsWith('file-error:')) console.error(`[secrets] ${name}_FILE cannot be used (${source.slice(11)}); ${name} is unset`);
|
|
}
|
|
for (const { name, replacement } of retiredSecretFiles(process.env)) {
|
|
console.warn(`[secrets] ${name} is not read by WeKan; use ${replacement} instead`);
|
|
}
|
|
}
|
|
|
|
// 0b. #6762: TLS trusts the operating system's certificate authorities as well
|
|
// as Node.js's own, so a company root CA installed on the server verifies
|
|
// LDAPS, mail, webhooks and OAuth2 the way it does for every other program.
|
|
// Before anything opens a connection.
|
|
{
|
|
const { trustSystemCaCertificates } = require('/server/lib/systemCaCertificates');
|
|
try {
|
|
const result = trustSystemCaCertificates();
|
|
if (result.applied) {
|
|
console.log(`[tls] trusting ${result.added} certificate authorities of the operating system as well as Node.js's own`);
|
|
}
|
|
} catch (e) {
|
|
console.warn(`[tls] the operating system's certificate authorities could not be read (${e.message}); only Node.js's own are trusted`);
|
|
}
|
|
}
|
|
|
|
// 0c. The Meteor 3.5.3 security fixes in packages/ (allow-deny, ddp-server,
|
|
// dynamic-import, google-oauth, facebook-oauth) report refused attempts to
|
|
// Admin Panel / Problems through this hook. Before the first connection.
|
|
require('/server/lib/meteorSecurityHook').installMeteorSecurityHook();
|
|
|
|
// 0d. The Sandstorm .spk is built without accounts-password, which is what
|
|
// creates Accounts.emailTemplates - and every WeKan e-mail reads its From
|
|
// address from it. Made here, with the package's own defaults, when absent.
|
|
// server/lib/accountsEmailTemplates.js
|
|
require('/server/lib/accountsEmailTemplates').ensureEmailTemplates(
|
|
require('meteor/accounts-base').Accounts, require('meteor/meteor').Meteor.absoluteUrl());
|
|
|
|
// 1. Helpers polyfill (server no-op for .helpers())
|
|
require('/imports/collectionHelpers');
|
|
|
|
// 2. Collection2 (server-only)
|
|
require('meteor/aldeed:collection2');
|
|
// 2b. ...and collection2's attachSchema itself, NOW. It lives in the package's
|
|
// lazy main module, which only aldeed:schema-index loads, through an ASYNC
|
|
// Collection2.load(). Nothing waited for that: models/ attached their
|
|
// schemas with whichever attachSchema was there first, collection2's or the
|
|
// bare shim in imports/collectionHelpers.js, which stores the schema and
|
|
// never cleans a write. With every package of the full build loaded first,
|
|
// the import happened to win; the Sandstorm .spk, built with fewer packages
|
|
// (releases/sandstorm-slim.mjs), reached models/ sooner, and a new board's
|
|
// swimlanes were stored without archived/sort/type - so the board opened
|
|
// empty. Loading it here, before step 3, ends the race for every build.
|
|
require('meteor/aldeed:collection2/main');
|
|
|
|
// 3. Load all application code
|
|
require('/server/imports');
|