Sandboxed compiles: convert DockerRunner to ESM

This commit is contained in:
yu-i-i
2026-03-16 02:04:54 +01:00
parent 373dd33b98
commit fdc092371b
4 changed files with 15 additions and 14 deletions

View File

@@ -10,7 +10,7 @@ import logger from '@overleaf/logger'
let commandRunnerPath
if ((Settings.clsi != null ? Settings.clsi.dockerRunner : undefined) === true) {
commandRunnerPath = './DockerRunner.js'
commandRunnerPath = './DockerRunner.mjs'
} else {
commandRunnerPath = './LocalCommandRunner.js'
}

View File

@@ -1,13 +1,14 @@
const { promisify } = require('node:util')
const Settings = require('@overleaf/settings')
const logger = require('@overleaf/logger')
const Docker = require('dockerode')
import { promisify } from 'node:util'
import Settings from '@overleaf/settings'
import logger from '@overleaf/logger'
import Docker from 'dockerode'
import crypto from 'node:crypto'
import async from 'async'
import LockManager from './DockerLockManager.js'
import Path from 'node:path'
import _ from 'lodash'
const dockerode = new Docker()
const crypto = require('node:crypto')
const async = require('async')
const LockManager = require('./DockerLockManager')
const Path = require('node:path')
const _ = require('lodash')
const ONE_HOUR_IN_MS = 60 * 60 * 1000
logger.debug('using docker runner')
@@ -602,8 +603,8 @@ const DockerRunner = {
DockerRunner.startContainerMonitor()
module.exports = DockerRunner
module.exports.promises = {
DockerRunner.promises = {
run: promisify(DockerRunner.run),
kill: promisify(DockerRunner.kill),
}
export default DockerRunner

View File

@@ -118,7 +118,7 @@ if (process.env.ALLOWED_COMPILE_GROUPS) {
if ((process.env.DOCKER_RUNNER || process.env.SANDBOXED_COMPILES) === 'true') {
if (
!fs.existsSync(Path.join(__dirname, '..', 'app', 'js', 'DockerRunner.js'))
!fs.existsSync(Path.join(__dirname, '..', 'app', 'js', 'DockerRunner.mjs'))
) {
console.error(
'Sandboxed compiles are only available with Overleaf Server Pro. Compare Server Pro with Community Edition here: https://docs.overleaf.com/on-premises/welcome/server-pro-vs.-community-edition'

View File

@@ -5,7 +5,7 @@ import Path from 'node:path'
const modulePath = Path.join(
import.meta.dirname,
'../../../app/js/DockerRunner'
'../../../app/js/DockerRunner.mjs'
)
describe('DockerRunner', () => {