[Wip] Update CI CD (#2945)

* Update CI and CD scripts

* Fix docker docs build

* Fix CD

* Fix CD

* Update front build and add postgres intel pg_graphql files

* Fix postgres install

* Fix

* Update docs
This commit is contained in:
Charles Bochet 2023-12-12 22:38:40 +01:00 committed by GitHub
parent 6594055317
commit 2496431703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
45 changed files with 389 additions and 451 deletions

View File

@ -10,14 +10,14 @@ docker-dev-down:
docker-dev-sh:
make -C packages/twenty-docker dev-sh
postgres-provision-on-docker:
make -C packages/twenty-docker dev-postgres-build
postgres-on-docker:
make -C packages/twenty-postgres provision-on-docker
postgres-provision-on-macos-arm:
postgres-on-macos-arm:
make -C packages/twenty-postgres provision-on-macos-arm
postgres-provision-on-macos-intel:
postgres-on-macos-intel:
make -C packages/twenty-postgres provision-on-macos-intel
postgres-provision-on-linux:
postgres-on-linux:
make -C packages/twenty-postgres provision-on-linux

View File

@ -1,11 +1,13 @@
dev-build:
@docker compose -f dev/docker-compose.yml down
@docker compose -f dev/docker-compose.yml down
rm -rf ../twenty-front/node_modules
rm -rf ../twenty-server/node_modules
rm -rf ../twenty-docs/node_modules
@docker volume rm twenty_node_modules_front > /dev/null 2>&1 || true
@docker volume rm twenty_node_modules_server > /dev/null 2>&1 || true
@docker volume rm twenty_node_modules_docs > /dev/null 2>&1 || true
@docker volume rm twenty_dev_node_modules_front > /dev/null 2>&1 || true
@docker volume rm twenty_dev_node_modules_server > /dev/null 2>&1 || true
@docker volume rm twenty_dev_node_modules_docs > /dev/null 2>&1 || true
@docker volume rm twenty_dev_node_modules_root > /dev/null 2>&1 || true
@docker volume rm twenty_dev_node_modules_yarn > /dev/null 2>&1 || true
@docker compose -f dev/docker-compose.yml build
dev-up:
@ -22,3 +24,59 @@ dev-postgres-build:
@docker rm twenty_postgres || true
@docker volume rm twenty_db_data || true
@docker compose -f dev/docker-compose.yml up --build postgres -d
prod-docs-build:
@cd ../.. && docker build -f ./packages/twenty-docker/prod/twenty-docs/Dockerfile --tag twenty-docs . && cd -
prod-docs-run:
@docker run -p 3000:3000 twenty-docs
prod-front-build:
@cd ../.. && docker build -f ./packages/twenty-docker/prod/twenty-front/Dockerfile --tag twenty-front . && cd -
prod-front-run:
@docker run -p 3000:3000 twenty-front
prod-server-build:
@cd ../.. && docker build -f ./packages/twenty-docker/prod/twenty-server/Dockerfile --tag twenty-server . && cd -
prod-server-run:
@docker run -p 3000:3000 twenty-server
prod-postgres-build:
@cd ../.. && docker build -f ./packages/twenty-docker/prod/twenty-postgres/Dockerfile --tag twenty-postgres . && cd -
prod-postgres-run:
@docker run -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres twenty-postgres
release-front:
@cd ../.. && docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./packages/twenty-docker/prod/twenty-front/Dockerfile -t twentycrm/twenty-front:$(version) -t twentycrm/twenty-front:latest . \
&& cd -
release-server:
@cd ../.. && docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./packages/twenty-docker/prod/twenty-server/Dockerfile -t twentycrm/twenty-server:$(version) -t twentycrm/twenty-server:latest . \
&& cd -
release-docs:
@cd ../.. && docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./packages/twenty-docker/prod/twenty-docs/Dockerfile -t twentycrm/twenty-docs:$(version) -t twentycrm/twenty-docs:latest . \
&& cd -
release-postgres:
@cd ../.. && docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./packages/twenty-docker/prod/twenty-postgres/Dockerfile -t twentycrm/twenty-postgres:$(version) -t twentycrm/twenty-postgres:latest . \
&& cd -

View File

@ -1,18 +0,0 @@
FROM node:18.16.0-alpine as docs
WORKDIR /app/docs
ARG SHOULD_INDEX_DOC
COPY ./docs/package.json .
COPY ./docs/yarn.lock .
RUN yarn install
COPY ./docs .
RUN npm run build
RUN yarn global add serve
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 documentation."
CMD ["serve", "-s", "./build"]

View File

@ -1,29 +0,0 @@
FROM node:18.16.0-alpine as build
ARG REACT_APP_SERVER_BASE_URL
ARG REACT_APP_SERVER_AUTH_URL
ARG REACT_APP_SERVER_FILES_URL
COPY ./packages/ /app/packages
WORKDIR /app/front
COPY ./front .
RUN yarn install
RUN yarn build
COPY ./infra/build/front/serve.json ./build
FROM node:18.16.0-alpine as front
WORKDIR /app/front
COPY --from=build /app/front/build ./build
COPY ./front/scripts/inject-runtime-env.sh /app/front/scripts/inject-runtime-env.sh
RUN yarn global add serve
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 frontend."
CMD ["/bin/sh", "-c", "/app/front/scripts/inject-runtime-env.sh && serve build"]

View File

@ -1,10 +0,0 @@
SELECT 'CREATE DATABASE "default"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
SELECT 'CREATE DATABASE "test"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test')\gexec
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
SELECT 'ALTER ROLE twenty superuser'\gexec

