mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
Sandboxed compiles: convert DockerRunner to ESM
This commit is contained in:
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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'
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user