Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

refactor(docker): added base url override in docker (#320)

Corentin Thomasset8ccdb748349a
diff --git a/.changeset/early-horses-rescue.md b/.changeset/early-horses-rescue.md
new file mode 100644
index 00000000..60dff5ed
--- /dev/null
+++ b/.changeset/early-horses-rescue.md
@@ -0,0 +1,5 @@
+---
+"@papra/app-server": minor
+---
+
+Set CLIENT_BASE_URL default value to http://localhost:1221 in Dockerfiles
diff --git a/.changeset/hip-peaches-worry.md b/.changeset/hip-peaches-worry.md
new file mode 100644
index 00000000..67fc3462
--- /dev/null
+++ b/.changeset/hip-peaches-worry.md
@@ -0,0 +1,5 @@
+---
+"@papra/docs": patch
+---
+
+Added base url configuration in docker compose generator
diff --git a/apps/docs/src/config.data.ts b/apps/docs/src/config.data.ts
index 48696a63..0d37d197 100644
--- a/apps/docs/src/config.data.ts
+++ b/apps/docs/src/config.data.ts
@@ -33,11 +33,14 @@ const rows = configDetails
const rawDocumentation = formatDoc(doc);
+ // The client baseUrl default value is overridden in the Dockerfiles
+ const defaultOverride = path.join('.') === 'client.baseUrl' ? 'http://localhost:1221' : undefined;
+
return {
path,
env,
documentation: rawDocumentation,
- defaultValue: isEmptyDefaultValue ? undefined : defaultValue,
+ defaultValue: defaultOverride ?? (isEmptyDefaultValue ? undefined : defaultValue),
};
});
diff --git a/apps/docs/src/docker-compose-generator/dc-generator.astro b/apps/docs/src/docker-compose-generator/dc-generator.astro
index a57b439c..d606a9ff 100644
--- a/apps/docs/src/docker-compose-generator/dc-generator.astro
+++ b/apps/docs/src/docker-compose-generator/dc-generator.astro
@@ -16,6 +16,8 @@ services:
- 1221:1221
environment:
- AUTH_SECRET=change-me
+ - CLIENT_BASE_URL=http://localhost:1221
+ - SERVER_BASE_URL=http://localhost:1221
volumes:
- ./app-data:/app/app-data
user: 1000:1000
@@ -33,6 +35,11 @@ const dcHtml = await codeToHtml(defaultDockerCompose, { theme: 'vitesse-black',
<input id="port" class="input-field" value="1221" type="number" min="1024" max="65535" placeholder="eg: 1221" />
</div>
+<div class="flex items-center gap-2 mt-1">
+ <label for="app-base-url" class="min-w-32">App base URL</label>
+ <input id="app-base-url" class="input-field" type="text" placeholder="eg: https://papra.example.com" value="http://localhost:1221" />
+</div>
+
<div class="flex items-center gap-2 mt-1">
<label for="source" class="min-w-32">Image source</label>
<select class="input-field mt-0" id="source">
@@ -153,6 +160,7 @@ const portInput = document.getElementById('port') as HTMLInputElement;
const sourceSelect = document.getElementById('source') as HTMLSelectElement;
const serviceNameInput = document.getElementById('service-name') as HTMLInputElement;
const authSecretInput = document.getElementById('auth-secret') as HTMLInputElement;
+const appBaseUrlInput = document.getElementById('app-base-url') as HTMLInputElement;
const refreshSecretButton = document.getElementById('refresh-secret');
const copyButton = document.getElementById('copy-button');
const dockerComposeOutput = document.getElementById('docker-compose-output');
@@ -193,12 +201,19 @@ function getDockerComposeYml() {
const intakeEmailEnabled = intakeEmailEnabledSelect.value === 'true';
const intakeDriver = intakeDriverSelect.value;
const webhookSecret = webhookSecretInput.value;
+ const appBaseUrl = appBaseUrlInput.value.trim();
const version = isRootless ? 'latest' : 'latest-root';
const fullImage = `${image}:${version}`;
+ // Determine base URLs
+ const clientBaseUrl = appBaseUrl || `http://localhost:${port}`;
+ const serverBaseUrl = appBaseUrl || `http://localhost:${port}`;
+
const environment = [
`AUTH_SECRET=${authSecret}`,
+ `CLIENT_BASE_URL=${clientBaseUrl}`,
+ `SERVER_BASE_URL=${serverBaseUrl}`,
isIngestionEnabled && 'INGESTION_FOLDER_IS_ENABLED=true',
intakeEmailEnabled && 'INTAKE_EMAILS_IS_ENABLED=true',
intakeEmailEnabled && `INTAKE_EMAILS_DRIVER=${intakeDriver}`,
@@ -336,6 +351,7 @@ portInput.addEventListener('input', updateDockerCompose);
sourceSelect.addEventListener('change', updateDockerCompose);
serviceNameInput.addEventListener('input', updateDockerCompose);
authSecretInput.addEventListener('input', updateDockerCompose);
+appBaseUrlInput.addEventListener('input', updateDockerCompose);
refreshSecretButton?.addEventListener('click', handleRefreshSecret);
copyButton?.addEventListener('click', handleCopy);
downloadButton?.addEventListener('click', handleDownload);
diff --git a/apps/papra-server/src/modules/config/config.ts b/apps/papra-server/src/modules/config/config.ts
index 958cdf65..65485aa4 100644
--- a/apps/papra-server/src/modules/config/config.ts
+++ b/apps/papra-server/src/modules/config/config.ts
@@ -29,21 +29,15 @@ export const configDefinition = {
},
client: {
baseUrl: {
- doc: 'The URL of the client',
+ doc: 'The URL of the client, when using docker, it should be the same as the server baseUrl',
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',
+ doc: 'The base URL of the server, when using docker, it should be the same as the client baseUrl',
schema: z.string().url(),
default: 'http://localhost:1221',
env: 'SERVER_BASE_URL',
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d2f6df3b..3779e9fb 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -41,6 +41,7 @@ ENV DATABASE_URL=file:./app-data/db/db.sqlite
ENV DOCUMENT_STORAGE_FILESYSTEM_ROOT=./app-data/documents
ENV PAPRA_CONFIG_DIR=./app-data
ENV EMAILS_DRY_RUN=true
+ENV CLIENT_BASE_URL=http://localhost:1221
RUN mkdir -p ./app-data/db ./app-data/documents ./ingestion
diff --git a/docker/Dockerfile.rootless b/docker/Dockerfile.rootless
index 19fba746..399585ae 100644
--- a/docker/Dockerfile.rootless
+++ b/docker/Dockerfile.rootless
@@ -52,5 +52,6 @@ ENV DOCUMENT_STORAGE_FILESYSTEM_ROOT=./app-data/documents
ENV PAPRA_CONFIG_DIR=./app-data
ENV INGESTION_FOLDER_ROOT=./ingestion
ENV EMAILS_DRY_RUN=true
+ENV CLIENT_BASE_URL=http://localhost:1221
CMD ["pnpm", "start:with-migrations"]
\ No newline at end of file