View File

@ -1,15 +0,0 @@
FROM node:18.16.0-alpine as build
WORKDIR /app/server
COPY ./server/package.json ./
COPY ./server/yarn.lock ./
COPY ./server/patches ./patches
RUN yarn install
COPY ./server .
RUN yarn build
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, ensuring it deploys faster and runs the same way regardless of the deployment environment."
CMD ["node", "dist/src/main"]

View File

@ -18,25 +18,14 @@ services:
- twenty_dev_node_modules_server:/app/packages/twenty-server/node_modules
depends_on:
- postgres
twenty-docs:
build:
context: ../../..
dockerfile: ./packages/twenty-docker/dev/twenty-docs/Dockerfile
ports:
- "5001:5001"
volumes:
- ../../../packages/twenty-docs:/app/packages/twenty-docs
- twenty_docs_node_modules_root:/app/node_modules
- twenty_docs_node_modules_yarn:/app/.yarn
- twenty_docs_node_modules_docs:/app/packages/twenty-docs/node_modules
postgres:
container_name: twenty_postgres
build: ./postgres
image: twentycrm/twenty-postgres:latest
volumes:
- twenty_db_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=twenty
- POSTGRES_PASSWORD=twenty
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=default
ports:
- "5432:5432"
@ -47,6 +36,4 @@ volumes:
twenty_dev_node_modules_yarn:
twenty_dev_node_modules_front:
twenty_dev_node_modules_server:
twenty_docs_node_modules_root:
twenty_docs_node_modules_yarn:
twenty_docs_node_modules_docs:
twenty_dev_node_modules_docs:

View File

@ -1,35 +0,0 @@
ARG PG_MAIN_VERSION=15.5
FROM postgres:${PG_MAIN_VERSION}-bullseye as postgres
ARG PG_MAIN_VERSION=15
ARG PG_GRAPHQL_VERSION=1.4.2
ARG WRAPPERS_VERSION=0.2.0
ARG TARGETARCH
RUN set -eux; \
ARCH="$(dpkg --print-architecture)"; \
case "${ARCH}" in \
aarch64|arm64) \
TARGETARCH='arm64'; \
;; \
amd64|x86_64) \
TARGETARCH='amd64'; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac;
RUN apt update && apt install curl -y
# Install precompiled pg_graphql extensions
RUN curl -L "https://github.com/supabase/pg_graphql/releases/download/v${PG_GRAPHQL_VERSION}/pg_graphql-v${PG_GRAPHQL_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o pg_graphql.deb
RUN dpkg --install pg_graphql.deb
# Install precompiled supabase wrappers extensions
RUN curl -L "https://github.com/supabase/wrappers/releases/download/v${WRAPPERS_VERSION}/wrappers-v${WRAPPERS_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o wrappers.deb
RUN dpkg --install wrappers.deb
COPY init.sql /docker-entrypoint-initdb.d/

