BlocknoteJS requires an ESM module where our server is CJS, this forced us to pin the server-util version, which led us to force the resolution of several packages, leading to bugs downstream. From Node 22.12 Node supports requiring ESM modules (available from Node 22.0 with a flag). So I upgrade the module. I picked Node 22 and not Node 23 or Node 24 because 22 is the LTS and we don't plan to change node versions frequently. If you remain on Node 18, things should still mostly work, except if you edit a Rich Text field. I also starting changing the default runtime for Serverless Functions which isn't directly related. This means new serverless functions will be created on Node 22, but we will still need another PR to migrate existing serverless functions before September (end of support by AWS). (In this PR I also remove the upgrade commands from 0.43 since they rely on Blocknote and I didn't want to have to deal with this) --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
88 lines
3.1 KiB
Docker
88 lines
3.1 KiB
Docker
# Base image for common dependencies
|
|
FROM node:22-alpine as common-deps
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy only the necessary files for dependency resolution
|
|
COPY ./package.json ./yarn.lock ./.yarnrc.yml ./tsconfig.base.json ./nx.json /app/
|
|
COPY ./.yarn/releases /app/.yarn/releases
|
|
|
|
COPY ./.prettierrc /app/
|
|
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/
|
|
|
|
# Install all dependencies
|
|
RUN yarn && yarn cache clean && npx nx reset
|
|
|
|
|
|
# Build the back
|
|
FROM common-deps as twenty-server-build
|
|
|
|
# Copy sourcecode after installing dependences to accelerate subsequents builds
|
|
COPY ./packages/twenty-emails /app/packages/twenty-emails
|
|
COPY ./packages/twenty-shared /app/packages/twenty-shared
|
|
COPY ./packages/twenty-server /app/packages/twenty-server
|
|
|
|
RUN npx nx run twenty-server:build
|
|
RUN mv /app/packages/twenty-server/dist /app/packages/twenty-server/build
|
|
RUN npx nx run twenty-server:build:packageJson
|
|
RUN mv /app/packages/twenty-server/dist/package.json /app/packages/twenty-server/package.json
|
|
RUN rm -rf /app/packages/twenty-server/dist
|
|
RUN mv /app/packages/twenty-server/build /app/packages/twenty-server/dist
|
|
|
|
RUN yarn workspaces focus --production twenty-emails twenty-shared twenty-server
|
|
|
|
|
|
# Build the front
|
|
FROM common-deps as twenty-front-build
|
|
|
|
ARG REACT_APP_SERVER_BASE_URL
|
|
|
|
COPY ./packages/twenty-front /app/packages/twenty-front
|
|
COPY ./packages/twenty-ui /app/packages/twenty-ui
|
|
COPY ./packages/twenty-shared /app/packages/twenty-shared
|
|
RUN npx nx build twenty-front
|
|
|
|
|
|
# Final stage: Run the application
|
|
FROM node:22-alpine as twenty
|
|
|
|
# Used to run healthcheck in docker
|
|
RUN apk add --no-cache curl jq
|
|
|
|
RUN npm install -g tsx
|
|
|
|
RUN apk add --no-cache postgresql-client
|
|
|
|
COPY ./packages/twenty-docker/twenty/entrypoint.sh /app/entrypoint.sh
|
|
RUN chmod +x /app/entrypoint.sh
|
|
WORKDIR /app/packages/twenty-server
|
|
|
|
ARG REACT_APP_SERVER_BASE_URL
|
|
ENV REACT_APP_SERVER_BASE_URL $REACT_APP_SERVER_BASE_URL
|
|
|
|
ARG APP_VERSION
|
|
ENV APP_VERSION $APP_VERSION
|
|
|
|
# Copy built applications from previous stages
|
|
COPY --chown=1000 --from=twenty-server-build /app /app
|
|
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-server /app/packages/twenty-server
|
|
COPY --chown=1000 --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front
|
|
|
|
# Set metadata and labels
|
|
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
|
|
LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the backend and frontend, ensuring it deploys faster and runs the same way regardless of the deployment environment."
|
|
|
|
RUN mkdir -p /app/.local-storage /app/packages/twenty-server/.local-storage && \
|
|
chown -R 1000:1000 /app
|
|
|
|
# Use non root user with uid 1000
|
|
USER 1000
|
|
|
|
CMD ["node", "dist/src/main"]
|
|
ENTRYPOINT ["/app/entrypoint.sh"]
|