Files
David Rotermund c7eb257a53 Restoring the support images: \n png2pdf: \n Without this cache you need to convert png to pdf manualy or you risk a compile timeout (had this problem yesterday and did the conversion manualy. Compile time reduction was from time out to 3sec.)\n env settings required:\n (mount point INSIDE the container)\n CLSI_CACHE_PATH: /var/lib/overleaf/data/cache \n (Mount point outside of the container i.e. host, based on your compose volume rules)\n SANDBOXED_COMPILES_HOST_DIR_CACHE: points to the same folder outside of the container\n Test parameter:\n PNG2PDF_MIN_FILE_SIZE_BYTES: 1024 \n ENABLE_PNG2PDF_CONVERSIONS: true \n PNG2PDF_IMAGE: sharelatex/png2pdf:2026-06-24 \n\n It acts on slow png conversions and not all. Hence the texlive image needs this detection hook as the creator intended it. I added them to:\n https://github.com/davrot/texlive-full/tree/png2pdf-slow \n It is a modification of the LatexMK file. Without the hook no png files are cached as pdf.\n\n pdftocairo: \n The creater intended that pdf to thumbnail / preview are created by an external container for safety reasons. \n The only action we do a to-thumbnail-conversion is in the template generation. Since we don't want to disapoint the creater, I restored this safety feature.\n env settings required:\n (default: local imagemagick; other options are local pdftocairo and container pdftocairo via pdftocairo-sandbox)\n CONVERTER: pdftocairo-sandbox \n CONVERSION_SANDBOX_IMAGE: sharelatex/pdftocairo:24.02 \n (mount point INSIDE the container)\n CONVERSION_SANDBOX_DIR: /var/lib/overleaf/tmp/conversions \n (Mount point outside of the container i.e. host, based on your compose volume rules)\n CONVERSION_SANDBOX_HOST_DIR: points to the same folder outside of the container\n
2026-10-24 14:30:35 +00:00

130 lines
4.8 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Path = require('node:path')
// environment variables renamed for consistency
// use AWS_ACCESS_KEY_ID-style going forward
if (process.env.AWS_KEY && !process.env.AWS_ACCESS_KEY_ID) {
process.env.AWS_ACCESS_KEY_ID = process.env.AWS_KEY
}
if (process.env.AWS_SECRET && !process.env.AWS_SECRET_ACCESS_KEY) {
process.env.AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET
}
// pre-backend setting, fall back to old behaviour
if (process.env.BACKEND == null) {
if (process.env.AWS_ACCESS_KEY_ID || process.env.S3_BUCKET_CREDENTIALS) {
process.env.BACKEND = 's3'
process.env.TEMPLATE_FILES_BUCKET_NAME =
process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME
} else {
process.env.BACKEND = 'fs'
process.env.TEMPLATE_FILES_BUCKET_NAME = Path.join(
__dirname,
'../template_files'
)
}
}
const settings = {
internal: {
filestore: {
port: 3009,
host: process.env.LISTEN_ADDRESS || '127.0.0.1',
},
},
filestore: {
// Which backend persistor to use.
// Choices are
// s3 - Amazon S3
// fs - local filesystem
// gcs - Google Cloud Storage
backend: process.env.BACKEND,
gcs: {
endpoint: process.env.GCS_API_ENDPOINT
? {
apiEndpoint: process.env.GCS_API_ENDPOINT,
projectId: process.env.GCS_PROJECT_ID,
}
: undefined,
unlockBeforeDelete: process.env.GCS_UNLOCK_BEFORE_DELETE === 'true', // unlock an event-based hold before deleting. default false
deletedBucketSuffix: process.env.GCS_DELETED_BUCKET_SUFFIX, // if present, copy file to another bucket on delete. default null
deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50,
signedUrlExpiryInMs: parseInt(process.env.LINK_EXPIRY_TIMEOUT || 60000),
},
s3: {
key: process.env.AWS_ACCESS_KEY_ID,
secret: process.env.AWS_SECRET_ACCESS_KEY,
endpoint: process.env.AWS_S3_ENDPOINT,
pathStyle: process.env.AWS_S3_PATH_STYLE,
partSize: process.env.AWS_S3_PARTSIZE || 100 * 1024 * 1024,
bucketCreds: process.env.S3_BUCKET_CREDENTIALS
? JSON.parse(process.env.S3_BUCKET_CREDENTIALS)
: undefined,
},
// GCS should be configured by the service account on the kubernetes pod. See GOOGLE_APPLICATION_CREDENTIALS,
// which will be picked up automatically.
stores: {
template_files: process.env.TEMPLATE_FILES_BUCKET_NAME,
// allow signed links to be generated for these buckets
project_blobs: process.env.OVERLEAF_EDITOR_PROJECT_BLOBS_BUCKET,
global_blobs: process.env.OVERLEAF_EDITOR_BLOBS_BUCKET,
},
fallback: process.env.FALLBACK_BACKEND
? {
backend: process.env.FALLBACK_BACKEND,
// mapping of bucket names on the fallback, to bucket names on the primary.
// e.g. { myS3UserFilesBucketName: 'myGoogleUserFilesBucketName' }
buckets: JSON.parse(process.env.FALLBACK_BUCKET_MAPPING || '{}'),
copyOnMiss: process.env.COPY_ON_MISS === 'true',
}
: undefined,
allowRedirects: process.env.ALLOW_REDIRECTS === 'true',
},
path: {
uploadFolder: Path.join(__dirname, '../uploads'),
},
commands: {
// Any commands to wrap the convert utility in, for example ["nice"]
convertCommandPrefix: [],
},
enableConversions: process.env.ENABLE_CONVERSIONS === 'true',
// PDF→image conversion backend (template gallery previews/thumbnails):
// 'imagemagick' – local, via ImageMagick `convert` (default; binary required)
// 'pdftocairo' – local, via the `pdftocairo` binary (poppler)
// 'pdftocairo-sandbox' – runs `pdftocairo` in a throwaway sibling container:
// no network, CapDrop ALL, no-new-privileges, memory
// cap (see app/js/SandboxConverterRunner.js).
// requires a Docker socket + a daemon-host-visible
// scratch dir (CONVERSION_SANDBOX_HOST_DIR).
converter: process.env.CONVERTER || 'imagemagick',
sandboxConversion: {
image: process.env.CONVERSION_SANDBOX_IMAGE || 'sharelatex/pdftocairo:24.02',
dockerSocketPath: process.env.CONVERSION_DOCKER_SOCKET || '/var/run/docker.sock',
// The scratch dir has two views of the same path (the overleaf container
// mounts ./data): `containerDir` for this process, `hostDir` for the Docker
// daemon's bind mount. Both must be set when sandbox conversion is used.
hostDir: process.env.CONVERSION_SANDBOX_HOST_DIR || null,
containerDir: process.env.CONVERSION_SANDBOX_DIR || null,
memoryBytes:
parseInt(process.env.CONVERSION_SANDBOX_MEMORY_BYTES, 10) || 512 * 1024 * 1024,
timeoutMs: parseInt(process.env.CONVERSION_SANDBOX_TIMEOUT_MS, 10) || 40000,
},
gracefulShutdownDelayInMs:
parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '30', 10) * 1000,
}
module.exports = settings