View File

@ -1,10 +0,0 @@
SELECT 'CREATE DATABASE "default"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
SELECT 'CREATE DATABASE "test"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test')\gexec
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
SELECT 'ALTER ROLE twenty superuser'\gexec

View File

@ -1,16 +1,14 @@
FROM node:18.16-bullseye as twenty-dev
WORKDIR /app
COPY ../../../../package.json .
COPY ../../../../yarn.lock .
COPY ../../../../.yarnrc.yml .
COPY ../../../../.yarn/releases /app/.yarn/releases
COPY ../../../packages/twenty-front/package.json /app/packages/twenty-front/package.json
COPY ../../../packages/twenty-server/package.json /app/packages/twenty-server/package.json
COPY ../../../packages/twenty-server/patches /app/packages/twenty-server/patches
COPY ../../../packages/eslint-plugin-twenty/package.json /app/packages/eslint-plugin-twenty/package.json
RUN yarn
COPY ./package.json .
COPY ./yarn.lock .
COPY ./.yarnrc.yml .
COPY ./.yarn/releases /app/.yarn/releases
COPY ./packages/twenty-front/package.json /app/packages/twenty-front/package.json
COPY ./packages/twenty-server/package.json /app/packages/twenty-server/package.json
COPY ./packages/twenty-server/patches /app/packages/twenty-server/patches
COPY ./packages/eslint-plugin-twenty/package.json /app/packages/eslint-plugin-twenty/package.json
RUN npx playwright install-deps

View File

@ -1,15 +0,0 @@
FROM node:18.16-bullseye as twenty-docs
WORKDIR /app
COPY ../../../../package.json .
COPY ../../../../yarn.lock .
COPY ../../../../.yarnrc.yml .
COPY ../../../../.yarn/releases /app/.yarn/releases
COPY ../../../packages/twenty-docs/package.json /app/packages/twenty-docs/package.json
RUN yarn
WORKDIR /app/packages/twenty-docs
CMD ["tail", "-f", "/dev/null"]

View File

@ -1,3 +0,0 @@
FROM --platform=linux/amd64 twentycrm/twenty-front as front
CMD ["/bin/sh", "-c", "/app/front/scripts/inject-runtime-env.sh && serve build"]

View File

@ -1,30 +0,0 @@
ARG PG_MAIN_VERSION=14
FROM postgres:${PG_MAIN_VERSION} as postgres
ARG PG_MAIN_VERSION
ARG PG_GRAPHQL_VERSION=1.3.0
ARG TARGETARCH
RUN set -eux; \
ARCH="$(dpkg --print-architecture)"; \
case "${ARCH}" in \
aarch64|arm64) \
TARGETARCH='arm64'; \
;; \
amd64|x86_64) \
TARGETARCH='amd64'; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac;
RUN apt update && apt install -y curl
# Install precompiled pg_graphql extensions
RUN curl -L "https://github.com/supabase/pg_graphql/releases/download/v${PG_GRAPHQL_VERSION}/pg_graphql-v${PG_GRAPHQL_VERSION}-pg${PG_MAIN_VERSION}-${TARGETARCH}-linux-gnu.deb" -o pg_graphql.deb
RUN dpkg --install pg_graphql.deb
COPY ./infra/prod/postgres/init.sql /docker-entrypoint-initdb.d/

View File

@ -1,10 +0,0 @@
SELECT 'CREATE DATABASE "default"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'default')\gexec
SELECT 'CREATE DATABASE "test"'
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'test')\gexec
SELECT 'CREATE USER twenty PASSWORD ''twenty'''
WHERE NOT EXISTS (SELECT FROM pg_user WHERE usename = 'twenty')\gexec
SELECT 'ALTER ROLE twenty superuser'\gexec

View File

