[DockerFile] Optimize twenty-server deps and build (#20132)
# Introduction Aiming for faster cd process ## Splitting front end server deps Reduce dependencies bloating when target is server only, installing only root repo dev deps and server dev and prod deps Still pruning before copying to prod node_modules ## Server only remove twenty-ui Also removing twenty-ui from server build as it was not consumed at all Depends on https://github.com/twentyhq/twenty/pull/20140
This commit is contained in:
@@ -1,8 +1,26 @@
|
||||
# ===========================================================================
|
||||
# Shared build stages (used by both targets)
|
||||
# Dependency stages
|
||||
# ===========================================================================
|
||||
|
||||
FROM node:24-alpine AS common-deps
|
||||
FROM node:24-alpine AS front-deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./package.json ./yarn.lock ./.yarnrc.yml ./tsconfig.base.json ./nx.json /app/
|
||||
COPY ./.yarn/releases /app/.yarn/releases
|
||||
COPY ./.yarn/patches /app/.yarn/patches
|
||||
|
||||
COPY ./packages/twenty-ui/package.json /app/packages/twenty-ui/
|
||||
COPY ./packages/twenty-shared/package.json /app/packages/twenty-shared/
|
||||
COPY ./packages/twenty-front/package.json /app/packages/twenty-front/
|
||||
COPY ./packages/twenty-front-component-renderer/package.json /app/packages/twenty-front-component-renderer/
|
||||
COPY ./packages/twenty-sdk/package.json /app/packages/twenty-sdk/
|
||||
COPY ./packages/twenty-client-sdk/package.json /app/packages/twenty-client-sdk/
|
||||
|
||||
RUN yarn workspaces focus twenty twenty-front twenty-front-component-renderer twenty-ui twenty-shared twenty-sdk twenty-client-sdk && yarn cache clean && npx nx reset
|
||||
|
||||
|
||||
FROM node:24-alpine AS server-deps
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -13,22 +31,16 @@ COPY ./.yarn/patches /app/.yarn/patches
|
||||
COPY ./packages/twenty-emails/package.json /app/packages/twenty-emails/
|
||||
COPY ./packages/twenty-server/package.json /app/packages/twenty-server/
|
||||
COPY ./packages/twenty-server/patches /app/packages/twenty-server/patches
|
||||
COPY ./packages/twenty-ui/package.json /app/packages/twenty-ui/
|
||||
COPY ./packages/twenty-shared/package.json /app/packages/twenty-shared/
|
||||
COPY ./packages/twenty-front/package.json /app/packages/twenty-front/
|
||||
COPY ./packages/twenty-front-component-renderer/package.json /app/packages/twenty-front-component-renderer/
|
||||
COPY ./packages/twenty-sdk/package.json /app/packages/twenty-sdk/
|
||||
COPY ./packages/twenty-client-sdk/package.json /app/packages/twenty-client-sdk/
|
||||
|
||||
RUN yarn && yarn cache clean && npx nx reset
|
||||
RUN yarn workspaces focus twenty twenty-server twenty-emails twenty-shared twenty-client-sdk && yarn cache clean && npx nx reset
|
||||
|
||||
|
||||
FROM common-deps AS twenty-server-build
|
||||
FROM server-deps AS twenty-server-build
|
||||
|
||||
COPY ./packages/twenty-emails /app/packages/twenty-emails
|
||||
COPY ./packages/twenty-shared /app/packages/twenty-shared
|
||||
COPY ./packages/twenty-ui /app/packages/twenty-ui
|
||||
COPY ./packages/twenty-sdk /app/packages/twenty-sdk
|
||||
COPY ./packages/twenty-client-sdk /app/packages/twenty-client-sdk
|
||||
COPY ./packages/twenty-server /app/packages/twenty-server
|
||||
|
||||
@@ -44,10 +56,10 @@ RUN npx nx run twenty-server:build
|
||||
RUN find /app/packages/twenty-server/dist -name '*.d.ts' -delete \
|
||||
&& rm -rf /app/packages/twenty-server/dist/packages/twenty-server/test
|
||||
|
||||
RUN yarn workspaces focus --production twenty-emails twenty-shared twenty-sdk twenty-client-sdk twenty-server
|
||||
RUN yarn workspaces focus --production twenty-emails twenty-shared twenty-client-sdk twenty-server
|
||||
|
||||
|
||||
FROM common-deps AS twenty-front-build
|
||||
FROM front-deps AS twenty-front-build
|
||||
|
||||
COPY ./packages/twenty-front /app/packages/twenty-front
|
||||
COPY ./packages/twenty-front-component-renderer /app/packages/twenty-front-component-renderer
|
||||
@@ -99,11 +111,8 @@ COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-shared/package
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-shared/dist /app/packages/twenty-shared/dist
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-emails/package.json /app/packages/twenty-emails/
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-emails/dist /app/packages/twenty-emails/dist
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-sdk/package.json /app/packages/twenty-sdk/
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-client-sdk/package.json /app/packages/twenty-client-sdk/
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-client-sdk/dist /app/packages/twenty-client-sdk/dist
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-ui/package.json /app/packages/twenty-ui/
|
||||
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-front/package.json /app/packages/twenty-front/
|
||||
|
||||
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
||||
LABEL org.opencontainers.image.description="Twenty server image (no frontend)."
|
||||
@@ -208,11 +217,8 @@ COPY --from=twenty-server-build /app/packages/twenty-shared/package.json /app/pa
|
||||
COPY --from=twenty-server-build /app/packages/twenty-shared/dist /app/packages/twenty-shared/dist
|
||||
COPY --from=twenty-server-build /app/packages/twenty-emails/package.json /app/packages/twenty-emails/
|
||||
COPY --from=twenty-server-build /app/packages/twenty-emails/dist /app/packages/twenty-emails/dist
|
||||
COPY --from=twenty-server-build /app/packages/twenty-sdk/package.json /app/packages/twenty-sdk/
|
||||
COPY --from=twenty-server-build /app/packages/twenty-client-sdk/package.json /app/packages/twenty-client-sdk/
|
||||
COPY --from=twenty-server-build /app/packages/twenty-client-sdk/dist /app/packages/twenty-client-sdk/dist
|
||||
COPY --from=twenty-server-build /app/packages/twenty-ui/package.json /app/packages/twenty-ui/
|
||||
COPY --from=twenty-server-build /app/packages/twenty-front/package.json /app/packages/twenty-front/
|
||||
|
||||
# Frontend static build
|
||||
COPY --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front
|
||||
|
||||
@@ -80,7 +80,9 @@
|
||||
"apollo-link-rest": "^0.10.0-rc.2",
|
||||
"apollo-upload-client": "^19.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"country-flag-icons": "^1.5.11",
|
||||
"cron-parser": "5.1.1",
|
||||
"d3-shape": "^3.2.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"date-fns-tz": "^2.0.0",
|
||||
"deep-equal": "^2.2.2",
|
||||
@@ -90,6 +92,7 @@
|
||||
"graphiql": "^3.1.1",
|
||||
"graphql": "16.8.1",
|
||||
"graphql-sse": "^2.5.4",
|
||||
"graphql-tag": "^2.12.6",
|
||||
"immer": "^10.1.1",
|
||||
"input-otp": "^1.4.2",
|
||||
"jotai": "^2.17.1",
|
||||
@@ -97,10 +100,18 @@
|
||||
"json-2-csv": "^5.4.0",
|
||||
"json-logic-js": "^2.0.5",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"libphonenumber-js": "^1.10.26",
|
||||
"linkify-react": "^4.1.3",
|
||||
"linkifyjs": "^4.1.3",
|
||||
"lodash.camelcase": "^4.3.0",
|
||||
"lodash.groupby": "^4.6.0",
|
||||
"lodash.isempty": "^4.4.0",
|
||||
"lodash.omit": "^4.5.0",
|
||||
"lodash.uniqby": "^4.7.0",
|
||||
"marked": "^17.0.1",
|
||||
"microdiff": "^1.3.2",
|
||||
"papaparse": "^5.4.1",
|
||||
"pluralize": "^8.0.0",
|
||||
"qs": "^6.11.2",
|
||||
"react": "^18.2.0",
|
||||
"react-data-grid": "7.0.0-beta.13",
|
||||
@@ -122,15 +133,18 @@
|
||||
"react-router-dom": "^6.4.4",
|
||||
"react-textarea-autosize": "^8.4.1",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"rxjs": "^7.2.0",
|
||||
"temporal-polyfill": "^0.3.0",
|
||||
"transliteration": "^2.3.5",
|
||||
"ts-key-enum": "^2.0.12",
|
||||
"twenty-front-component-renderer": "workspace:*",
|
||||
"twenty-shared": "workspace:*",
|
||||
"twenty-ui": "workspace:*",
|
||||
"type-fest": "4.10.1",
|
||||
"use-debounce": "^10.0.0",
|
||||
"uuid": "^9.0.0",
|
||||
"xlsx-ugnis": "^0.19.3"
|
||||
"xlsx-ugnis": "^0.19.3",
|
||||
"zod": "^4.1.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.5",
|
||||
@@ -180,6 +194,7 @@
|
||||
"oxlint-tsgolint": "^0.16.0",
|
||||
"playwright": "^1.56.1",
|
||||
"prettier": "^3.1.1",
|
||||
"rollup-plugin-node-polyfills": "^0.2.1",
|
||||
"rollup-plugin-visualizer": "^5.14.0",
|
||||
"storybook-addon-mock-date": "2.0.0",
|
||||
"storybook-addon-pseudo-states": "^10.3.3",
|
||||
|
||||
@@ -44266,7 +44266,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lodash.isempty@npm:4.4.0":
|
||||
"lodash.isempty@npm:4.4.0, lodash.isempty@npm:^4.4.0":
|
||||
version: 4.4.0
|
||||
resolution: "lodash.isempty@npm:4.4.0"
|
||||
checksum: 10c0/6c7eaa0802398736809b9e8aed8b8ac1abca9be71788fd719ba9d7f5b4c23e8dc63b7f049df4131713dda30a2fdedc2f655268e9deb8cd5a985dfc934afca194
|
||||
@@ -57887,7 +57887,9 @@ __metadata:
|
||||
apollo-upload-client: "npm:^19.0.0"
|
||||
buffer: "npm:^6.0.3"
|
||||
chromatic: "npm:^6.18.0"
|
||||
country-flag-icons: "npm:^1.5.11"
|
||||
cron-parser: "npm:5.1.1"
|
||||
d3-shape: "npm:^3.2.0"
|
||||
date-fns: "npm:^2.30.0"
|
||||
date-fns-tz: "npm:^2.0.0"
|
||||
deep-equal: "npm:^2.2.2"
|
||||
@@ -57898,6 +57900,7 @@ __metadata:
|
||||
graphiql: "npm:^3.1.1"
|
||||
graphql: "npm:16.8.1"
|
||||
graphql-sse: "npm:^2.5.4"
|
||||
graphql-tag: "npm:^2.12.6"
|
||||
immer: "npm:^10.1.1"
|
||||
input-otp: "npm:^1.4.2"
|
||||
jest: "npm:29.7.0"
|
||||
@@ -57908,8 +57911,14 @@ __metadata:
|
||||
json-2-csv: "npm:^5.4.0"
|
||||
json-logic-js: "npm:^2.0.5"
|
||||
jwt-decode: "npm:^4.0.0"
|
||||
libphonenumber-js: "npm:^1.10.26"
|
||||
linkify-react: "npm:^4.1.3"
|
||||
linkifyjs: "npm:^4.1.3"
|
||||
lodash.camelcase: "npm:^4.3.0"
|
||||
lodash.groupby: "npm:^4.6.0"
|
||||
lodash.isempty: "npm:^4.4.0"
|
||||
lodash.omit: "npm:^4.5.0"
|
||||
lodash.uniqby: "npm:^4.7.0"
|
||||
marked: "npm:^17.0.1"
|
||||
microdiff: "npm:^1.3.2"
|
||||
monaco-editor: "npm:^0.51.0"
|
||||
@@ -57919,7 +57928,9 @@ __metadata:
|
||||
optionator: "npm:^0.9.1"
|
||||
oxlint: "npm:^1.51.0"
|
||||
oxlint-tsgolint: "npm:^0.16.0"
|
||||
papaparse: "npm:^5.4.1"
|
||||
playwright: "npm:^1.56.1"
|
||||
pluralize: "npm:^8.0.0"
|
||||
prettier: "npm:^3.1.1"
|
||||
qs: "npm:^6.11.2"
|
||||
react: "npm:^18.2.0"
|
||||
@@ -57942,7 +57953,9 @@ __metadata:
|
||||
react-router-dom: "npm:^6.4.4"
|
||||
react-textarea-autosize: "npm:^8.4.1"
|
||||
remark-gfm: "npm:^4.0.1"
|
||||
rollup-plugin-node-polyfills: "npm:^0.2.1"
|
||||
rollup-plugin-visualizer: "npm:^5.14.0"
|
||||
rxjs: "npm:^7.2.0"
|
||||
storybook-addon-mock-date: "npm:2.0.0"
|
||||
storybook-addon-pseudo-states: "npm:^10.3.3"
|
||||
temporal-polyfill: "npm:^0.3.0"
|
||||
@@ -57952,11 +57965,13 @@ __metadata:
|
||||
twenty-front-component-renderer: "workspace:*"
|
||||
twenty-shared: "workspace:*"
|
||||
twenty-ui: "workspace:*"
|
||||
type-fest: "npm:4.10.1"
|
||||
use-debounce: "npm:^10.0.0"
|
||||
uuid: "npm:^9.0.0"
|
||||
vite-plugin-svgr: "npm:^4.3.0"
|
||||
vite-tsconfig-paths: "npm:^4.2.1"
|
||||
xlsx-ugnis: "npm:^0.19.3"
|
||||
zod: "npm:^4.1.11"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user