Allow selecting a TeX Live image for a project

This commit is contained in:
yu-i-i
2024-12-12 18:49:19 +01:00
parent 12690a9b06
commit 3e7d1d3160
5 changed files with 15 additions and 15 deletions
+1 -7
View File
@@ -462,13 +462,7 @@ if (process.env.SANDBOXED_COMPILES === 'true') {
dockerRunner: true,
docker: {
image: process.env.TEX_LIVE_DOCKER_IMAGE,
env: {
HOME: '/tmp',
PATH:
process.env.COMPILER_PATH ||
'/usr/local/bin:/usr/bin:/bin',
},
user: 'www-data',
user: process.env.TEX_LIVE_DOCKER_USER || 'www-data',
}
}
+2 -2
View File
@@ -234,8 +234,8 @@ const DockerRunner = {
}
}
// set the path based on the image year
const match = image.match(/:([0-9]+)\.[0-9]+/)
const year = match ? match[1] : '2014'
const match = image.match(/:([0-9]+)\.[0-9]+|:TL([0-9]+)/)
const year = match ? match[1] || match[2] : '2014'
env.PATH = `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/texlive/${year}/bin/x86_64-linux/`
const options = {
Cmd: command,
@@ -36,10 +36,7 @@ module.exports = ProjectEditorHandler = {
),
members: [],
invites: this.buildInvitesView(invites),
imageName:
project.imageName != null
? Path.basename(project.imageName)
: undefined,
imageName: project.imageName,
}
;({ owner, ownerFeatures, members } =
@@ -22,7 +22,6 @@ const ProjectOptionsHandler = {
if (!imageName || !Array.isArray(settings.allowedImageNames)) {
return
}
imageName = imageName.toLowerCase()
const isAllowed = settings.allowedImageNames.find(
allowed => imageName === allowed.imageName
)
@@ -30,7 +29,7 @@ const ProjectOptionsHandler = {
throw new Error(`invalid imageName: ${imageName}`)
}
const conditions = { _id: projectId }
const update = { imageName: settings.imageRoot + '/' + imageName }
const update = { imageName: imageName }
return Project.updateOne(conditions, update, {})
},
+10
View File
@@ -1007,6 +1007,16 @@ module.exports = {
managedUsers: {
enabled: false,
},
allowedImageNames: (() => {
if (process.env.SANDBOXED_COMPILES != 'true') return null
const imageNames = parseTextExtensions(process.env.ALL_TEX_LIVE_DOCKER_IMAGES);
const imageDescs = parseTextExtensions(process.env.ALL_TEX_LIVE_DOCKER_IMAGE_NAMES);
return imageNames.map((imageName, index) => ({
imageName,
imageDesc: imageDescs[index] || imageName.split(':')[1],
}))
})()
}
module.exports.mergeWith = function (overrides) {