From 9771725cc49cc65a35f77a3dd685f1146f0e39c2 Mon Sep 17 00:00:00 2001 From: Paul Rastoin <45004772+prastoin@users.noreply.github.com> Date: Fri, 24 Apr 2026 16:24:32 +0200 Subject: [PATCH] Dockerfile `twenty-server` target (#20028) # Introduction Creating a target funnel that allow bypassing front build and injection in the server ## New targets - `twenty-server` only ships server - `twenty` ships both front and back in the same image - `twenty-server-aws` only ships server and `aws-cli` - `twenty-aws` ships both front and back in the same image with the `aws-image` --- packages/twenty-docker/twenty/Dockerfile | 45 +++++++++++++++++------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/packages/twenty-docker/twenty/Dockerfile b/packages/twenty-docker/twenty/Dockerfile index fe568468c2..d800270e93 100644 --- a/packages/twenty-docker/twenty/Dockerfile +++ b/packages/twenty-docker/twenty/Dockerfile @@ -70,11 +70,11 @@ RUN if [ -d /app/packages/twenty-front/build ]; then \ # =========================================================================== -# Target: twenty (production) -# docker build --target twenty -f packages/twenty-docker/twenty/Dockerfile . +# Target: twenty-server (server only, no frontend) +# docker build --target twenty-server -f packages/twenty-docker/twenty/Dockerfile . # =========================================================================== -FROM node:24-alpine AS twenty +FROM node:24-alpine AS twenty-server RUN apk add --no-cache curl jq postgresql-client @@ -82,9 +82,6 @@ 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 @@ -110,11 +107,8 @@ COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-client-sdk/dis 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/ -# Frontend static build -COPY --chown=1000 --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front - LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty -LABEL org.opencontainers.image.description="Production Twenty image with backend and frontend." +LABEL org.opencontainers.image.description="Twenty server image (no frontend)." RUN mkdir -p /app/.local-storage /app/packages/twenty-server/.local-storage && \ chown 1000:1000 /app/.local-storage /app/packages/twenty-server/.local-storage @@ -126,8 +120,35 @@ ENTRYPOINT ["/app/entrypoint.sh"] # =========================================================================== -# Target: twenty-aws -# docker build --target twenty-aws -f packages/twenty-docker/twenty/Dockerfile . +# Target: twenty-server-aws (server only + aws-cli, no frontend) +# docker build --target twenty-server-aws -f packages/twenty-docker/twenty/Dockerfile . +# =========================================================================== + +FROM twenty-server AS twenty-server-aws + +USER root +RUN apk add --no-cache aws-cli +USER 1000 + + +# =========================================================================== +# Target: twenty (server + frontend) +# docker build --target twenty -f packages/twenty-docker/twenty/Dockerfile . +# =========================================================================== + +FROM twenty-server AS twenty + +ARG REACT_APP_SERVER_BASE_URL +ENV REACT_APP_SERVER_BASE_URL=$REACT_APP_SERVER_BASE_URL + +COPY --chown=1000 --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front + +LABEL org.opencontainers.image.description="Twenty image with backend and frontend." + + +# =========================================================================== +# Target: twenty-aws (server + frontend + aws-cli) +# docker build --target twenty-aws -f packages/twenty-docker/twenty/Dockerfile . # =========================================================================== FROM twenty AS twenty-aws