@ -1,3 +0,0 @@
FROM --platform=linux/amd64 twentycrm/twenty-server as server
CMD ["node", "dist/src/main"]

View File

@ -0,0 +1,30 @@
FROM node:18.16.0-alpine as twenty-docs-build
WORKDIR /app
ARG SHOULD_INDEX_DOC
COPY ./package.json .
COPY ./yarn.lock .
COPY ./.yarnrc.yml .
COPY ./.yarn/releases /app/.yarn/releases
COPY ./packages/twenty-docs/package.json /app/packages/twenty-docs/package.json
RUN yarn
COPY ./packages/twenty-docs /app/packages/twenty-docs
RUN yarn nx build twenty-docs
CMD ["tail", "-f", "/dev/null"]
FROM node:18.16.0-alpine as twenty-docs
WORKDIR /app/packages/twenty-docs
COPY --from=twenty-docs-build /app/packages/twenty-docs/build ./build
RUN yarn global add serve
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 documentation."
CMD ["serve", "-s", "./build"]

View File

@ -0,0 +1,32 @@
FROM node:18.16.0-alpine as twenty-front-build
ARG REACT_APP_SERVER_BASE_URL
ARG REACT_APP_SERVER_AUTH_URL
ARG REACT_APP_SERVER_FILES_URL
WORKDIR /app
COPY ./package.json .
COPY ./yarn.lock .
COPY ./.yarnrc.yml .
COPY ./.yarn/releases /app/.yarn/releases
COPY ./packages/eslint-plugin-twenty /app/packages/eslint-plugin-twenty
COPY ./packages/twenty-front /app/packages/twenty-front
RUN yarn
RUN yarn nx build twenty-front
COPY ./packages/twenty-docker/prod/twenty-front/serve.json ./build
FROM node:18.16.0-alpine as twenty-front
WORKDIR /app/packages/twenty-front
COPY --from=twenty-front-build /app/packages/twenty-front/build ./build
COPY ./packages/twenty-front/scripts/inject-runtime-env.sh /app/packages/twenty-front/scripts/inject-runtime-env.sh
RUN yarn global add serve
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 frontend."
CMD ["/bin/sh", "-c", "./scripts/inject-runtime-env.sh && serve build"]

View File

@ -38,8 +38,8 @@ RUN dpkg --install wrappers.deb
RUN cp /usr/share/postgresql/${PG_MAIN_VERSION}/extension/wrappers* /opt/bitnami/postgresql/share/extension/
RUN cp /usr/lib/postgresql/${PG_MAIN_VERSION}/lib/wrappers* /opt/bitnami/postgresql/lib/
COPY ./infra/build/postgres/init.sql /docker-entrypoint-initdb.d/
COPY ./packages/twenty-docker/prod/twenty-postgres/init.sql /docker-entrypoint-initdb.d/
USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/postgresql/entrypoint.sh" ]
CMD [ "/opt/bitnami/scripts/postgresql/run.sh" ]
ENTRYPOINT ["/opt/bitnami/scripts/postgresql/entrypoint.sh"]
CMD ["/opt/bitnami/scripts/postgresql/run.sh"]

View File

@ -0,0 +1,4 @@
CREATE DATABASE "default";
CREATE DATABASE "test";
CREATE USER twenty PASSWORD 'twenty';
ALTER ROLE twenty superuser;

View File

@ -0,0 +1,21 @@
FROM node:18.16.0-alpine as twenty-server
WORKDIR /app
COPY ./package.json .
COPY ./yarn.lock .
COPY ./.yarnrc.yml .
COPY ./.yarn/releases /app/.yarn/releases
COPY ./packages/eslint-plugin-twenty /app/packages/eslint-plugin-twenty
COPY ./packages/twenty-server /app/packages/twenty-server
RUN yarn
RUN yarn
RUN yarn nx build twenty-server
WORKDIR /app/packages/twenty-server
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, ensuring it deploys faster and runs the same way regardless of the deployment environment."
CMD ["node", "dist/src/main"]

View File

