Merge pull request #6211 from overleaf/em-code-sharing

Change directory layout in service containers

GitOrigin-RevId: 09ff19db2a123cbf7691d51e9ce9be6eee264287
This commit is contained in:
Eric Mc Sween 2022-01-06 10:02:36 -05:00 committed by Copybot
parent 6ddbf23da0
commit f3f0be5c56
57 changed files with 225 additions and 210 deletions

View file

@ -6,4 +6,4 @@ access-token-encryptor
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ logger
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ metrics
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ o-error
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ object-persistor
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ redis-wrapper
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,4 +6,4 @@ settings
--is-library=True
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/chat
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/chat/package*.json /overleaf/services/chat/
RUN npm ci --quiet
COPY . /app
COPY services/chat /overleaf/services/chat
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ chat
--env-pass-through=
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/chat
working_dir: /overleaf/services/chat
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/chat
working_dir: /overleaf/services/chat
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,24 +4,21 @@
FROM node:14.18.1 as base
WORKDIR /app
COPY install_deps.sh /app
WORKDIR /overleaf/services/clsi
COPY services/clsi/install_deps.sh /overleaf/services/clsi/
RUN chmod 0755 ./install_deps.sh && ./install_deps.sh
ENTRYPOINT ["/bin/sh", "entrypoint.sh"]
COPY entrypoint.sh /app
ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
COPY services/clsi/entrypoint.sh /
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/clsi/package*.json /overleaf/services/clsi/
RUN npm ci --quiet
COPY . /app
COPY services/clsi /overleaf/services/clsi
FROM base
COPY --from=app /app /app
FROM app
RUN mkdir -p cache compiles output \
&& chown node:node cache compiles output

View file

@ -94,12 +94,13 @@ build:
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
--target base \
--file Dockerfile \
.
../..
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -61,8 +61,8 @@ Then start the Docker container:
-e TEXLIVE_IMAGE=texlive/texlive \
-e TEXLIVE_IMAGE_USER=root \
-e COMPILES_HOST_DIR="$PWD/compiles" \
-v "$PWD/compiles:/app/compiles" \
-v "$PWD/cache:/app/cache" \
-v "$PWD/compiles:/overleaf/services/clsi/compiles" \
-v "$PWD/cache:/overleaf/services/clsi/cache" \
-v /var/run/docker.sock:/var/run/docker.sock \
--name clsi \
overleaf/clsi

View file

@ -7,4 +7,4 @@ clsi
--has-custom-cloudbuild=True
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -6,13 +6,13 @@ services:
ALLOWED_IMAGES: "quay.io/sharelatex/texlive-full:2017.1"
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2017.1
TEXLIVE_IMAGE_USER: "tex"
SHARELATEX_CONFIG: /app/config/settings.defaults.js
SHARELATEX_CONFIG: /overleaf/services/clsi/config/settings.defaults.js
DOCKER_RUNNER: "true"
COMPILES_HOST_DIR: $PWD/compiles
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./compiles:/app/compiles
- ./cache:/app/cache
- ./compiles:/overleaf/services/clsi/compiles
- ./cache:/overleaf/services/clsi/cache
ci:
@ -20,10 +20,10 @@ services:
ALLOWED_IMAGES: ${TEXLIVE_IMAGE}
TEXLIVE_IMAGE: quay.io/sharelatex/texlive-full:2017.1
TEXLIVE_IMAGE_USER: "tex"
SHARELATEX_CONFIG: /app/config/settings.defaults.js
SHARELATEX_CONFIG: /overleaf/services/clsi/config/settings.defaults.js
DOCKER_RUNNER: "true"
COMPILES_HOST_DIR: $PWD/compiles
volumes:
- /var/run/docker.sock:/var/run/docker.sock:rw
- ./compiles:/app/compiles
- ./cache:/app/cache
- ./compiles:/overleaf/services/clsi/compiles
- ./cache:/overleaf/services/clsi/cache

View file

