2022-01-06 10:02:36 -05:00
|
|
|
# the base image is suitable for running web with /overleaf/services/web bind
|
|
|
|
# mounted
|
2024-10-29 06:49:30 -04:00
|
|
|
FROM node:20.18.0 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
|
|
|
|
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
|
|
|
|
|
2024-07-03 04:49:13 -04:00
|
|
|
|
2020-07-02 11:51:38 -04:00
|
|
|
# the deps image is used for caching npm ci
|
2024-09-20 10:03:26 -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
|
|
|
|
|
2024-09-20 10:03:26 -04:00
|
|
|
FROM deps-prod AS deps
|
2023-08-23 06:17:37 -04:00
|
|
|
|
2022-03-30 05:49:41 -04:00
|
|
|
ENV CYPRESS_INSTALL_BINARY=0
|
|
|
|
|
2024-01-16 14:24:03 -05:00
|
|
|
COPY tsconfig.backend.json /overleaf/
|
2024-05-06 07:57:39 -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
|
2024-09-20 10:03:26 -04:00
|
|
|
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
|
2024-09-20 10:03:26 -04:00
|
|
|
FROM dev AS webpack
|
2020-07-02 11:51:38 -04:00
|
|
|
USER root
|
2024-09-27 06:31:10 -04:00
|
|
|
RUN OVERLEAF_CONFIG=/overleaf/services/web/config/settings.webpack.js npm run webpack:production
|
2020-07-02 11:51:38 -04:00
|
|
|
|
|
|
|
|
2024-07-03 04:49:13 -04:00
|
|
|
# intermediate image for removing source maps ahead of copying into final production image
|
2024-09-20 10:03:26 -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
|
|
|
|
|
|
|
|
2024-07-03 04:49:13 -04:00
|
|
|
# copy source code and precompile pug images
|
2024-09-20 10:03:26 -04:00
|
|
|
FROM deps-prod AS pug
|
2023-08-23 07:36:40 -04:00
|
|
|
COPY services/web /overleaf/services/web
|
2024-07-03 04:49:13 -04:00
|
|
|
# Omit Server Pro/CE specific scripts from SaaS image
|
2022-01-06 10:02:36 -05:00
|
|
|
RUN rm /overleaf/services/web/modules/server-ce-scripts -rf
|
2024-07-03 04:49:13 -04:00
|
|
|
RUN OVERLEAF_CONFIG=/overleaf/services/web/config/settings.overrides.saas.js npm run precompile-pug
|
|
|
|
|
|
|
|
|
|
|
|
# the web image with only production dependencies but no webpack production build, for development
|
2024-09-20 10:03:26 -04:00
|
|
|
FROM pug AS app-only
|
2020-07-02 11:51:38 -04:00
|
|
|
USER node
|
2024-09-25 12:02:35 -04:00
|
|
|
CMD ["node", "--expose-gc", "app.mjs"]
|
2020-07-02 11:51:38 -04:00
|
|
|
|
2024-07-03 04:49:13 -04:00
|
|
|
|
|
|
|
# the final production image, with webpack production build but without source maps
|
2024-09-20 10:03:26 -04:00
|
|
|
FROM pug AS app
|
2024-07-03 04:49:13 -04:00
|
|
|
ARG SENTRY_RELEASE
|
|
|
|
ENV SENTRY_RELEASE=$SENTRY_RELEASE
|
|
|
|
COPY --from=webpack-no-sourcemaps /overleaf/services/web/public /overleaf/services/web/public
|
|
|
|
USER node
|
2024-09-25 12:02:35 -04:00
|
|
|
CMD ["node", "--expose-gc", "app.mjs"]
|