@ -92,6 +92,7 @@ make docker-dev-up
Setup database, run migrations, and seed:
```bash
make docker-dev-sh
yarn
yarn nx database:init twenty-server
```
@ -104,6 +105,7 @@ make docker-dev-sh
yarn nx start:dev twenty-server
```
and in a separate terminal:
```bash
make docker-dev-sh
yarn nx start twenty-front

View File

@ -23,7 +23,7 @@ In this document, you'll learn how to install the project using yarn. You should
Before you can install and use Twenty, make sure you install the following on your computer:
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
- [Node v18](https://nodejs.org/en/download)
- [yarn v4](https://yarnpkg.com/getting-started/install).
- [yarn v4](https://yarnpkg.com/getting-started/install)
- [nvm](https://github.com/nvm-sh/nvm/blob/master/README.md)
:::info Note
@ -115,17 +115,15 @@ You need to provision this database with a `twenty` user (password: `twenty`), a
<Tabs>
<TabItem value="linux" label="Linux" default>
<b>Option 1:</b> To provision your database locally:
<br /><br />
<br />
```bash
make postgres-provision-on-linux
make postgres-on-linux
```
<b>Option 2:</b> If you have docker installed:
<br /><br />
<br />
```bash
make postgres-provision-on-docker
make postgres--on-docker
```
This will create a Docker container, exposing a PostgresSQL instance at [http://localhost:5432](http://localhost:5432).
You can access this using `twenty` postgres user (password: `twenty`)
@ -133,18 +131,16 @@ You can access this using `twenty` postgres user (password: `twenty`)
<TabItem value="mac-os" label="Mac OS" default>
<b>Option 1:</b> To provision your database locally:
<br /><br />
<br />
```bash
make postgres-provision-on-macos-intel #for intel architecture
make postgres-provision-on-macos-arm #for M1/M2/M3 architecture
make postgres-on-macos-intel #for intel architecture
make postgres-on-macos-arm #for M1/M2/M3 architecture
```
<b>Option 2:</b> If you have docker installed:
<br /><br />
<br />
```bash
make postgres-provision-on-docker
make postgres-on-docker
```
This will create a Docker container, exposing a PostgresSQL instance at [http://localhost:5432](http://localhost:5432).
You can access this using `twenty` postgres user (password: `twenty`)
@ -154,7 +150,7 @@ You can access this using `twenty` postgres user (password: `twenty`)
It's better to provision your database locally:
```bash
make provision-postgres-linux
make postgres-on-linux
```
This will create a Docker container, exposing a PostgresSQL instance at [http://localhost:5432](http://localhost:5432).
You can access this using `twenty` postgres user (password: `twenty`)

View File

@ -7,7 +7,7 @@
"start": "vite --host",
"start:clean": "yarn start --force",
"build": "tsc && vite build && yarn build:inject-runtime-env",
"build:inject-runtime-env": "./scripts/inject-runtime-env.sh",
"build:inject-runtime-env": "sh ./scripts/inject-runtime-env.sh",
"preview": "vite preview",
"eslint-plugin:setup": "cd ../packages/eslint-plugin-twenty/ && yarn && yarn build && cd ../../front/ && yarn upgrade eslint-plugin-twenty",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",

View File

@ -1,3 +1,4 @@
#!/bin/sh
echo "Generating env-config.js file from runtime environment variables..."
BASE_FILENAME="build/env-config.js"

View File

@ -1,14 +1,12 @@
provision-on-docker:
@docker compose -f docker/docker-compose.yml up
provision-on-macos-arm:
sh ./provision/provision-postgres-macos-arm.sh
sh ./macos/arm/provision-postgres-macos-arm.sh
provision-on-macos-intel:
sh ./provision/provision-postgres-macos-intel.sh
sh ./macos/intel/provision-postgres-macos-intel.sh
provision-on-linux:
sh ./provision/provision-postgres-linux.sh
sh ./linux/provision-postgres-linux.sh
build-pg_graphql-macos-arm:
sh ./build/pg_graphql/build-pg_graphql-macos-arm.sh
build-pg_graphql-macos-intel:
sh ./build/pg_graphql/build-pg_graphql-macos-intel.sh

View File

@ -1,95 +0,0 @@
#!/bin/bash
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
function echo_header {
COLOR=$1
MESSAGE=$2
echo -e "\e[${COLOR}m\n=======================================================\e[0m"
echo -e "\e[${COLOR}m${MESSAGE}\e[0m"
echo -e "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
function handle_error {
echo_header $RED "Error: $1"
exit 1
}
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.4.2
CARGO_PGRX_VERSION=0.10.2
current_directory=$(pwd)
# Install PostgresSQL
echo_header $GREEN "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
# Install pg_graphql extensions
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL..."
# Uninstall existing Rust installation if found
existing_rust_path=$(which rustc)
if [ -n "$existing_rust_path" ]; then
echo "Uninstalling existing Rust installation..."
rm -rf "$existing_rust_path"
fi
# To force a reinstall of cargo-pgrx, pass --force to the command below
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
cargo install --locked cargo-pgrx@$CARGO_PGRX_VERSION --force
cargo pgrx init --pg$PG_MAIN_VERSION download
# Create a temporary directory
temp_dir=$(mktemp -d)
cd "$temp_dir"
pwd
curl -LJO https://github.com/supabase/pg_graphql/archive/refs/tags/v$PG_GRAPHQL_VERSION.zip || handle_error "Failed to download pg_graphql package."
unzip pg_graphql-$PG_GRAPHQL_VERSION.zip
[[ ":$PATH:" != *":/opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin:"* ]] && PATH="/opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin:${PATH}"
cd "pg_graphql-$PG_GRAPHQL_VERSION"
cargo pgrx install --release --pg-config /opt/homebrew/opt/postgresql@$PG_MAIN_VERSION/bin/pg_config
# # Clean up the temporary directory
echo "Cleaning up..."
cd "$current_directory"
echo "Build complete in $temp_dir."

View File

@ -1,95 +0,0 @@
#!/bin/bash
# Colors
RED=31
GREEN=32
BLUE=34
# Function to display colored output
function echo_header {
COLOR=$1
MESSAGE=$2
echo -e "\e[${COLOR}m\n=======================================================\e[0m"
echo -e "\e[${COLOR}m${MESSAGE}\e[0m"
echo -e "\e[${COLOR}m=======================================================\e[0m"
}
# Function to handle errors
function handle_error {
echo_header $RED "Error: $1"
exit 1
}
cat << "EOF"
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@#*+=================@@@@@%*+=========++*%@@@@@@@
@@@@#- .+@@%=. .+@@@@@
@@@- .*@@%- .#@@@
@@= .=+++++++++++*#@@@= -++++++++++- %@@
@@. %@@@@@@@@@@@@@@@+ =%@@@@@@@@@@@@= +@@
@@. .@@@@@@@@@@@@@@+. -%@@@@@@@@@@@@@@+ +@@
@@. .@@@@@@@@@@@@*. -#@@#:=@@@@@@@@@@@= +@@
@@ @@@@@@@@@@#: :#@@#: -@@@@@@@@@@@= +@@
@@#====#@@@@@@@@#- .*@@@= -@@@@@@@@@@@= +@@
@@@@@@@@@@@@@@%- .*@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@@%= +@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@@@+ =@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@@@+. -%@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@@@*. -%@@@@@@@@@@@# -@@@@@@@@@@@= +@@
@@@@@#: :#@@@@@@@@@@@@@# -@@@@@@@@@@@+ +@@
@@@#: :#@@@@@@@@@@@@@@@# :@@@@@@@@@@@= +@@
@@= :+*+++++++++++*%@@@. :+++++++++- %@@
@@ :@@@%. .#@@@
@@- :@@@@@+: .+@@@@@
@@@#+===================+%@@@@@@@%*++=======++*%@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOF
echo_header $BLUE " DATABASE SETUP"
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.4.2
CARGO_PGRX_VERSION=0.9.8
current_directory=$(pwd)
# Install PostgresSQL
echo_header $GREEN "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
# Install pg_graphql extensions
echo_header $GREEN "Step [2/4]: Installing GraphQL for PostgreSQL..."
# Uninstall existing Rust installation if found
existing_rust_path=$(which rustc)
if [ -n "$existing_rust_path" ]; then
echo "Uninstalling existing Rust installation..."
rm -rf "$existing_rust_path"
fi
# To force a reinstall of cargo-pgrx, pass --force to the command below
curl https://sh.rustup.rs -sSf | sh
source "$HOME/.cargo/env"
cargo install --locked cargo-pgrx@$CARGO_PGRX_VERSION --force
cargo pgrx init --pg$PG_MAIN_VERSION download
# Create a temporary directory
temp_dir=$(mktemp -d)
cd "$temp_dir"
pwd
curl -LJO https://github.com/supabase/pg_graphql/archive/refs/tags/v$PG_GRAPHQL_VERSION.zip || handle_error "Failed to download pg_graphql package."
unzip pg_graphql-$PG_GRAPHQL_VERSION.zip
[[ ":$PATH:" != *":/usr/local/opt/postgresql@$PG_MAIN_VERSION/bin:"* ]] && PATH="/usr/local/opt/postgresql@$PG_MAIN_VERSION/bin:${PATH}"
cd "pg_graphql-$PG_GRAPHQL_VERSION"
cargo pgrx install --release --pg-config /usr/local/opt/postgresql@$PG_MAIN_VERSION/bin/pg_config
# # Clean up the temporary directory
echo "Cleaning up..."
cd "$current_directory"
echo "Build complete."

View File

@ -0,0 +1,17 @@
version: "3.9"
services:
postgres:
container_name: twenty_postgres
image: twentycrm/twenty-postgres:latest
volumes:
- twenty_db_data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=default
ports:
- "5432:5432"
volumes:
twenty_db_data:
name: twenty_db_data

View File

@ -0,0 +1,4 @@
CREATE DATABASE "default";
CREATE DATABASE "test";
CREATE USER twenty PASSWORD 'twenty';
ALTER ROLE twenty superuser;

View File

@ -0,0 +1,27 @@
#!/bin/bash
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.4.2
current_directory=$(pwd)
echo "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
echo "Step [2/4]: Installing GraphQL for PostgreSQL..."
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql
export PATH="/opt/homebrew/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH"
echo "Step [3/4]: Starting PostgreSQL service..."
brew services restart postgresql@15
echo "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sleep 5
psql -f /tmp/init.sql -d postgres

View File

@ -0,0 +1,116 @@
/*
This file is auto generated by pgrx.
The ordering of items is not stable, it is driven by a dependency graph.
*/
-- src/lib.rs:26
-- pg_graphql::_internal_resolve
CREATE FUNCTION graphql."_internal_resolve"(
"query" TEXT, /* &str */
"variables" jsonb DEFAULT '{}', /* core::option::Option<pgrx::datum::json::JsonB> */
"operationName" TEXT DEFAULT null, /* core::option::Option<alloc::string::String> */
"extensions" jsonb DEFAULT null /* core::option::Option<pgrx::datum::json::JsonB> */
) RETURNS jsonb /* pgrx::datum::json::JsonB */
LANGUAGE c /* Rust */
AS 'MODULE_PATHNAME', 'resolve_wrapper';
-- src/lib.rs:19
-- Is updated every time the schema changes
create sequence if not exists graphql.seq_schema_version as int cycle;
create or replace function graphql.increment_schema_version()
returns event_trigger
security definer
language plpgsql
as $$
begin
perform nextval('graphql.seq_schema_version');
end;
$$;
create or replace function graphql.get_schema_version()
returns int
security definer
language sql
as $$
select last_value from graphql.seq_schema_version;
$$;
-- On DDL event, increment the schema version number
create event trigger graphql_watch_ddl
on ddl_command_end
execute procedure graphql.increment_schema_version();
create event trigger graphql_watch_drop
on sql_drop
execute procedure graphql.increment_schema_version();
-- src/lib.rs:20
create function graphql.comment_directive(comment_ text)
returns jsonb
language sql
immutable
as $$
/*
comment on column public.account.name is '@graphql.name: myField'
*/
select
coalesce(
(
regexp_match(
comment_,
'@graphql\((.+?)\)'
)
)[1]::jsonb,
jsonb_build_object()
)
$$;
-- src/lib.rs:22
-- requires:
-- resolve
create or replace function graphql.resolve(
"query" text,
"variables" jsonb default '{}',
"operationName" text default null,
"extensions" jsonb default null
)
returns jsonb
language plpgsql
as $$
declare
res jsonb;
message_text text;
begin
begin
select graphql._internal_resolve("query" := "query",
"variables" := "variables",
"operationName" := "operationName",
"extensions" := "extensions") into res;
return res;
exception
when others then
get stacked diagnostics message_text = message_text;
return
jsonb_build_object('data', null,
'errors', jsonb_build_array(jsonb_build_object('message', message_text)));
end;
end;
$$;
-- src/lib.rs:21
create or replace function graphql.exception(message text)
returns text
language plpgsql
as $$
begin
raise exception using errcode='22000', message=message;
end;
$$;

View File

@ -0,0 +1,6 @@
comment = 'pg_graphql: GraphQL support'
default_version = '1.3.0'
module_pathname = '$libdir/pg_graphql'
relocatable = false
superuser = true
schema = 'graphql'

View File

@ -0,0 +1,27 @@
#!/bin/bash
PG_MAIN_VERSION=15
PG_GRAPHQL_VERSION=1.4.2
current_directory=$(pwd)
echo "Step [1/4]: Installing PostgreSQL..."
brew reinstall postgresql@$PG_MAIN_VERSION
echo "Step [2/4]: Installing GraphQL for PostgreSQL..."
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql--${PG_GRAPHQL_VERSION}.sql \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.control \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/share/postgresql@${PG_MAIN_VERSION}/extension
cp ./macos/arm/${PG_MAIN_VERSION}/pg_graphql/${PG_GRAPHQL_VERSION}/pg_graphql.so \
/usr/local/opt/postgresql@${PG_MAIN_VERSION}/lib/postgresql
export PATH="/usr/local/opt/postgresql@${PG_MAIN_VERSION}/bin:$PATH"
echo "Step [3/4]: Starting PostgreSQL service..."
brew services restart postgresql@15
echo "Step [4/4]: Setting up database..."
cp ./init.sql /tmp/init.sql
sleep 5
psql -f /tmp/init.sql -d postgres

View File

@ -1,6 +0,0 @@
docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./infra/build/front/Dockerfile -t twentycrm/twenty-front:0.1.5 -t twentycrm/twenty-front:latest .

View File

@ -1,6 +0,0 @@
docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./infra/build/postgres/Dockerfile -t twentycrm/twenty-postgres:0.2.0 -t twentycrm/twenty-postgres:latest .

View File

@ -1,6 +0,0 @@
docker buildx build \
--push \
--no-cache \
--platform linux/amd64,linux/arm64 \
-f ./infra/build/server/Dockerfile -t twentycrm/twenty-server:0.1.5 -t twentycrm/twenty-server:latest .

View File

@ -18957,8 +18957,8 @@ __metadata:
"eslint-plugin-twenty@file:../eslint-plugin-twenty::locator=twenty-front%40workspace%3Apackages%2Ftwenty-front":
version: 1.0.3
resolution: "eslint-plugin-twenty@file:../eslint-plugin-twenty#../eslint-plugin-twenty::hash=8c2438&locator=twenty-front%40workspace%3Apackages%2Ftwenty-front"
checksum: f8fcae09e4d1434abf95a36a716f54772b42c84a3638fbcf53df745045bf336cf32016c02880ad3bc738fe1e1a4d68d7fe98917ec4fce7d4bf1a37ae39530ec2
resolution: "eslint-plugin-twenty@file:../eslint-plugin-twenty#../eslint-plugin-twenty::hash=755c0c&locator=twenty-front%40workspace%3Apackages%2Ftwenty-front"
checksum: 3687c4e0fc2b8bc991e9b5a3e9bffdf120cce6ca3f04a6abba5bd831ea178eb18eec20288c75a460d54b766e5d1b678ba5c1d528f721e33dc18fe0bffed15b68
languageName: node
linkType: hard