-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into brkuhgk/issue-4502
- Loading branch information
Showing
1,452 changed files
with
14,516 additions
and
11,640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
server/node_modules/ | ||
server/.env | ||
.git | ||
.env | ||
node_modules | ||
.nx/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
TAG=latest | ||
|
||
POSTGRES_ADMIN_PASSWORD=replace_me_with_a_strong_password | ||
|
||
PG_DATABASE_HOST=db:5432 | ||
|
||
SERVER_URL=http://localhost:3000 | ||
# Uncoment if you are serving your front on another server than the API (eg. bucket) | ||
# FRONT_BASE_URL=http://localhost:3000 | ||
|
||
# Use openssl rand -base64 32 for each secret | ||
# ACCESS_TOKEN_SECRET=replace_me_with_a_random_string_access | ||
# LOGIN_TOKEN_SECRET=replace_me_with_a_random_string_login | ||
# REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh | ||
|
||
SIGN_IN_PREFILLED=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
version: '3.8' | ||
name: twenty | ||
|
||
services: | ||
server: | ||
image: twentycrm/twenty:${TAG} | ||
volumes: | ||
- server-local-data:/app/.local-storage | ||
ports: | ||
- "3000:3000" | ||
environment: | ||
PORT: 3000 | ||
PG_DATABASE_URL: postgres://twenty:twenty@${PG_DATABASE_HOST}/default | ||
SERVER_URL: ${SERVER_URL} | ||
FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL} | ||
|
||
ENABLE_DB_MIGRATIONS: true | ||
|
||
SIGN_IN_PREFILLED: ${SIGN_IN_PREFILLED} | ||
STORAGE_TYPE: local | ||
STORAGE_LOCAL_PATH: .local-storage | ||
ACCESS_TOKEN_SECRET: ${ACCESS_TOKEN_SECRET} | ||
LOGIN_TOKEN_SECRET: ${LOGIN_TOKEN_SECRET} | ||
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET} | ||
depends_on: | ||
db: | ||
condition: service_healthy | ||
healthcheck: | ||
test: ["CMD-SHELL", "curl --silent --fail http://localhost:3000/healthz | jq -e '.status == \"ok\"' > /dev/null || exit 1"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 10 | ||
restart: always | ||
|
||
db: | ||
image: twentycrm/twenty-postgres:${TAG} | ||
volumes: | ||
- db-data:/var/lib/postgresql/data | ||
environment: | ||
POSTGRES_PASSWORD: ${POSTGRES_ADMIN_PASSWORD} | ||
#POSTGRES_USER: ${POSTGRES_USER} | ||
#POSTGRES_DB: ${POSTGRES_DB} | ||
healthcheck: | ||
test: ["CMD-SHELL", "pg_isready -U twenty -d default"] | ||
interval: 5s | ||
timeout: 5s | ||
retries: 10 | ||
restart: always | ||
|
||
volumes: | ||
db-data: | ||
server-local-data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Base image for common dependencies | ||
FROM node:18.17.1-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 ./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-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-server /app/packages/twenty-server | ||
|
||
RUN npx nx run twenty-server:build && \ | ||
mv /app/packages/twenty-server/dist /app/packages/twenty-server/build && \ | ||
npx nx run twenty-server:build:packageJson && \ | ||
mv /app/packages/twenty-server/dist/package.json /app/packages/twenty-server/package.json && \ | ||
rm -rf /app/packages/twenty-server/dist && \ | ||
mv /app/packages/twenty-server/build /app/packages/twenty-server/dist | ||
|
||
RUN yarn workspaces focus --production twenty-emails 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 | ||
RUN yarn nx build twenty-front | ||
|
||
|
||
# Final stage: Run the application | ||
FROM node:18.17.1-alpine as twenty | ||
|
||
# Used to run healthcheck in docker | ||
RUN apk add --no-cache curl jq | ||
|
||
COPY ./packages/twenty-docker/prod/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 | ||
|
||
# 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 /app/.local-storage | ||
RUN chown -R 1000 /app | ||
|
||
# Use non root user with uid 1000 | ||
USER 1000 | ||
|
||
CMD ["node", "dist/src/main"] | ||
ENTRYPOINT ["/app/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
|
||
# Check if the initialization has already been done and that we enabled automatic migration | ||
if [ "${ENABLE_DB_MIGRATIONS}" = "true" ] && [ ! -f /app/${STORAGE_LOCAL_PATH}/db_initialized ]; then | ||
echo "Running database setup and migrations..." | ||
|
||
# Run setup and migration scripts | ||
npx ts-node ./scripts/setup-db.ts | ||
yarn database:migrate:prod | ||
|
||
# Mark initialization as done | ||
echo "Successfuly migrated DB!" | ||
touch /app/${STORAGE_LOCAL_PATH}/db_initialized | ||
fi | ||
|
||
# Continue with the original Docker command | ||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.