The minimalistic document archiving platform.
refactor(docs): added mising auth-secret in docker examples (#1070)
Corentin Thomasset58752a053604
diff --git a/README.md b/README.mdindex e228e6a3..0cf6583c 100644--- a/README.md+++ b/README.md@@ -81,9 +81,11 @@ Papra is dedicated to providing a simple yet highly configurable self-hosting exFor a quick start, simply run the following command:```bash-docker run -d --name papra -p 1221:1221 ghcr.io/papra-hq/papra:latest+docker run -d --name papra -p 1221:1221 -e AUTH_SECRET=a-dummy-secret-for-testing-purposes-only ghcr.io/papra-hq/papra:latest```+> The `AUTH_SECRET` above is fine for kicking the tires, but for any real instance you should generate your own with `openssl rand -hex 48` (or similar).+Please refer to the [self-hosting documentation](https://docs.papra.app/self-hosting/using-docker) for more information and configuration options.## Contributingdiff --git a/apps/docs/src/components/encryption-key-generator.astro b/apps/docs/src/components/random-hex-key-generator.astrosimilarity index 91%rename from apps/docs/src/components/encryption-key-generator.astrorename to apps/docs/src/components/random-hex-key-generator.astroindex 4f06d4ee..bf15b298 100644--- a/apps/docs/src/components/encryption-key-generator.astro+++ b/apps/docs/src/components/random-hex-key-generator.astro@@ -1,11 +1,17 @@---+type Props = {+ byteLength?: number;+};++const { byteLength = 32 } = Astro.props;+const iconSize = '20';const refreshIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}" height="${iconSize}" viewBox="0 0 24 24"><!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE --><path fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4m-4 4a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg>`;const copyIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}" height="${iconSize}" viewBox="0 0 24 24"><!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE --><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M7 9.667A2.667 2.667 0 0 1 9.667 7h8.666A2.667 2.667 0 0 1 21 9.667v8.666A2.667 2.667 0 0 1 18.333 21H9.667A2.667 2.667 0 0 1 7 18.333z"/><path d="M4.012 16.737A2 2 0 0 1 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1"/></g></svg>`;const copiedIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}" height="${iconSize}" viewBox="0 0 24 24"><!-- Icon from Tabler Icons by Paweł Kuna - https://github.com/tabler/tabler-icons/blob/master/LICENSE --><path fill="currentColor" d="M18.333 6A3.667 3.667 0 0 1 22 9.667v8.666A3.667 3.667 0 0 1 18.333 22H9.667A3.667 3.667 0 0 1 6 18.333V9.667A3.667 3.667 0 0 1 9.667 6zM15 2c1.094 0 1.828.533 2.374 1.514a1 1 0 1 1-1.748.972C15.405 4.088 15.284 4 15 4H5c-.548 0-1 .452-1 1v9.998c0 .32.154.618.407.805l.1.065a1 1 0 1 1-.99 1.738A3 3 0 0 1 2 15V5c0-1.652 1.348-3 3-3zm1.293 9.293L13 14.585l-1.293-1.292a1 1 0 0 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 0 0-1.414-1.414"/></svg>`;----<div class="key-generator">+<div class="key-generator" data-byte-length={byteLength}><div class="key-row"><input type="text" class="key-input" readonly /><button class="cbtn btn-refresh" title="Generate new key">@@ -22,9 +28,8 @@ const copiedIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}"</div><script>- function generateKey({ keyInputElement }: { keyInputElement: HTMLInputElement }) {- // Generate a 32-byte (256-bit) encryption key- const array = new Uint8Array(32);+ function generateKey({ keyInputElement, byteLength }: { keyInputElement: HTMLInputElement; byteLength: number }) {+ const array = new Uint8Array(byteLength);crypto.getRandomValues(array);// Convert to hex format@@ -34,7 +39,7 @@ const copiedIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}"function copyToClipboard({ keyInputElement, copyButtonElement, iconCopyElement, iconCopiedElement }: { keyInputElement: HTMLInputElement; copyButtonElement: HTMLButtonElement; iconCopyElement: HTMLSpanElement; iconCopiedElement: HTMLSpanElement }) {keyInputElement.select();- keyInputElement.setSelectionRange(0, 64); // For mobile devices+ keyInputElement.setSelectionRange(0, keyInputElement.value.length); // For mobile devicesnavigator.clipboard.writeText(keyInputElement.value).then(() => {iconCopyElement.classList.add('hidden');@@ -60,10 +65,11 @@ const copiedIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="${iconSize}"const keyInputElement = keyGenerator.querySelector<HTMLInputElement>('.key-input')!;const iconCopyElement = keyGenerator.querySelector<HTMLSpanElement>('.icon-copy')!;const iconCopiedElement = keyGenerator.querySelector<HTMLSpanElement>('.icon-copied')!;+ const byteLength = Number.parseInt(keyGenerator.getAttribute('data-byte-length') ?? '32', 10);- generateKey({ keyInputElement });+ generateKey({ keyInputElement, byteLength });- refreshButtonElement.addEventListener('click', () => generateKey({ keyInputElement }));+ refreshButtonElement.addEventListener('click', () => generateKey({ keyInputElement, byteLength }));copyButtonElement.addEventListener('click', () => copyToClipboard({ copyButtonElement, keyInputElement, iconCopyElement, iconCopiedElement }));});</script>diff --git a/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx b/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdxindex db5dc42f..69070726 100644--- a/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx+++ b/apps/docs/src/content/docs/02-self-hosting/01-using-docker.mdx@@ -4,6 +4,8 @@ description: Self-host Papra using Docker.slug: self-hosting/using-docker---import { Steps } from '@astrojs/starlight/components';+import { Tabs, TabItem } from '@astrojs/starlight/components';+import SecretKeyGenerator from '../../../components/random-hex-key-generator.astro';Papra provides optimized Docker images for streamlined deployment. This method is recommended for users seeking a production-ready setup with minimal maintenance overhead.@@ -25,13 +27,27 @@ docker --version## Quick Deployment-Launch Papra with default configuration using:+Papra requires an `AUTH_SECRET` to run. Generate a secure one using the generator below or the OpenSSL command:++<Tabs>+ <TabItem label="Key generator">+ <SecretKeyGenerator byteLength={48} />+ </TabItem>+ <TabItem label="OpenSSL command">+ ```bash+ openssl rand -hex 48+ ```+ </TabItem>+</Tabs>++Then launch Papra with default configuration using:```bashdocker run -d \--name papra \--restart unless-stopped \--env APP_BASE_URL=http://localhost:1221 \+ --env AUTH_SECRET=<your-auth-secret> \-p 1221:1221 \ghcr.io/papra-hq/papra:latest```@@ -66,11 +82,14 @@ For production deployments, mount host directories to preserve application data2. Launch Container with Volume Binding+ Make sure you have generated an `AUTH_SECRET` (see the [Quick Deployment](#quick-deployment) section above), then run:+```bashdocker run -d \--name papra \--restart unless-stopped \--env APP_BASE_URL=http://localhost:1221 \+ --env AUTH_SECRET=<your-auth-secret> \-p 1221:1221 \-v $(pwd)/papra-data:/app/app-data \--user $(id -u):$(id -g) \diff --git a/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx b/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdxindex a246c97e..e040665c 100644--- a/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx+++ b/apps/docs/src/content/docs/02-self-hosting/02-using-docker-compose.mdx@@ -5,6 +5,8 @@ description: Self-host Papra using Docker Compose.---import { Steps } from '@astrojs/starlight/components';+import { Tabs, TabItem } from '@astrojs/starlight/components';+import SecretKeyGenerator from '../../../components/random-hex-key-generator.astro';This guide covers how to deploy Papra using Docker Compose, ideal for users who prefer declarative configurations or plan to integrate Papra into a broader service stack.@@ -37,9 +39,26 @@ docker compose versionmkdir -p papra/app-data/{db,documents} && cd papra```-2. Create Docker Compose file+2. Generate an Auth Secret- Create a file named `docker-compose.yml` with the following content:+ Papra requires an `AUTH_SECRET` to run. Generate a secure one using the generator below or the OpenSSL command:++ <Tabs>+ <TabItem label="Key generator">+ <SecretKeyGenerator byteLength={48} />+ </TabItem>+ <TabItem label="OpenSSL command">+ ```bash+ openssl rand -hex 48+ ```+ </TabItem>+ </Tabs>++ Keep the value handy, you will set it as an environment variable in the next step.++3. Create Docker Compose file++ Create a file named `docker-compose.yml` with the following content (replacing `<your-auth-secret>` with the value generated in the previous step):```yamlservices:@@ -49,12 +68,14 @@ docker compose versionrestart: unless-stoppedports:- "1221:1221"+ environment:+ - AUTH_SECRET=<your-auth-secret>volumes:- ./app-data:/app/app-datauser: "${UID}:${GID}"```-3. Start Papra+4. Start PapraFrom the directory containing your `docker-compose.yml` file, run:@@ -64,7 +85,7 @@ docker compose versionThis command downloads the latest Papra image, sets up the container, and starts the Papra service. The `UID` and `GID` variables are used to set the user and group for the container, ensuring proper file ownership. If you don't want to use the `UID` and `GID` variables, you can replace the image with the rootful variant.-4. Access Papra+5. Access PapraOnce your container is running, access Papra via your browser at:@@ -74,7 +95,7 @@ docker compose versionYour Papra instance is now ready for use!-5. To go further+6. To go furtherCheck the [configuration](/self-hosting/configuration) page for more information on how to configure your Papra instance.diff --git a/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx b/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdxindex 75140541..93e783ac 100644--- a/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx+++ b/apps/docs/src/content/docs/02-self-hosting/04-from-source.mdx@@ -6,7 +6,7 @@ slug: self-hosting/from-sourceimport { Steps } from '@astrojs/starlight/components';import { Tabs, TabItem } from '@astrojs/starlight/components';import { Aside } from '@astrojs/starlight/components';-import SecretKeyGenerator from '../../../components/encryption-key-generator.astro';+import SecretKeyGenerator from '../../../components/random-hex-key-generator.astro';This guide covers building and running Papra directly from source code. This method is an alternative to Docker for users who prefer running applications natively on their system.diff --git a/apps/docs/src/content/docs/03-guides/05-setup-document-encryption.mdx b/apps/docs/src/content/docs/03-guides/05-setup-document-encryption.mdxindex 84971993..417a7860 100644--- a/apps/docs/src/content/docs/03-guides/05-setup-document-encryption.mdx+++ b/apps/docs/src/content/docs/03-guides/05-setup-document-encryption.mdx@@ -7,7 +7,7 @@ import { Steps } from '@astrojs/starlight/components';import { Aside } from '@astrojs/starlight/components';import { Code } from '@astrojs/starlight/components';import { Tabs, TabItem } from '@astrojs/starlight/components';-import EncryptionKeyGenerator from '../../../components/encryption-key-generator.astro';+import EncryptionKeyGenerator from '../../../components/random-hex-key-generator.astro';<Aside type="note">Document encryption is available in Papra v0.9.0 and above.