Skip to content

Commit 9771725

Browse files
authored
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`
1 parent 2a3c759 commit 9771725

1 file changed

Lines changed: 33 additions & 12 deletions

File tree

packages/twenty-docker/twenty/Dockerfile

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,18 @@ RUN if [ -d /app/packages/twenty-front/build ]; then \
7070

7171

7272
# ===========================================================================
73-
# Target: twenty (production)
74-
# docker build --target twenty -f packages/twenty-docker/twenty/Dockerfile .
73+
# Target: twenty-server (server only, no frontend)
74+
# docker build --target twenty-server -f packages/twenty-docker/twenty/Dockerfile .
7575
# ===========================================================================
7676

77-
FROM node:24-alpine AS twenty
77+
FROM node:24-alpine AS twenty-server
7878

7979
RUN apk add --no-cache curl jq postgresql-client
8080

8181
COPY ./packages/twenty-docker/twenty/entrypoint.sh /app/entrypoint.sh
8282
RUN chmod +x /app/entrypoint.sh
8383
WORKDIR /app/packages/twenty-server
8484

85-
ARG REACT_APP_SERVER_BASE_URL
86-
ENV REACT_APP_SERVER_BASE_URL=$REACT_APP_SERVER_BASE_URL
87-
8885
ARG APP_VERSION
8986
ENV APP_VERSION=$APP_VERSION
9087

@@ -110,11 +107,8 @@ COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-client-sdk/dis
110107
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-ui/package.json /app/packages/twenty-ui/
111108
COPY --chown=1000 --from=twenty-server-build /app/packages/twenty-front/package.json /app/packages/twenty-front/
112109

113-
# Frontend static build
114-
COPY --chown=1000 --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front
115-
116110
LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty
117-
LABEL org.opencontainers.image.description="Production Twenty image with backend and frontend."
111+
LABEL org.opencontainers.image.description="Twenty server image (no frontend)."
118112

119113
RUN mkdir -p /app/.local-storage /app/packages/twenty-server/.local-storage && \
120114
chown 1000:1000 /app/.local-storage /app/packages/twenty-server/.local-storage
@@ -126,8 +120,35 @@ ENTRYPOINT ["/app/entrypoint.sh"]
126120

127121

128122
# ===========================================================================
129-
# Target: twenty-aws
130-
# docker build --target twenty-aws -f packages/twenty-docker/twenty/Dockerfile .
123+
# Target: twenty-server-aws (server only + aws-cli, no frontend)
124+
# docker build --target twenty-server-aws -f packages/twenty-docker/twenty/Dockerfile .
125+
# ===========================================================================
126+
127+
FROM twenty-server AS twenty-server-aws
128+
129+
USER root
130+
RUN apk add --no-cache aws-cli
131+
USER 1000
132+
133+
134+
# ===========================================================================
135+
# Target: twenty (server + frontend)
136+
# docker build --target twenty -f packages/twenty-docker/twenty/Dockerfile .
137+
# ===========================================================================
138+
139+
FROM twenty-server AS twenty
140+
141+
ARG REACT_APP_SERVER_BASE_URL
142+
ENV REACT_APP_SERVER_BASE_URL=$REACT_APP_SERVER_BASE_URL
143+
144+
COPY --chown=1000 --from=twenty-front-build /app/packages/twenty-front/build /app/packages/twenty-server/dist/front
145+
146+
LABEL org.opencontainers.image.description="Twenty image with backend and frontend."
147+
148+
149+
# ===========================================================================
150+
# Target: twenty-aws (server + frontend + aws-cli)
151+
# docker build --target twenty-aws -f packages/twenty-docker/twenty/Dockerfile .
131152
# ===========================================================================
132153

133154
FROM twenty AS twenty-aws

0 commit comments

Comments
 (0)