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:
|
2021-07-20 05:26:03 -04:00
|
|
|
BASE_CONFIG:
|
|
|
|
SHARELATEX_CONFIG:
|
2019-02-19 09:51:34 -05:00
|
|
|
MOCHA_GREP: ${MOCHA_GREP}
|
2020-08-11 08:20:23 -04:00
|
|
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
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:
|
2021-07-15 11:16:00 -04:00
|
|
|
image: node:12.22.3
|
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
|
2021-07-27 04:45:17 -04:00
|
|
|
env_file: docker-compose.common.env
|
2017-11-23 11:01:32 -05:00
|
|
|
environment:
|
2021-07-27 04:45:17 -04:00
|
|
|
BASE_CONFIG:
|
|
|
|
SHARELATEX_CONFIG:
|
2019-02-19 09:51:34 -05:00
|
|
|
MOCHA_GREP: ${MOCHA_GREP}
|
2021-01-14 10:47:20 -05:00
|
|
|
MONGO_SERVER_SELECTION_TIMEOUT: 600000
|
|
|
|
MONGO_SOCKET_TIMEOUT: 300000
|
2020-02-25 04:39:53 -05:00
|
|
|
# SHARELATEX_ALLOW_ANONYMOUS_READ_AND_WRITE_SHARING: 'true'
|
2021-07-27 04:45:17 -04:00
|
|
|
|
2020-12-02 05:16:16 -05:00
|
|
|
extra_hosts:
|
|
|
|
- 'www.overleaf.test:127.0.0.1'
|
2017-11-23 11:01:32 -05:00
|
|
|
depends_on:
|
|
|
|
- redis
|
|
|
|
- mongo
|
2021-07-27 04:45:17 -04:00
|
|
|
- saml
|
|
|
|
- ldap
|
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
|
2020-08-11 08:20:23 -04:00
|
|
|
environment:
|
|
|
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
2018-02-13 10:42:27 -05:00
|
|
|
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-11 08:20:23 -04:00
|
|
|
NODE_OPTIONS: "--unhandled-rejections=strict"
|
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-08-06 09:53:53 -04:00
|
|
|
image: mongo:4.0.19
|
2021-07-27 04:45:17 -04:00
|
|
|
|
|
|
|
ldap:
|
|
|
|
restart: always
|
|
|
|
image: rroemhild/test-openldap:1.1
|
|
|
|
|
|
|
|
saml:
|
|
|
|
restart: always
|
|
|
|
image: gcr.io/overleaf-ops/saml-test
|
|
|
|
environment:
|
|
|
|
SAML_BASE_URL_PATH: 'http://saml/simplesaml/'
|
|
|
|
SAML_TEST_SP_ENTITY_ID: 'sharelatex-test-saml'
|
|
|
|
SAML_TEST_SP_LOCATION: 'http://www.overleaf.test:3000/saml/callback'
|