Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

feat(docs): add full .env configuration display in self-hosting guide (#198)

Corentin Thomasset542225fabcf2
diff --git a/apps/docs/src/config.data.ts b/apps/docs/src/config.data.ts
index 536ce7ce..2c8c988a 100644
--- a/apps/docs/src/config.data.ts
+++ b/apps/docs/src/config.data.ts
@@ -52,4 +52,13 @@ ${documentation}
`.trim()).join('\n\n---\n\n');
-export { mdSections };
+const fullDotEnv = rows.map(({ env, defaultValue, documentation }) => {
+ const isEmptyDefaultValue = isNil(defaultValue) || (isArray(defaultValue) && isEmpty(defaultValue)) || defaultValue === '';
+
+ return [
+ `# ${documentation}`,
+ `# ${env}=${isEmptyDefaultValue ? '' : defaultValue}`,
+ ].join('\n');
+}).join('\n\n');
+
+export { fullDotEnv, mdSections };
diff --git a/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx b/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx
index 9a5e663b..34bc7d41 100644
--- a/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx
+++ b/apps/docs/src/content/docs/02-self-hosting/03-configuration.mdx
@@ -4,10 +4,11 @@ slug: self-hosting/configuration
---
-import { mdSections } from '../../../config.data.ts';
+import { mdSections, fullDotEnv } from '../../../config.data.ts';
import { marked } from 'marked';
import { Tabs, TabItem } from '@astrojs/starlight/components';
import { Aside } from '@astrojs/starlight/components';
+import { Code } from '@astrojs/starlight/components';
Configuring your self hosted Papra allows you to customize the application to better suit your environment and requirements. This guide covers the key environment variables you can set to control various aspects of the application, including port settings, security options, and storage configurations.
@@ -73,10 +74,15 @@ Example of configuration files:
You'll find the complete list of configuration variables with their environment variables equivalents and path for files in the next section.
+## Complete .env
+
+Here is the full configuration file that you can use to configure Papra. The variables values are the default values.
+
+<Code code={fullDotEnv} language="env" title=".env" />
+
## Configuration variables
Here is the complete list of configuration variables that you can use to configure Papra. You can set these variables in the `.env` file or pass them as environment variables when running the Docker container.
<Fragment set:html={marked.parse(mdSections)} />
-Coming soon.
diff --git a/apps/papra-server/src/modules/app/database/database.config.ts b/apps/papra-server/src/modules/app/database/database.config.ts
index 176cf6af..0e0303f3 100644
--- a/apps/papra-server/src/modules/app/database/database.config.ts
+++ b/apps/papra-server/src/modules/app/database/database.config.ts
@@ -3,7 +3,7 @@ import { z } from 'zod';
export const databaseConfig = {
url: {
- doc: 'The URL of the database',
+ doc: 'The URL of the database (default as "file:./app-data/db/db.sqlite" when using docker)',
schema: z.string().url(),
default: 'file:./db.sqlite',
env: 'DATABASE_URL',
diff --git a/apps/papra-server/src/modules/config/config.ts b/apps/papra-server/src/modules/config/config.ts
index 23154ade..ff6a9841 100644
--- a/apps/papra-server/src/modules/config/config.ts
+++ b/apps/papra-server/src/modules/config/config.ts
@@ -26,6 +26,20 @@ export const configDefinition = {
default: 'development',
env: 'NODE_ENV',
},
+ client: {
+ baseUrl: {
+ doc: 'The URL of the client',
+ schema: z.string().url(),
+ default: 'http://localhost:3000',
+ env: 'CLIENT_BASE_URL',
+ },
+ oauthRedirectUrl: {
+ doc: 'The URL to redirect to after OAuth',
+ schema: z.string().url(),
+ default: 'http://localhost:3000/confirm',
+ env: 'CLIENT_OAUTH_REDIRECT_URL',
+ },
+ },
server: {
baseUrl: {
doc: 'The base URL of the server',
@@ -61,26 +75,13 @@ export const configDefinition = {
env: 'SERVER_CORS_ORIGINS',
},
servePublicDir: {
- doc: 'Whether to serve the public directory',
+ doc: 'Whether to serve the public directory (default as true when using docker)',
schema: booleanishSchema,
default: false,
env: 'SERVER_SERVE_PUBLIC_DIR',
},
},
- client: {
- baseUrl: {
- doc: 'The URL of the client',
- schema: z.string().url(),
- default: 'http://localhost:3000',
- env: 'CLIENT_BASE_URL',
- },
- oauthRedirectUrl: {
- doc: 'The URL to redirect to after OAuth',
- schema: z.string().url(),
- default: 'http://localhost:3000/confirm',
- env: 'CLIENT_OAUTH_REDIRECT_URL',
- },
- },
+
database: databaseConfig,
documents: documentsConfig,
documentsStorage: documentStorageConfig,
diff --git a/apps/papra-server/src/modules/documents/storage/document-storage.config.ts b/apps/papra-server/src/modules/documents/storage/document-storage.config.ts
index 3d994bd0..ec3472a2 100644
--- a/apps/papra-server/src/modules/documents/storage/document-storage.config.ts
+++ b/apps/papra-server/src/modules/documents/storage/document-storage.config.ts
@@ -12,7 +12,7 @@ export const documentStorageConfig = {
env: 'DOCUMENT_STORAGE_MAX_UPLOAD_SIZE',
},
driver: {
- doc: 'The driver to use for document storage',
+ doc: `The driver to use for document storage, values can be one of: ${[FS_STORAGE_DRIVER_NAME, S3_STORAGE_DRIVER_NAME, IN_MEMORY_STORAGE_DRIVER_NAME].map(x => `\`${x}\``).join(', ')}`,
schema: z.enum([FS_STORAGE_DRIVER_NAME, S3_STORAGE_DRIVER_NAME, IN_MEMORY_STORAGE_DRIVER_NAME]),
default: FS_STORAGE_DRIVER_NAME,
env: 'DOCUMENT_STORAGE_DRIVER',
@@ -20,7 +20,7 @@ export const documentStorageConfig = {
drivers: {
filesystem: {
root: {
- doc: 'The root directory to store documents in',
+ doc: 'The root directory to store documents in (default as "./app-data/documents" when using docker)',
schema: z.string(),
default: './local-documents',
env: 'DOCUMENT_STORAGE_FILESYSTEM_ROOT',
diff --git a/apps/papra-server/src/modules/emails/emails.config.ts b/apps/papra-server/src/modules/emails/emails.config.ts
index 38b935ac..5970a41e 100644
--- a/apps/papra-server/src/modules/emails/emails.config.ts
+++ b/apps/papra-server/src/modules/emails/emails.config.ts
@@ -4,7 +4,7 @@ import { booleanishSchema } from '../config/config.schemas';
export const emailsConfig = {
resendApiKey: {
- doc: 'The API key for Resend',
+ doc: 'The API key for Resend (use to send emails)',
schema: z.string(),
default: 'set-me',
env: 'RESEND_API_KEY',
diff --git a/apps/papra-server/src/modules/plans/plans.config.ts b/apps/papra-server/src/modules/plans/plans.config.ts
index b4f61357..806d2c8c 100644
--- a/apps/papra-server/src/modules/plans/plans.config.ts
+++ b/apps/papra-server/src/modules/plans/plans.config.ts
@@ -10,13 +10,13 @@ export const organizationPlansConfig = {
env: 'IS_FREE_PLAN_UNLIMITED',
},
plusPlanPriceId: {
- doc: 'The price id of the plus plan',
+ doc: 'The price id of the plus plan (useless for self-hosting)',
schema: z.string(),
default: 'change-me',
env: 'PLANS_PLUS_PLAN_PRICE_ID',
},
familyPlanPriceId: {
- doc: 'The price id of the family plan',
+ doc: 'The price id of the family plan (useless for self-hosting)',
schema: z.string(),
default: 'change-me',
env: 'PLANS_FAMILY_PLAN_PRICE_ID',
diff --git a/apps/papra-server/src/modules/subscriptions/subscriptions.config.ts b/apps/papra-server/src/modules/subscriptions/subscriptions.config.ts
index 4e39a26d..8731d5ec 100644
--- a/apps/papra-server/src/modules/subscriptions/subscriptions.config.ts
+++ b/apps/papra-server/src/modules/subscriptions/subscriptions.config.ts
@@ -3,13 +3,13 @@ import { z } from 'zod';
export const subscriptionsConfig = {
stripeApiSecretKey: {
- doc: 'The API secret key for the Stripe',
+ doc: 'The API secret key for the Stripe (useless for self-hosting)',
schema: z.string(),
default: 'change-me',
env: 'STRIPE_API_SECRET_KEY',
},
stripeWebhookSecret: {
- doc: 'The secret for the Stripe webhook',
+ doc: 'The secret for the Stripe webhook (useless for self-hosting)',
schema: z.string(),
default: 'change-me',
env: 'STRIPE_WEBHOOK_SECRET',