@ -7,11 +7,12 @@ version: "2.3"
services:
test_unit:
build:
context: .
context: ../..
dockerfile: services/clsi/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/clsi
working_dir: /overleaf/services/clsi
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,11 +21,12 @@ services:
test_acceptance:
build:
context: .
context: ../..
dockerfile: services/clsi/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/clsi
working_dir: /overleaf/services/clsi
extends:
file: docker-compose-config.yml
service: dev

View file

@ -8,9 +8,9 @@ groupadd --non-unique --gid ${DOCKER_GROUP} dockeronhost
usermod -aG dockeronhost node
# compatibility: initial volume setup
mkdir -p /app/cache && chown node:node /app/cache
mkdir -p /app/compiles && chown node:node /app/compiles
mkdir -p /app/db && chown node:node /app/db
mkdir -p /app/output && chown node:node /app/output
mkdir -p /overleaf/services/clsi/cache && chown node:node /overleaf/services/clsi/cache
mkdir -p /overleaf/services/clsi/compiles && chown node:node /overleaf/services/clsi/compiles
mkdir -p /overleaf/services/clsi/db && chown node:node /overleaf/services/clsi/db
mkdir -p /overleaf/services/clsi/output && chown node:node /overleaf/services/clsi/output
exec runuser -u node -- "$@"

View file

