Skip to content

Commit cc3f1f1

Browse files
committed
feat(clsi): sandboxed compiles
1 parent 0377e48 commit cc3f1f1

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

docker-compose.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
#### Server Pro: Uncomment the following line to mount the docker ####
2121
#### socket, required for Sibling Containers to work ####
2222
########################################################################
23-
# - /var/run/docker.sock:/var/run/docker.sock
23+
- /var/run/docker.sock:/var/run/docker.sock
2424
environment:
2525

2626
OVERLEAF_APP_NAME: Overleaf Community Edition
@@ -81,7 +81,15 @@ services:
8181
SANDBOXED_COMPILES: 'true'
8282
SANDBOXED_COMPILES_SIBLING_CONTAINERS: 'true'
8383
### Bind-mount source for /var/lib/overleaf/data/compiles inside the container.
84-
SANDBOXED_COMPILES_HOST_DIR: '/home/user/sharelatex_data/data/compiles'
84+
SANDBOXED_COMPILES_HOST_DIR: '/home/overleaf/sharelatex_data/data/compiles'
85+
SANDBOXED_COMPILES_CONTAINER_TIMEOUT: 3600000
86+
TEX_LIVE_DOCKER_IMAGE: "ghcr.io/lcpu-club/sharelatex-base:2024.1"
87+
ALL_TEX_LIVE_DOCKER_IMAGES: "ghcr.io/lcpu-club/sharelatex-base:2024.1,ghcr.io/lcpu-club/sharelatex-base:2022.1,ghcr.io/lcpu-club/sharelatex-base:2020.1"
88+
ALL_TEX_LIVE_DOCKER_IMAGE_NAMES: "TeX Live 2024,TeX Live 2022,TeX Live 2020"
89+
DOCKER_RUNNER: true
90+
DOCKER_USER: "www-data"
91+
92+
OVERLEAF_IS_SERVER_PRO: true
8593

8694
## Works with test LDAP server shown at bottom of docker compose
8795
# OVERLEAF_LDAP_URL: 'ldap://ldap:389'

server-ce/config/settings.js

+20
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,30 @@ const parseIntOrFail = function (value) {
4747
const DATA_DIR = '/var/lib/overleaf/data'
4848
const TMP_DIR = '/var/lib/overleaf/tmp'
4949

50+
const images = process.env.ALL_TEX_LIVE_DOCKER_IMAGES.split(',')
51+
const imageNames = process.env.ALL_TEX_LIVE_DOCKER_IMAGE_NAMES.split(',')
52+
53+
if (images.length !== imageNames.length) {
54+
throw new Error(`image and imageName count mismatched`)
55+
}
56+
const allowedImageNames = []
57+
images.forEach((_, i) => {
58+
allowedImageNames.push({imageName: images[i], imageDesc: imageNames[i]})
59+
});
60+
5061
const settings = {
5162
clsi: {
5263
optimiseInDocker: process.env.OPTIMISE_PDF === 'true',
64+
dockerRunner: process.env.DOCKER_RUNNER === 'true',
65+
docker: {
66+
maxContainerAge: process.env.SANDBOXED_COMPILES_CONTAINER_TIMEOUT,
67+
image: process.env.TEX_LIVE_DOCKER_IMAGE,
68+
user: process.env.DOCKER_USER,
69+
},
5370
},
5471

72+
allowedImageNames: allowedImageNames,
73+
5574
brandPrefix: '',
5675

5776
allowAnonymousReadAndWriteSharing:
@@ -172,6 +191,7 @@ const settings = {
172191
clsiCacheDir: Path.join(DATA_DIR, 'cache'),
173192
// Where to write the output files to disk after running LaTeX
174193
outputDir: Path.join(DATA_DIR, 'output'),
194+
sandboxedCompilesHostDir: process.env.SANDBOXED_COMPILES_HOST_DIR,
175195
},
176196

177197
// Server Config

services/web/app/src/Features/Project/ProjectOptionsHandler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const ProjectOptionsHandler = {
3030
throw new Error(`invalid imageName: ${imageName}`)
3131
}
3232
const conditions = { _id: projectId }
33-
const update = { imageName: settings.imageRoot + '/' + imageName }
33+
const update = { imageName: imageName }
3434
return Project.updateOne(conditions, update, {})
3535
},
3636

0 commit comments

Comments
 (0)