Merge pull request #158 from overleaf/jpa-entry-point-cleanup

[misc] entry point cleanup
This commit is contained in:
Henry Oswald 2020-04-23 13:52:04 +01:00 committed by GitHub
commit a5887fad50
7 changed files with 33 additions and 28 deletions

View file

@ -5,3 +5,6 @@ gitrev
.npm .npm
.nvmrc .nvmrc
nodemon.json nodemon.json
cache/
compiles/
db/

View file

@ -24,5 +24,7 @@ COPY . /app
FROM base FROM base
COPY --from=app /app /app COPY --from=app /app /app
RUN mkdir -p cache compiles db \
&& chown node:node cache compiles db
CMD ["node", "--expose-gc", "app.js"] CMD ["node", "--expose-gc", "app.js"]

View file

@ -1,5 +1,6 @@
clsi clsi
--acceptance-creds=None --acceptance-creds=None
--data-dirs=cache,compiles,db
--dependencies= --dependencies=
--docker-repos=gcr.io/overleaf-ops --docker-repos=gcr.io/overleaf-ops
--env-add= --env-add=

View file

@ -9,7 +9,7 @@ module.exports = {
username: 'clsi', username: 'clsi',
dialect: 'sqlite', dialect: 'sqlite',
storage: storage:
process.env.SQLITE_PATH || Path.resolve(__dirname + '/../db.sqlite'), process.env.SQLITE_PATH || Path.resolve(__dirname + '/../db/db.sqlite'),
pool: { pool: {
max: 1, max: 1,
min: 1 min: 1

2
services/clsi/db/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -1,26 +1,18 @@
#!/bin/sh #!/bin/sh
echo "Changing permissions of /var/run/docker.sock for sibling containers" docker --version >&2
ls -al /var/run/docker.sock
docker --version
cat /etc/passwd
# add the node user to the docker group on the host
DOCKER_GROUP=$(stat -c '%g' /var/run/docker.sock) DOCKER_GROUP=$(stat -c '%g' /var/run/docker.sock)
groupadd --non-unique --gid ${DOCKER_GROUP} dockeronhost groupadd --non-unique --gid ${DOCKER_GROUP} dockeronhost
usermod -aG dockeronhost node usermod -aG dockeronhost node
mkdir -p /app/cache # compatibility: initial volume setup
chown -R node:node /app/cache chown node:node /app/cache
chown node:node /app/compiles
mkdir -p /app/compiles chown node:node /app/db
chown -R node:node /app/compiles
chown -R node:node /app/bin/synctex
mkdir -p /app/test/acceptance/fixtures/tmp/
chown -R node:node /app
chown -R node:node /app/bin
# make synctex available for remount in compiles
cp /app/bin/synctex /app/bin/synctex-mount/synctex cp /app/bin/synctex /app/bin/synctex-mount/synctex
exec runuser -u node -- "$@" exec runuser -u node -- "$@"

View file

@ -19,11 +19,17 @@ const Client = require('./helpers/Client')
const request = require('request') const request = require('request')
require('chai').should() require('chai').should()
const fs = require('fs') const fs = require('fs')
const fsExtra = require('fs-extra')
const ChildProcess = require('child_process') const ChildProcess = require('child_process')
const ClsiApp = require('./helpers/ClsiApp') const ClsiApp = require('./helpers/ClsiApp')
const logger = require('logger-sharelatex') const logger = require('logger-sharelatex')
const Path = require('path') const Path = require('path')
const fixturePath = path => Path.normalize(__dirname + '/../fixtures/' + path) const fixturePath = path => {
if (path.slice(0, 3) === 'tmp') {
return '/tmp/clsi_acceptance_tests' + path.slice(3)
}
return Path.normalize(__dirname + '/../fixtures/' + path)
}
const process = require('process') const process = require('process')
console.log( console.log(
process.pid, process.pid,
@ -32,13 +38,6 @@ console.log(
process.getgroups(), process.getgroups(),
'PID' 'PID'
) )
try {
console.log('creating tmp directory', fixturePath('tmp'))
fs.mkdirSync(fixturePath('tmp'))
} catch (error) {
const err = error
console.log(err, fixturePath('tmp'), 'unable to create fixture tmp path')
}
const MOCHA_LATEX_TIMEOUT = 60 * 1000 const MOCHA_LATEX_TIMEOUT = 60 * 1000
@ -201,10 +200,16 @@ Client.runServer(4242, fixturePath('examples'))
describe('Example Documents', function() { describe('Example Documents', function() {
before(function(done) { before(function(done) {
return ChildProcess.exec('rm test/acceptance/fixtures/tmp/*').on( ClsiApp.ensureRunning(done)
'exit', })
() => ClsiApp.ensureRunning(done) before(function(done) {
) fsExtra.remove(fixturePath('tmp'), done)
})
before(function(done) {
fs.mkdir(fixturePath('tmp'), done)
})
after(function(done) {
fsExtra.remove(fixturePath('tmp'), done)
}) })
return Array.from(fs.readdirSync(fixturePath('examples'))).map(example_dir => return Array.from(fs.readdirSync(fixturePath('examples'))).map(example_dir =>