mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
Sandboxed compiles: convert DockerRunner to ESM
This commit is contained in:
@@ -10,7 +10,7 @@ import logger from '@overleaf/logger'
|
|||||||
let commandRunnerPath
|
let commandRunnerPath
|
||||||
|
|
||||||
if ((Settings.clsi != null ? Settings.clsi.dockerRunner : undefined) === true) {
|
if ((Settings.clsi != null ? Settings.clsi.dockerRunner : undefined) === true) {
|
||||||
commandRunnerPath = './DockerRunner.js'
|
commandRunnerPath = './DockerRunner.mjs'
|
||||||
} else {
|
} else {
|
||||||
commandRunnerPath = './LocalCommandRunner.js'
|
commandRunnerPath = './LocalCommandRunner.js'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
const { promisify } = require('node:util')
|
import { promisify } from 'node:util'
|
||||||
const Settings = require('@overleaf/settings')
|
import Settings from '@overleaf/settings'
|
||||||
const logger = require('@overleaf/logger')
|
import logger from '@overleaf/logger'
|
||||||
const Docker = require('dockerode')
|
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 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
|
const ONE_HOUR_IN_MS = 60 * 60 * 1000
|
||||||
logger.debug('using docker runner')
|
logger.debug('using docker runner')
|
||||||
@@ -602,8 +603,8 @@ const DockerRunner = {
|
|||||||
|
|
||||||
DockerRunner.startContainerMonitor()
|
DockerRunner.startContainerMonitor()
|
||||||
|
|
||||||
module.exports = DockerRunner
|
DockerRunner.promises = {
|
||||||
module.exports.promises = {
|
|
||||||
run: promisify(DockerRunner.run),
|
run: promisify(DockerRunner.run),
|
||||||
kill: promisify(DockerRunner.kill),
|
kill: promisify(DockerRunner.kill),
|
||||||
}
|
}
|
||||||
|
export default DockerRunner
|
||||||
@@ -130,7 +130,7 @@ if (process.env.ALLOWED_COMPILE_GROUPS) {
|
|||||||
|
|
||||||
if ((process.env.DOCKER_RUNNER || process.env.SANDBOXED_COMPILES) === 'true') {
|
if ((process.env.DOCKER_RUNNER || process.env.SANDBOXED_COMPILES) === 'true') {
|
||||||
if (
|
if (
|
||||||
!fs.existsSync(Path.join(__dirname, '..', 'app', 'js', 'DockerRunner.js'))
|
!fs.existsSync(Path.join(__dirname, '..', 'app', 'js', 'DockerRunner.mjs'))
|
||||||
) {
|
) {
|
||||||
console.error(
|
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'
|
'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(
|
const modulePath = Path.join(
|
||||||
import.meta.dirname,
|
import.meta.dirname,
|
||||||
'../../../app/js/DockerRunner'
|
'../../../app/js/DockerRunner.mjs'
|
||||||
)
|
)
|
||||||
|
|
||||||
describe('DockerRunner', () => {
|
describe('DockerRunner', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user