@ -31,9 +31,9 @@ describe('ContentCacheManager', function () {
}
before(function () {
contentDir =
'/app/output/602cee6f6460fca0ba7921e6/content/1797a7f48f9-5abc1998509dea1f'
'/overleaf/services/clsi/output/602cee6f6460fca0ba7921e6/content/1797a7f48f9-5abc1998509dea1f'
pdfPath =
'/app/output/602cee6f6460fca0ba7921e6/generated-files/1797a7f48ea-8ac6805139f43351/output.pdf'
'/overleaf/services/clsi/output/602cee6f6460fca0ba7921e6/generated-files/1797a7f48ea-8ac6805139f43351/output.pdf'
reclaimed = 0
Settings.pdfCachingMinChunkSize = 1024

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/contacts
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/contacts/package*.json /overleaf/services/contacts/
RUN npm ci --quiet
COPY . /app
COPY services/contacts /overleaf/services/contacts
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ contacts
--env-pass-through=
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/contacts
working_dir: /overleaf/services/contacts
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/contacts
working_dir: /overleaf/services/contacts
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/docstore
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/docstore/package*.json /overleaf/services/docstore/
RUN npm ci --quiet
COPY . /app
COPY services/docstore /overleaf/services/docstore
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ docstore
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/docstore
working_dir: /overleaf/services/docstore
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/docstore
working_dir: /overleaf/services/docstore
extends:
file: docker-compose-config.yml
service: dev

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/document-updater
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/document-updater/package*.json /overleaf/services/document-updater/
RUN npm ci --quiet
COPY . /app
COPY services/document-updater /overleaf/services/document-updater
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ document-updater
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/document-updater
working_dir: /overleaf/services/document-updater
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/document-updater
working_dir: /overleaf/services/document-updater
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,22 +4,19 @@
FROM node:14.18.1 as base
WORKDIR /app
COPY install_deps.sh /app
WORKDIR /overleaf/services/filestore
COPY services/filestore/install_deps.sh /overleaf/services/filestore/
RUN chmod 0755 ./install_deps.sh && ./install_deps.sh
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/filestore/package*.json /overleaf/services/filestore/
RUN npm ci --quiet
COPY . /app
COPY services/filestore /overleaf/services/filestore
FROM base
COPY --from=app /app /app
FROM app
RUN mkdir -p uploads user_files template_files \
&& chown node:node uploads user_files template_files
USER node

View file

@ -94,12 +94,13 @@ build:
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
--target base \
--file Dockerfile \
.
../..
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -6,4 +6,4 @@ filestore
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -7,11 +7,12 @@ version: "2.3"
services:
test_unit:
build:
context: .
context: ../..
dockerfile: services/filestore/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/filestore
working_dir: /overleaf/services/filestore
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -21,11 +22,12 @@ services:
test_acceptance:
build:
context: .
context: ../..
dockerfile: services/filestore/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/filestore
working_dir: /overleaf/services/filestore
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/notifications
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/notifications/package*.json /overleaf/services/notifications/
RUN npm ci --quiet
COPY . /app
COPY services/notifications /overleaf/services/notifications
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ notifications
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/notifications
working_dir: /overleaf/services/notifications
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/notifications
working_dir: /overleaf/services/notifications
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/real-time
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/real-time/package*.json /overleaf/services/real-time/
RUN npm ci --quiet
COPY . /app
COPY services/real-time /overleaf/services/real-time
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ real-time
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/real-time
working_dir: /overleaf/services/real-time
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/real-time
working_dir: /overleaf/services/real-time
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,22 +4,19 @@
FROM node:14.18.1 as base
WORKDIR /app
COPY install_deps.sh /app
WORKDIR /overleaf/services/spelling
COPY services/spelling/install_deps.sh /overleaf/services/spelling/
RUN chmod 0755 ./install_deps.sh && ./install_deps.sh
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/spelling/package*.json /overleaf/services/spelling/
RUN npm ci --quiet
COPY . /app
COPY services/spelling /overleaf/services/spelling
FROM base
COPY --from=app /app /app
FROM app
RUN mkdir -p cache \
&& chown node:node cache
USER node

View file

@ -94,12 +94,13 @@ build:
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):main-deps \
--target base \
--file Dockerfile \
.
../..
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--cache-from gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-deps \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -6,4 +6,4 @@ spelling
--env-pass-through=
--node-version=14.18.1
--public-repo=False
--script-version=3.13.0
--script-version=4.0.0

View file

@ -7,11 +7,12 @@ version: "2.3"
services:
test_unit:
build:
context: .
context: ../..
dockerfile: services/spelling/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/spelling
working_dir: /overleaf/services/spelling
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -21,11 +22,12 @@ services:
test_acceptance:
build:
context: .
context: ../..
dockerfile: services/spelling/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/spelling
working_dir: /overleaf/services/spelling
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -4,20 +4,17 @@
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/track-changes
FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
COPY services/track-changes/package*.json /overleaf/services/track-changes/
RUN npm ci --quiet
COPY . /app
COPY services/track-changes /overleaf/services/track-changes
FROM base
COPY --from=app /app /app
FROM app
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -86,7 +86,8 @@ endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
--tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \
.
--file Dockerfile \
../..
tar:
$(DOCKER_COMPOSE) up tar

View file

@ -5,4 +5,4 @@ track-changes
--env-pass-through=
--node-version=14.18.1
--public-repo=True
--script-version=3.13.0
--script-version=4.0.0

View file

@ -8,8 +8,8 @@ services:
test_unit:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/track-changes
working_dir: /overleaf/services/track-changes
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
@ -20,8 +20,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/track-changes
working_dir: /overleaf/services/track-changes
environment:
ELASTIC_SEARCH_DSN: es:9200
REDIS_HOST: redis

View file

@ -1,7 +1,8 @@
# the base image is suitable for running web with /app bind mounted
# the base image is suitable for running web with /overleaf/services/web bind
# mounted
FROM node:14.18.1 as base
WORKDIR /app
WORKDIR /overleaf/services/web
# install_deps changes app files and installs npm packages
# as such it has to run at a later stage
@ -10,12 +11,13 @@ RUN apt-get update \
&& apt-get install -y parallel \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /app/node_modules && chown node:node /app/node_modules
RUN mkdir /overleaf/services/web/node_modules \
&& chown node:node /overleaf/services/web/node_modules
# the deps image is used for caching npm ci
FROM base as deps
COPY package.json package-lock.json /app/
COPY services/web/package.json services/web/package-lock.json /overleaf/services/web/
RUN npm ci --quiet
@ -23,16 +25,16 @@ RUN npm ci --quiet
# the dev is suitable for running tests
FROM deps as dev
COPY . /app
COPY services/web /overleaf/services/web
RUN mkdir -p /app/data/dumpFolder && \
mkdir -p /app/data/logs && \
mkdir -p /app/data/pdf && \
mkdir -p /app/data/uploads && \
mkdir -p /app/data/zippedProjects && \
mkdir -p /app/data/projectHistories && \
chmod -R 0755 /app/data/ && \
chown -R node:node /app/data/
RUN mkdir -p /overleaf/services/web/data/dumpFolder \
&& mkdir -p /overleaf/services/web/data/logs \
&& mkdir -p /overleaf/services/web/data/pdf \
&& mkdir -p /overleaf/services/web/data/uploads \
&& mkdir -p /overleaf/services/web/data/zippedProjects \
&& mkdir -p /overleaf/services/web/data/projectHistories \
&& chmod -R 0755 /overleaf/services/web/data \
&& chown -R node:node /overleaf/services/web/data
ARG SENTRY_RELEASE
ENV SENTRY_RELEASE=$SENTRY_RELEASE
@ -50,8 +52,8 @@ RUN chmod 0755 ./install_deps.sh && ./install_deps.sh
# the final production image without webpack source maps
FROM webpack as app
RUN find /app/public -name '*.js.map' -delete
RUN rm /app/modules/server-ce-scripts -rf
RUN find /overleaf/services/web/public -name '*.js.map' -delete
RUN rm /overleaf/services/web/modules/server-ce-scripts -rf
USER node
CMD ["node", "--expose-gc", "app.js"]

View file

@ -5,12 +5,12 @@ BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
PROJECT_NAME = web
BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
export SHARELATEX_CONFIG ?= /app/test/acceptance/config/settings.test.saas.js
export SHARELATEX_CONFIG ?= /overleaf/services/web/test/acceptance/config/settings.test.saas.js
export BASE_CONFIG ?= ${SHARELATEX_CONFIG}
CFG_SAAS=/app/test/acceptance/config/settings.test.saas.js
CFG_SERVER_CE=/app/test/acceptance/config/settings.test.server-ce.js
CFG_SERVER_PRO=/app/test/acceptance/config/settings.test.server-pro.js
CFG_SAAS=/overleaf/services/web/test/acceptance/config/settings.test.saas.js
CFG_SERVER_CE=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
CFG_SERVER_PRO=/overleaf/services/web/test/acceptance/config/settings.test.server-pro.js
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
BRANCH_NAME=$(BRANCH_NAME) \
@ -29,6 +29,27 @@ $(MODULE_MAKEFILES): Makefile.module
# Clean
#
clean:
-$(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=unit_test_all_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=unit_test_parallel_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=unit_test_parallel_make_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_test_saas_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_test_server_ce_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_test_server_pro_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_1_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_2_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_3_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_saas_4_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_server_ce_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=acceptance_modules_merged_server_pro_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=karma_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=karma_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=frontend_test_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
-COMPOSE_PROJECT_NAME=tar_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) down --rmi local
clean_ci:
$(DOCKER_COMPOSE) down -v -t 0
docker container list | grep 'days ago' | cut -d ' ' -f 1 - | xargs -r docker container stop
@ -163,7 +184,7 @@ $(TEST_ACCEPTANCE_APP):
# Target: modules/server-ce-scripts/test_acceptance_server_ce
# -> depends on modules/server-ce-scripts/Makefile
# -> add environment variable BASE_CONFIG=$(CFG_SERVER_CE)
# -> BASE_CONFIG=/app/test/acceptance/config/settings.test.server-ce.js
# -> BASE_CONFIG=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
# -> automatic target: `make -C server-ce-scripts test_acceptance_server_ce`
# -> automatic target: run `make test_acceptance_server_ce` in module
# Target: modules/server-ce-scripts/Makefile
@ -338,7 +359,7 @@ ORG_PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
RUN_LINT_FORMAT ?= \
docker run --rm ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
NODE_MODULES_PATH := ${PATH}:${PWD}/node_modules/.bin:/app/node_modules/.bin
NODE_MODULES_PATH := ${PATH}:${PWD}/node_modules/.bin:/overleaf/services/web/node_modules/.bin
WITH_NODE_MODULES_PATH = \
format_backend \
format_frontend \
@ -450,7 +471,8 @@ build_deps:
--cache-from $(IMAGE_REPO_MASTER)-deps \
--tag $(IMAGE_REPO_BRANCH)-deps \
--target deps \
.
--file Dockerfile \
../..
build_dev:
docker build \
@ -460,7 +482,8 @@ build_dev:
--tag $(IMAGE_CI) \
--tag $(IMAGE_CI)-dev \
--target dev \
.
--file Dockerfile \
../..
build_webpack:
$(MAKE) build_webpack_once \
@ -473,7 +496,8 @@ build_webpack_once:
--cache-from $(IMAGE_CI)-webpack \
--tag $(IMAGE_CI)-webpack \
--target webpack \
.
--file Dockerfile \
../..
build:
docker build \
@ -481,7 +505,8 @@ build:
--cache-from $(IMAGE_CI)-webpack \
--cache-from $(IMAGE_REPO_FINAL) \
--tag $(IMAGE_REPO_FINAL) \
.
--file Dockerfile \
../..
build_test_karma:
COMPOSE_PROJECT_NAME=karma_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE) build test_karma

View file

@ -3,12 +3,12 @@ MODULE_NAME := $(notdir $(shell pwd))
MODULE_DIR := modules/$(MODULE_NAME)
PROJECT_NAME = web
export SHARELATEX_CONFIG = /app/$(MODULE_DIR)/test/acceptance/config/settings.test.js
export BASE_CONFIG ?= /app/test/acceptance/config/settings.test.saas.js
export SHARELATEX_CONFIG = /overleaf/services/web/$(MODULE_DIR)/test/acceptance/config/settings.test.js
export BASE_CONFIG ?= /overleaf/services/web/test/acceptance/config/settings.test.saas.js
CFG_SAAS=/app/test/acceptance/config/settings.test.saas.js
CFG_SERVER_CE=/app/test/acceptance/config/settings.test.server-ce.js
CFG_SERVER_PRO=/app/test/acceptance/config/settings.test.server-pro.js
CFG_SAAS=/overleaf/services/web/test/acceptance/config/settings.test.saas.js
CFG_SERVER_CE=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
CFG_SERVER_PRO=/overleaf/services/web/test/acceptance/config/settings.test.server-pro.js
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml --log-level ERROR
DOCKER_COMPOSE := cd ../../ && \

View file

@ -18,7 +18,7 @@ services:
test_acceptance:
build: .
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
working_dir: /app
working_dir: /overleaf/services/web
env_file: docker-compose.common.env
environment:
BASE_CONFIG:
@ -41,7 +41,7 @@ services:
PROJECT_NAME: $PROJECT_NAME
BRANCH_NAME: $BRANCH_NAME
BUILD_NUMBER: $BUILD_NUMBER
working_dir: /app
working_dir: /overleaf/services/web
command: npm run test:karma:single
user: node
environment:

View file

@ -7,11 +7,12 @@ services:
test_unit:
build:
context: .
context: ../..
dockerfile: services/web/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/web
working_dir: /overleaf/services/web
environment:
BASE_CONFIG:
SHARELATEX_CONFIG:
@ -23,8 +24,8 @@ services:
test_acceptance:
image: node:14.18.1
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/web
working_dir: /overleaf/services/web
env_file: docker-compose.common.env
environment:
BASE_CONFIG:
@ -45,22 +46,23 @@ services:
test_karma:
build:
context: .
dockerfile: Dockerfile.frontend
context: ../..
dockerfile: services/web/Dockerfile.frontend
volumes:
- .:/app
- .:/overleaf/services/web
environment:
NODE_OPTIONS: "--unhandled-rejections=strict"
working_dir: /app
working_dir: /overleaf/services/web
command: npm run --silent test:karma:single
test_frontend:
build:
context: .
context: ../..
dockerfile: services/web/Dockerfile
target: base
volumes:
- .:/app
working_dir: /app
- .:/overleaf/services/web
working_dir: /overleaf/services/web
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_OPTIONS: "--unhandled-rejections=strict"

View file

@ -1,5 +1,5 @@
#!/bin/bash
SHARELATEX_CONFIG=/app/config/settings.webpack.js npm run webpack:production & WEBPACK=$!
SHARELATEX_CONFIG=/overleaf/services/web/config/settings.webpack.js npm run webpack:production & WEBPACK=$!
wait $WEBPACK && echo "Webpack complete" || exit 1