2022-01-06 10:02:36 -05:00
|
|
|
# the base image is suitable for running web with /overleaf/services/web bind
|
|
|
|
# mounted
|
2023-08-14 09:54:15 -04:00
|
|
|
FROM node:18.17.1 as base
|
2019-02-19 09:51:34 -05:00
|
|
|
|
2022-01-06 10:02:36 -05:00
|
|
|
WORKDIR /overleaf/services/web
|
2019-02-19 09:51:34 -05:00
|
|
|
|
2020-02-12 07:54:45 -05:00
|
|
|
# install_deps changes app files and installs npm packages
|
|
|
|
# as such it has to run at a later stage
|
|
|
|
|
2022-02-07 06:46:51 -05:00
|
|
|
# Google Cloud Storage needs a writable $HOME/.config for resumable uploads
|
|
|
|
# (see https://googleapis.dev/nodejs/storage/latest/File.html#createWriteStream)
|
|
|
|
RUN mkdir /home/node/.config && chown node:node /home/node/.config
|
2020-07-02 11:51:38 -04:00
|
|
|
|
2023-08-23 07:36:40 -04:00
|
|
|
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
|
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
# the deps image is used for caching npm ci
|
2023-08-23 06:17:37 -04:00
|
|
|
FROM base as deps-prod
|
2020-02-12 07:54:45 -05:00
|
|
|
|
2022-02-07 06:46:51 -05:00
|
|
|
COPY package.json package-lock.json /overleaf/
|
|
|
|
COPY services/web/package.json /overleaf/services/web/
|
|
|
|
COPY libraries/ /overleaf/libraries/
|
2022-05-26 04:01:50 -04:00
|
|
|
COPY patches/ /overleaf/patches/
|
2019-02-19 09:51:34 -05:00
|
|
|
|
2023-08-23 06:17:37 -04:00
|
|
|
RUN cd /overleaf && NODE_ENV=production npm ci --quiet
|
|
|
|
|
|
|
|
FROM deps-prod as deps
|
|
|
|
|
2022-03-30 05:49:41 -04:00
|
|
|
ENV CYPRESS_INSTALL_BINARY=0
|
|
|
|
|
2023-08-23 06:17:37 -04:00
|
|
|
RUN cd /overleaf && npm install
|
2020-05-22 06:34:57 -04:00
|
|
|
|
2019-02-19 09:51:34 -05:00
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
# the dev is suitable for running tests
|
|
|
|
FROM deps as dev
|
2020-02-12 10:37:32 -05:00
|
|
|
|
2023-08-23 07:36:40 -04:00
|
|
|
ARG SENTRY_RELEASE
|
|
|
|
ENV SENTRY_RELEASE=$SENTRY_RELEASE
|
2022-01-06 10:02:36 -05:00
|
|
|
COPY services/web /overleaf/services/web
|
2020-02-12 10:37:32 -05:00
|
|
|
|
2022-06-23 04:19:07 -04:00
|
|
|
# Build the latex parser
|
|
|
|
RUN cd /overleaf/services/web && npm run 'lezer-latex:generate'
|
|
|
|
|
2019-02-19 09:51:34 -05:00
|
|
|
USER node
|
|
|
|
|
2020-06-23 09:15:49 -04:00
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
# the webpack image has deps+src+webpack artifacts
|
|
|
|
FROM dev as webpack
|
|
|
|
|
|
|
|
USER root
|
|
|
|
RUN chmod 0755 ./install_deps.sh && ./install_deps.sh
|
|
|
|
|
|
|
|
|
|
|
|
# the final production image without webpack source maps
|
2023-08-23 06:17:37 -04:00
|
|
|
FROM webpack as webpack-no-sourcemaps
|
2022-01-06 10:02:36 -05:00
|
|
|
RUN find /overleaf/services/web/public -name '*.js.map' -delete
|
2023-08-23 06:17:37 -04:00
|
|
|
|
|
|
|
FROM deps-prod as app
|
|
|
|
|
2023-08-23 07:36:40 -04:00
|
|
|
ARG SENTRY_RELEASE
|
|
|
|
ENV SENTRY_RELEASE=$SENTRY_RELEASE
|
|
|
|
COPY services/web /overleaf/services/web
|
2023-08-23 06:17:37 -04:00
|
|
|
COPY --from=webpack-no-sourcemaps /overleaf/services/web/public /overleaf/services/web/public
|
2022-01-06 10:02:36 -05:00
|
|
|
RUN rm /overleaf/services/web/modules/server-ce-scripts -rf
|
2020-07-02 11:51:38 -04:00
|
|
|
USER node
|
|
|
|
|
|
|
|
CMD ["node", "--expose-gc", "app.js"]
|