2020-05-22 06:34:57 -04:00
|
|
|
version: "2.3"
|
2017-11-23 11:01:32 -05:00
|
|
|
|
|
|
|
volumes:
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
data:
|
2017-11-23 11:01:32 -05:00
|
|
|
|
|
|
|
services:
|
2019-02-19 09:51:34 -05:00
|
|
|
|
|
|
|
test_unit:
|
2020-05-22 06:34:57 -04:00
|
|
|
build:
|
|
|
|
context: .
|
|
|
|
target: base
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
volumes:
|
2018-12-13 04:07:55 -05:00
|
|
|
- .:/app
|
CI and local dev environment improvements
The need for this became very noticeable due to the slowness of filesystem access in docker-in-mac, with a full compile taking over a minute for me in docker. Using make to introduce incremental compile makes this near instantaneous outside of docker (if only a few files have changed), and quick enough inside docker.
With incremental compile via make, it compiles quickly enough that re-compiling and restarting the web service automatically when backend files change is quick enough now. This is how the service is run via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, so it shouldn't be necessary to manually restart the container each time a coffee file changes.
At the moment Jenkins pull web modules in via the GitSCM plugin, but I believe this is creating a dependency in Jenkins, where any commits to any of the modules causes all of the web branches to rebuild. By doing it via our own scripts we can hopefully avoid this. It also creates a build process which is reproducible locally.
**Note that at the moment in this PR all modules pull from `ja-dockerize-dev` branches, but these should be merged first, and this PR updated to point to the master branches before merging**. This is necessary for other changes to build process/docker-compose workflow.
As well as a Makefile for web, there is now a `Makefile.module`. This is copied into each module directory by the top-level Makefile, and is written in a way to be flexible and support unit tests, acceptance tests, front-end js for the ide and main, and the modules `app/coffee` directory, while allowing modules to have some of these missing (not all modules have e.g. acceptance tests, or front-end JS). This will allows us to refine the build process in future, without needing to update the Makefile in each module repo separately (I found this to be a painful part of this development).
This makes web compatible with the docker-compose workflow at https://github.com/sharelatex/sharelatex-dev-environment, where each service is running in its own docker container, with networking managed by docker.
Previously the Makefile was set up to run unit tests in docker with `make unit_tests`. This now just runs them natively. In the CI, they are run in docker anyway (all steps in Jenkins are), and locally, they run fine natively with `npm run test:unit`, or can be run in docker via https://github.com/sharelatex/sharelatex-dev-environment with `bin/run web_sl npm run test:unit`.
Previously we did a lot of juggling with only mounting source files (coffee, less, etc) into the docker container for acceptance tests. This was to avoid creating root owned files if the whole directory was mounted. Now instead the whole web directory is mounted read-only, with the compilation step done outside of the container before running the tests.
This allows the host and container to share the `node_modules` folder as well, which avoids needing to `npm install` twice on the CI box, and should speed up the build by a few minutes.
On macOS, this would cause a problem with compiled modules if you tried to use the same `node_modules` to run the app natively. However, if running via docker-compose in https://github.com/sharelatex/sharelatex-dev-environment, this is no longer a problem.
2017-12-28 15:11:27 -05:00
|
|
|
working_dir: /app
|
2019-02-19 09:51:34 -05:00
|
|
|
environment:
|
|
|
|
MOCHA_GREP: ${MOCHA_GREP}
|
2020-08-03 07:34:22 -04:00
|
|
|
command: npm run --silent test:unit:app
|
2019-02-19 09:51:34 -05:00
|
|
|
user: node
|
|
|
|
|
|
|
|
test_acceptance:
|
2020-06-03 04:22:55 -04:00
|
|
|
image: node:10.21.0
|
2019-02-19 09:51:34 -05:00
|
|
|
volumes:
|
2019-02-25 08:18:42 -05:00
|
|
|
- .:/app
|
2019-02-19 09:51:34 -05:00
|
|
|
working_dir: /app
|
2017-11-23 11:01:32 -05:00
|
|
|
environment:
|
2020-05-06 06:01:59 -04:00
|
|
|
BCRYPT_ROUNDS: 1
|
2017-11-23 11:01:32 -05:00
|
|
|
REDIS_HOST: redis
|
2017-11-29 08:49:36 -05:00
|
|
|
MONGO_URL: "mongodb://mongo/sharelatex"
|
2017-11-23 11:01:32 -05:00
|
|
|
SHARELATEX_ALLOW_PUBLIC_ACCESS: 'true'
|
2017-11-30 08:49:08 -05:00
|
|
|
PROJECT_HISTORY_ENABLED: 'true'
|
2018-02-21 06:19:21 -05:00
|
|
|
LINKED_URL_PROXY: 'http://localhost:6543'
|
2018-11-30 08:03:35 -05:00
|
|
|
ENABLED_LINKED_FILE_TYPES: 'url,project_file,project_output_file,mendeley,zotero'
|
2019-02-19 09:51:34 -05:00
|
|
|
MOCHA_GREP: ${MOCHA_GREP}
|
2019-10-16 06:10:54 -04:00
|
|
|
NODE_ENV: test
|
2020-06-01 04:37:34 -04:00
|
|
|
LOCK_MANAGER_MAX_LOCK_WAIT_TIME: 30000
|
2020-07-15 06:47:15 -04:00
|
|
|
MONGO_SOCKET_TIMEOUT: 60000
|
2020-02-25 04:39:53 -05:00
|
|
|
# SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING: 'true'
|
2019-10-23 08:22:37 -04:00
|
|
|
SHARELATEX_CONFIG:
|
2017-11-23 11:01:32 -05:00
|
|
|
depends_on:
|
|
|
|
- redis
|
|
|
|
- mongo
|
2020-08-03 07:34:22 -04:00
|
|
|
command: npm run --silent test:acceptance:app
|
2017-11-23 11:01:32 -05:00
|
|
|
|
2020-07-09 09:56:33 -04:00
|
|
|
test_karma:
|
2018-02-13 10:42:27 -05:00
|
|
|
build:
|
|
|
|
context: .
|
|
|
|
dockerfile: Dockerfile.frontend
|
|
|
|
volumes:
|
|
|
|
- .:/app
|
|
|
|
working_dir: /app
|
2020-08-03 07:34:22 -04:00
|
|
|
command: npm run --silent test:karma:single
|
2020-07-09 09:56:33 -04:00
|
|
|
|
|
|
|
test_frontend:
|
|
|
|
build:
|
|
|
|
context: .
|
|
|
|
target: base
|
|
|
|
volumes:
|
|
|
|
- .:/app
|
|
|
|
working_dir: /app
|
|
|
|
environment:
|
|
|
|
MOCHA_GREP: ${MOCHA_GREP}
|
2020-08-03 07:34:22 -04:00
|
|
|
command: npm run --silent test:frontend
|
2020-07-09 09:56:33 -04:00
|
|
|
user: node
|
2018-02-13 10:42:27 -05:00
|
|
|
|
2017-11-23 11:01:32 -05:00
|
|
|
redis:
|
|
|
|
image: redis
|
|
|
|
|
|
|
|
mongo:
|
2020-01-08 08:40:07 -05:00
|
|
|
image: mongo:3.6.16
|